Snap use of `gpu-2404-custom-wrapper` in the `command-chain` breaks priming individual parts
Please confirm
- [x] I have searched existing issues to check if an issue already exists for the bug I encountered.
Distribution
ubuntu
Distribution version
24.04
Output of "snap list --all lxd core20 core22 core24 snapd"
N/A
Output of "lxc info" or system info if it fails
N/A
Issue description
The use of the command-chain directive to call bin/gpu-2404-custom-wrapper which does not exist until the wrappers part is preventing priming individual parts, for example:
snapcraft prime qemu -v
...
Failed to generate snap metadata: The command-chain item 'bin/gpu-2404-custom-wrapper' defined in app 'daemon' does not exist or is not executable.
Recommended resolution: Ensure that 'bin/gpu-2404-custom-wrapper' is relative to the prime directory.
Failed to run snapcraft in instance
Full execution log: '/home/user/.local/state/snapcraft/log/snapcraft-20250620-101627.289457.log'
The offending section is here:
daemon:
command-chain:
- bin/gpu-2404-custom-wrapper
command: commands/daemon.start
reload-command: commands/daemon.reload
https://github.com/canonical/lxd-pkg-snap/blob/latest-edge/snapcraft.yaml#L102-L103
I've already tried moving the snapcraft/wappers/gpu-2404-custom-wrapper file to snapcraft/commands/gpu-2404-custom-wrapper and then updating the command-chanin to call commands/gpu-2404-custom-wrapper but that did not work as snapcraft is trying to find that in the primed root fs.
So instead I propose to remove the command-chain directive entirely, and instead source the bin/gpu-2404-custom-wrapper file in the commands/daemon.start file, and potentially also commands/daemon.reload and commands/daemon.stop files.
However this requires testing because these files escape the apparmor confinement so not clear which paths point where, or whether we need to source it in the reload and stop files.
Steps to reproduce
snapcraft prime <any part except wrappers> -v
...
Failed to generate snap metadata: The command-chain item 'bin/gpu-2404-custom-wrapper' defined in app 'daemon' does not exist or is not executable.
Recommended resolution: Ensure that 'bin/gpu-2404-custom-wrapper' is relative to the prime directory.
Failed to run snapcraft in instance
Information to attach
- [ ] Any relevant kernel output (
dmesg) - [ ] Instance log (
lxc info NAME --show-log) - [ ] Instance configuration (
lxc config show NAME --expanded) - [ ] Main daemon log (at
/var/log/lxd/lxd.logor/var/snap/lxd/common/lxd/logs/lxd.log) - [ ] Output of the client with
--debug - [ ] Output of the daemon with
--debug(or uselxc monitorwhile reproducing the issue)
@mihalicyn @simondeziel does my proposal sound OK to you?
@mihalicyn @simondeziel does my proposal sound OK to you?
I was not familiar with command-chain mechanism but it seems to be simple enough according to https://documentation.ubuntu.com/snapcraft/stable/reference/project-file/snapcraft-yaml/#apps.%3Capp-name%3E.command-chain
As such, your proposal sounds fine.
I've already tried moving the snapcraft/wappers/gpu-2404-custom-wrapper file to snapcraft/commands/gpu-2404-custom-wrapper and then updating the command-chanin to call commands/gpu-2404-custom-wrapper but that did not work as snapcraft is trying to find that in the primed root fs.
Sounds like a bug in snapcraft to me. Especially that moving to snapcraft/commands/gpu-2404-custom-wrapper does not help. Why they it doesn't fail on other files referenced in the daemon section? I mean that we have:
daemon:
command-chain:
- commands/gpu-2404-custom-wrapper
command: commands/daemon.start
reload-command: commands/daemon.reload
stop-command: commands/daemon.stop
And it fails on commands/gpu-2404-custom-wrapper and doesn't fail on commands/daemon.start? These are treated somehow differently?
I've already tried moving the snapcraft/wappers/gpu-2404-custom-wrapper file to snapcraft/commands/gpu-2404-custom-wrapper and then updating the command-chanin to call commands/gpu-2404-custom-wrapper but that did not work as snapcraft is trying to find that in the primed root fs.
Sounds like a bug in snapcraft to me. Especially that moving to
snapcraft/commands/gpu-2404-custom-wrapperdoes not help. Why they it doesn't fail on other files referenced in thedaemonsection? I mean that we have:daemon: command-chain: - commands/gpu-2404-custom-wrapper command: commands/daemon.start reload-command: commands/daemon.reload stop-command: commands/daemon.stopAnd it fails on
commands/gpu-2404-custom-wrapperand doesn't fail oncommands/daemon.start? These are treated somehow differently?
Yes it seems command-chain uses the primed filesystem whereas *-command looks in the commands directory of the packaging repo.
I've already tried moving the snapcraft/wappers/gpu-2404-custom-wrapper file to snapcraft/commands/gpu-2404-custom-wrapper and then updating the command-chanin to call commands/gpu-2404-custom-wrapper but that did not work as snapcraft is trying to find that in the primed root fs.
Sounds like a bug in snapcraft to me. Especially that moving to
snapcraft/commands/gpu-2404-custom-wrapperdoes not help. Why they it doesn't fail on other files referenced in thedaemonsection? I mean that we have:daemon: command-chain: - commands/gpu-2404-custom-wrapper command: commands/daemon.start reload-command: commands/daemon.reload stop-command: commands/daemon.stopAnd it fails on
commands/gpu-2404-custom-wrapperand doesn't fail oncommands/daemon.start? These are treated somehow differently?Yes it seems command-chain uses the primed filesystem whereas
*-commandlooks in thecommandsdirectory of the packaging repo.
@mihalicyn do we really need wrapper to run on stop and reload btw?