Container-shutdown event not raised after executing halt in container

I’m trying to detect when my containers shutdown. I’m listening on /1.0/events?type=lifecycle websocket, and I can detect when the container closes by executing lxc stop c, but not when I shutdown it manually by lxc exec c halt.

Not working again in 5.0, i get instance-shutdown event on manually stopping instance using lxc stop, but not using halt from inside instance

Can you show reproducer steps please.

lxc launch ubuntu: lxd42 --vm
lxc shell lxd42
snap refresh
snap switch --channel=4.2/stable lxd
snap refresh lxd
lxd init # all defaults except for storage backend: btrfs
lxc launch ubuntu: test
lxc monitor --type=lifecycle > lifecycle.log &
lxc exec test halt
tail lifecycle.log
location: none
metadata:
  action: container-shutdown
  source: /1.0/containers/test
timestamp: "2022-09-26T11:06:28.278947378Z"
type: lifecycle
lxc launch ubuntu: lxd50 --vm
lxc shell lxd50
snap refresh
snap switch --channel=5.0/stable lxd
snap refresh lxd
lxd init # all defaults except for storage backend: btrfs
lxc launch ubuntu: test
lxc monitor --type=lifecycle > lifecycle.log &
lxc exec test halt
tail lifecycle.log 
  action: instance-exec
  context:
    command:
    - halt
  source: /1.0/instances/test
project: default
timestamp: "2022-09-26T11:09:57.089888559Z"
type: lifecycle

any news regarding this issue?

I’ve assigned it to myself now to take a look and see if i can reproduce.

Thanks for chasing, I’m sorry that we missed this one.

I’ve got a fix and it should be in LXD 5.8 and then later in LXD 5.0.2.

1 Like