-
Notifications
You must be signed in to change notification settings - Fork 75
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
charmcraft: perform LXD checks before use (CRAFT-420) #474
Conversation
Invoke ensure_lxd_is_ready() interface before using LXD provider. This consolidates a couple of existing checks done elsewhere as well as a new one for ensuring the user has the necessary permissions to use LXD. Minor simplification of imports used in providers module to improve and update mocks accordingly. Example error: ``` $ /snap/bin/charmcraft pack LXD requires additional permissions. Please ensure that the user is in the 'lxd' group. (full execution logs in '/home/test1/snap/charmcraft/common/charmcraft-log-0xgcist7') ``` Signed-off-by: Chris Patterson <chris.patterson@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 generally good, tone of voice needs adjusting.
charmcraft/providers.py
Outdated
lxd.install() | ||
except lxd.LXDInstallationError as error: | ||
raise CommandError( | ||
"Failed to install LXD. Please visit https://snapcraft.io/lxd for " |
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.
Remove Please, start with Visit -> https://discourse.ubuntu.com/t/tone-of-voice/18883
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.
Ah yes, I questioned it when I wrote it way back when and never did reconsider. 🤔 I think I just feel compelled to be polite 🤣 will fix (but note that this was just an indent change, not new text).
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.
done!
charmcraft/providers.py
Outdated
raise CommandError( | ||
"Failed to install LXD. Please visit https://snapcraft.io/lxd for " | ||
"LXD is required, but not installed. Please visit https://snapcraft.io/lxd for " |
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.
same
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.
done!
Signed-off-by: Chris Patterson <chris.patterson@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 great!
if not is_provider_available(): | ||
if confirm_with_user( | ||
"LXD is required, but not installed. Do you wish to install LXD " | ||
"and configure it with the defaults?", |
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.
Not worth for this branch, but for the future: for readability in these cases please write the long message outside the if
. Thanks!
Invoke ensure_lxd_is_ready() interface before using LXD
provider. This consolidates a couple of existing checks
done elsewhere as well as a new one for ensuring the user
has the necessary permissions to use LXD.
Minor simplification of imports used in providers module
to improve and update mocks accordingly.
Example error:
Signed-off-by: Chris Patterson chris.patterson@canonical.com