Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

systemctl reload snap.lxd.daemon.service starts stopped instances with boot.auto = true #14464

Open
vosdev opened this issue Nov 14, 2024 · 4 comments
Assignees
Labels
Bug Confirmed to be a bug Snap

Comments

@vosdev
Copy link
Contributor

vosdev commented Nov 14, 2024

Required information

  • Distribution: Ubuntu
  • Distribution version: 24.04
  • The output of "snap list --all lxd core20 core22 core24 snapd":
Name    Version      Rev    Tracking       Publisher   Notes
core22  20240904     1621   latest/stable  canonical✓  base,disabled
core22  20241001     1663   latest/stable  canonical✓  base
lxd     6.1-78a3d8f  30130  latest/stable  canonical✓  -
snapd   2.63         21759  latest/stable  canonical✓  snapd

Issue description

Updating LXD's certificates I noticed that instances that were in a Stopped state, changed to Running after issueing systemctl reload snap.lxd.daemon.service.

Steps to reproduce

  1. Stop an instance that has boot.autostart: "true" configured.
  2. systemctl reload snap.lxd.daemon.service
  3. The instance is now running

I did not expect it to change to Running after a reload, I only expect this after a restart.

@MggMuggins
Copy link
Contributor

MggMuggins commented Nov 15, 2024

This also results in instances auto starting when the daemon is auto-refreshed by snapd. While the docs are fairly clear that boot.autostart is tied to the LXD server's lifetime, I agree that this behavior is sub-optimal in a snap-deployed context.

I suspect that the LXD server currently has no way to tell why it was started; looks like the snap holds on to the start state but I'm reasonably confident we can't expect ${LXD_COMMON}/state to exist in all deployment contexts.

@MggMuggins MggMuggins added Bug Confirmed to be a bug Snap labels Nov 15, 2024
@tomponline
Copy link
Member

LXD should already be able to distinguish between snap restart and snap reload, as it chooses not to stop instances during a reload.

@MggMuggins
Copy link
Contributor

Yeah, it's based on the signal (SIGTERM for reload and SIGPWR for shutdown). The problem is distinguishing during start how the daemon was shut down; that is, to effectively disable boot.autostart when the daemon was shut down with SIGTERM.

@tomponline
Copy link
Member

Wonder if we can set an env var on stop so its detectabke on start up.

@MggMuggins MggMuggins self-assigned this Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Confirmed to be a bug Snap
Projects
None yet
Development

No branches or pull requests

3 participants