-
Notifications
You must be signed in to change notification settings - Fork 21
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
fix: check if lxd snap is installed #585
fix: check if lxd snap is installed #585
Conversation
Check if the lxd snap is installed by querying the snapd socket instead of looking for an executable in the path, as lxd can use auto-installer stubs. Co-authored-by: Callahan Kovacs <callahan.kovacs@canonical.com> Signed-off-by: Claudio Matsuoka <claudio.matsuoka@canonical.com>
Signed-off-by: Claudio Matsuoka <claudio.matsuoka@canonical.com>
Signed-off-by: Claudio Matsuoka <claudio.matsuoka@canonical.com>
Signed-off-by: Claudio Matsuoka <claudio.matsuoka@canonical.com>
Signed-off-by: Claudio Matsuoka <claudio.matsuoka@canonical.com>
Signed-off-by: Claudio Matsuoka <claudio.matsuoka@canonical.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, nice unit test!
craft_providers/lxd/installer.py
Outdated
logger.debug(f"LXD snap status: {status}") | ||
# snap status can be "installed" or "active" - "installed" revisions | ||
# are filtered from this API call with `select: enabled` | ||
return bool(status == "active") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about retaining the old check as well? It's unlikely to fail but may still be useful:
return bool(status == "active) and shutil.which("lxd") is not None
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dariuszd21 also raised the issue about lxd on arch and nixos not being snap-packaged, we may need a dual check to cover these cases too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yikes, that's a good point.
Does that stubbed LXD exec file on Ubuntu come in as an apt package? Or is that just part of the base image?
I'm wondering if craft-providers could check if LXD is installed as a snap only on Ubuntu with is_ubuntu_like
.
Making an API call to LXC may be the most robust check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Covered this for now by verifying the presence of a non-snap lxd socket in the standard location, but a more robust verification would be always welcome.
You'll need to cherry-pick #572 for the failing integration tests |
Signed-off-by: Claudio Matsuoka <claudio.matsuoka@canonical.com>
Signed-off-by: Claudio Matsuoka <claudio.matsuoka@canonical.com>
Signed-off-by: Claudio Matsuoka <claudio.matsuoka@canonical.com>
Re-requesting reviews because Dariusz raised a concern about a new scenario where non-snap LXD can be installed on the system. |
Signed-off-by: Claudio Matsuoka <claudio.matsuoka@canonical.com>
Signed-off-by: Claudio Matsuoka <claudio.matsuoka@canonical.com>
Signed-off-by: Claudio Matsuoka <claudio.matsuoka@canonical.com>
I am a bit conflicted by this as we can also be checking for |
By asking snapd we can have additional system health assurances (such as that snapd is up and running). Checking the presence of the socket file is what was possible in the non-snap case. |
Check if the lxd snap is installed by querying the snapd socket instead of looking for an executable in the path, as lxd can use auto-installer stubs. Co-authored-by: Callahan Kovacs <callahan.kovacs@canonical.com> Signed-off-by: Claudio Matsuoka <claudio.matsuoka@canonical.com>
Check if the lxd snap is installed by querying the snapd socket instead of looking for an executable in the path, as lxd can use auto-installer stubs. Co-authored-by: Callahan Kovacs <callahan.kovacs@canonical.com> Signed-off-by: Claudio Matsuoka <claudio.matsuoka@canonical.com>
Check if the lxd snap is installed by querying the snapd socket instead of looking for an executable in the path, as lxd can use auto-installer stubs. Co-authored-by: Callahan Kovacs <callahan.kovacs@canonical.com> Signed-off-by: Claudio Matsuoka <claudio.matsuoka@canonical.com>
Check if the lxd snap is installed by querying the snapd socket
instead of looking for an executable in the path, as lxd can use
auto-installer stubs.
tox
?