Can not stop lxc containers with a systemd service on host reboot

The LXD service has a 10min stop timeout to allow for boot.host_shutdown_timeout to be far higher than 30s/60s.

boot.stop.priority can be used to influence shutdown ordering. All instances at the same priority level will be shutdown concurrently, once those are done, the next set at the next priority level will be processed.

The regression you noticed is most likely because of how snapd is now interacting with systemd, so it’s something that’s outside of our control. You can avoid this by not going through the snap (which is what pylxd would get you) but you’re trying to have a service perform actions while it’s at the same time being told to shutdown by systemd too, so you’re very likely to be racing LXD’s normal shutdown process here.

Maybe you could try two different units, one that starts after LXD (easy enough) and another one which is part of the shutdown.target and so starts when a shutdown is triggered, that may give you more control on ordering during shutdown.