systemctl reload snap.lxd.daemon.service starts stopped instances with boot.auto = true
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
- Stop an instance that has
boot.autostart: "true"configured. - systemctl reload snap.lxd.daemon.service
- The instance is now running
I did not expect it to change to Running after a reload, I only expect this after a restart.
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.
LXD should already be able to distinguish between snap restart and snap reload, as it chooses not to stop instances during a reload.
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.
Wonder if we can set an env var on stop so its detectabke on start up.
This also results in instances auto starting when the daemon is auto-refreshed by snapd. While the docs are fairly clear that
boot.autostartis tied to the LXD server's lifetime, I agree that this behavior is sub-optimal in a snap-deployed context.
Yeah my LXD snap apparently updated yesterday evening and this morning I found some instances running that weren't running before the update.