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

Add lxd-stophook wrapper that redirects container stop callhooks to lxd-user #635

Merged
merged 2 commits into from
Nov 25, 2024

Conversation

tomponline
Copy link
Member

@tomponline tomponline commented Nov 25, 2024

  • Adds lxd-stophook wrapper that redirects container stop callhooks to lxd-user.
  • Builds lxd binary into sbin directory (so as not to conflict with lxd-stophook script in bin/lxd).
  • Changes LXD_EXEC_PATH to use the lxd binary in sbin directory.

Related to canonical/lxd#14526

Related to canonical/lxd#13331

This command is intended to replace the `lxd` command in the snap so that
existing running containers that are stopping will call this script as part of
their stop hooks.

This will then "route" the command to the `lxd-user` command that will be
statically compiled so that it can connect to the running LXD daemon via
the unix socket to indicate the container is stopping, even after refreshing
the LXD snap to a different core base snap.

Signed-off-by: Thomas Parrott <[email protected]>
(cherry picked from commit 4d10cbd)
    The PATH inside the snap is configured to prefer /sbin over /bin so the lxd binary will still
    be called by default.

    The lxd-stophook-wrapper script which will be placed into `/bin/lxd`.

    Because containers are configured to call `/snap/lxd/current/bin/lxd callhook` which in turn will be
    routed to `/snap/lxd/current/bin/lxd-user` by the lxd-stophook-wrapper script, which will then connect
    to LXD's unix socket to indicate to the server that the container is stopping.

    Because lxd-user is compiled as a static binary this will work across snap core base changes.

    Also update LXD_EXEC_PATH env var so that LXD will still directly execute itself when needed, rather
    than going via the lxd-stophook wrapper script.

Signed-off-by: Thomas Parrott <[email protected]>
(cherry picked from commit 75de117)
@tomponline tomponline changed the title Add lxd-stophook wrapper that redirects container stop callhooks to lxd-user Add lxd-stophook wrapper that redirects container stop callhooks to lxd-user Nov 25, 2024
@tomponline
Copy link
Member Author

Will follow up with a change to lxd itself that separately configures liblxc container's stop hook paths to use the lxd-stophook script in bin/lxd.

@tomponline tomponline self-assigned this Nov 25, 2024
@tomponline
Copy link
Member Author

canonical/lxd#14526

@tomponline tomponline merged commit 68321c2 into canonical:latest-edge Nov 25, 2024
4 checks passed
@tomponline tomponline deleted the tp-stop-hook branch November 25, 2024 15:56
tomponline added a commit to canonical/lxd that referenced this pull request Nov 25, 2024
…of the snap instead of sbin (#14526)

This is the historical path where the lxd binary used to be, but it was
replaced with a small wrapper script which redirects the stop hook
requests to lxd-user (which is statically compiled) so that stop hook
notifications to LXD work when the snap base version is changed.

Related to canonical/lxd-pkg-snap#635

Fixes #13331
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants