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

snapcraft/commands/daemon.start: always remount /bin/kmod #263

Merged
merged 1 commit into from
Jan 17, 2024

Conversation

simondeziel
Copy link
Member

Upon update, the daemon.start would keep any existing mountbind of /bin/kmod rather than remount a fresh one. This lead to such situation:

root@sdeziel-lemur:~# nsenter -m -t "$(lxc info | awk '/server_pid:/ {print $2}')"
root@sdeziel-lemur:/# mount | grep kmod
/var/lib/snapd/snaps/lxd_26615.snap (deleted) on /usr/bin/kmod type squashfs (ro,relatime,errors=continue,threads=single

Always remounting that script should avoid holding onto old snap data.

Copy link
Member

@tomponline tomponline left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does LXD also need to umount this on LXD stop?

@tomponline
Copy link
Member

@simondeziel I had a quick search in lxd-pkg-snap for /bin/kmod and noticed there are some hardcoded references to "core22", given we are planning to change to core24 soon, I suspect this may become an issue. Please could you see if there is a way to make that dynamic somehow to refer to the correct core?

@tomponline
Copy link
Member

@simondeziel ah looks like you had the same though as me here #262 thanks!

@simondeziel
Copy link
Member Author

Does LXD also need to umount this on LXD stop?

daemon.stop does surprisingly little umount'ing, should we also umount other bits? @mihalicyn I'd like your input on this, please.

@tomponline
Copy link
Member

Does LXD also need to umount this on LXD stop?

daemon.stop does surprisingly little umount'ing, should we also umount other bits? @mihalicyn I'd like your input on this, please.

If daemon.stop is called during systemctl reload snap.lxd.daemon then we probably should unmount anything as it could be in use by running instances.

@simondeziel
Copy link
Member Author

While daemon.stop has code meant to handle reloads:

https://github.com/canonical/lxd-pkg-snap/blob/latest-edge/snapcraft/commands/daemon.stop#L32-L42:

echo "=> Stop reason is: ${reason}"
...
# Handle reloads and crashes
if [ "${reason}" = "reload" ] || [ "${reason}" = "crashed" ]; then
    exit 0
fi

It is not invoked by either systemctl reload snap.lxd.daemon or the heavier wait snap restart lxd --reload as I'm not seeing the => Stop reason is: message in the logs.

This is probably fine because reloads have a dedicated script (daemon.reload, https://github.com/canonical/lxd-pkg-snap/blob/latest-edge/snapcraft.yaml#L81) which essentially just signals the existing LXD that a reload is needed an then kill it.

@tomponline
Copy link
Member

Well thats odd that snap restart lxd doesnt invoke it, id have thought it would invoke stop and then start hooks (as that does stop instances).

There are clearly differences though as there is this open snapd bug https://bugs.launchpad.net/snapd/+bug/2028141

@simondeziel
Copy link
Member Author

Well thats odd that snap restart lxd doesnt invoke it, id have thought it would invoke stop and then start hooks (as that does stop instances).

Did you miss the --reload in snap restart lxd --reload?

@tomponline
Copy link
Member

Well thats odd that snap restart lxd doesnt invoke it, id have thought it would invoke stop and then start hooks (as that does stop instances).

Did you miss the --reload in snap restart lxd --reload?

i did :)

@tomponline tomponline merged commit 4b5a032 into canonical:latest-edge Jan 17, 2024
3 checks passed
@simondeziel simondeziel deleted the kmod-remount branch January 17, 2024 13:59
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