-
Notifications
You must be signed in to change notification settings - Fork 8
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
Make LXD refresh optional (speed reason) #4
Conversation
> > time snap info lxd | grep "installed" > ... > real 0m0.430s > > > time snap info lxd | grep "^installed" > ... > real 0m0.341s
The failing test cannot install juju 3.0:
which looks unrelated to the PR and no re-trigger button on my side :-( |
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.
LGTM - one minor grammatical error
@barrettj12 - this was initially your work, I'll leave this to you to merge if/when you're happy! Thanks! |
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.
I definitely support the option to disable the snap install/refresh, however I'm not sure if this is the right way to do it. I think your example in the README shows the issue here:
- name: Setup LXD
uses: canonical/setup-lxd@[sha]
with:
channel: 5.0/stable
refresh: false
This seems like it should ensure LXD version 5.0.x, however we have set refresh: false
, so we could end up with a different LXD version to what we've specified.
This also doesn't handle the case where LXD is installed not using snap, and we want to disable the snap install.
I'd prefer either of the following options:
- The channel is meaningless if we're not doing a snap install/refresh, so we could set the input
channel: ''
to disable the snap install/refresh. Then we can do a checkif [[ -n ${{ inputs.channel }} ]]
before the snap install refresh. - If we want to be more explicit, we could have a new input
install-snap
which is true by default (or the converseuse-existing-lxd
, false by default). Then we'd have to document thatinstall-snap: false
(resp.use-existing-lxd: true
) will disable the snap install/refresh and override any value provided tochannel
.
README.md
Outdated
By default, this action will install LXD from the `latest/stable` snap channel. You can specify a different channel using the `channel` input. (See `snap info lxd` for a list of available channels). | ||
It will default install LXD from the `latest/stable` snap channel. | ||
You can specify a different channel using the `channel` input | ||
(see `snap info lxd` for a list of available channels). |
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.
No need to change the text here.
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.
ACK, I will revert it. Old-school... 80 symbols length for the line in a source code. :-)
action.yml
Outdated
- name: Refresh LXD snap | ||
shell: bash | ||
run: | | ||
if ( "${{ inputs.refresh }}" == "true" ) ; then |
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.
I think this check should be on the previous step. If LXD is installed another way, e.g. source, apt repo, then snap info lxd | grep "installed"
will return false and we will install the snap anyway.
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.
We should really be checking if LXD is on PATH by running e.g. lxc version
.
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.
It is a question how deep should we follow the rabbit hole.
We can declare compatibility with 'ubuntu-latest' as a base only (lxd is installed from snap) or provide support for all kind of installations. Sent a new commit checking all the mentioned scenarios.
@taurus-forever: I've opened a new PR #5 which does this using the |
Shared my vision in PR#5, I can close this PR if you as a repo owner would like to go PR#5 direction. |
Good points. I have refactored the last commits to match your expectations. |
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.
I've changed my mind on the approach in #5. I think you're right that we should have an explicit configuration option to disable the snap refresh. We should think it through a bit to make sure we're doing something sensible, and won't have to go back and change it later.
My use case: make sure a certain version of LXD is installed. We do this by specifying a channel input (as per current behaviour)
uses: canonical/setup-lxd
with:
channel: 5.2/candidate
Your use case: snap refresh
takes too long, we just want to use the LXD pre-installed on the runners. Great, we can add another input to do this.
uses: canonical/setup-lxd
with:
refresh: false
Now if we have refresh: false
and the LXD snap is pre-installed, don't snap install
/refresh
anything. refresh
defaults to true
.
The question is what should happen if we have refresh: false
but the LXD snap is not installed. There are a few options and I'm not sure which one is best:
- install LXD anyway. This means users don't have a way to disable the snap install, which they might want to do if e.g. they're installing LXD some other way.
- don't install LXD. This will cause the action to fail unless the user installs LXD another way.
- check
$PATH
/dpkg
for LXD, but this quickly goes down a rabbit hole as you say (environment issues, might match a different script called lxd, etc).
I'm probably favouring option 2 cause:
- it allows users to disable the snap install if they want to install from source
- it makes the logic simpler (if refresh = false, skip the snap install/refresh step)
In this case it is probably more sensible to call the new inputinstall-snap
or something, instead ofrefresh
.
The only downside here is it assumes (want to install LXD) == (want to refresh LXD). I'm not sure if a user might want one, but not the other.
FWIW, I think the following approach is probably the simplest:
uses: canonical/setup-lxd First check if LXD is installed. If it is, move on. If it isn't then run
uses: canonical/setup-lxd
with:
channel: 5.2/candidate Then check if LXD is installed, and either There is a little bit of magic here, but it means that existing workflows that specify a version can be left alone and will continue to work as expected, and people who are happy to use whatever is installed on the latest Ubuntu Github Actions runner will have a (very simple) way to just get up and running. While your preferred option is more explicit, the idea of having a |
2 Jon: "Then check if LXD is installed" is a tricky definition. Installed from snap or whatever? IMHO: 1) do one thing, but do it right. 2) do not harm. Currently, the action
The current main branch doesn't support any other LXD sources. To do not harm: avoid changes if LXD exist from unsupported sources. Consider to add 'force: true' if you want to remove current LXD and force snap version. TODO: support all possible sources. Not a topic for this PR. Do it right: make sure proper version of LXD from snap is installed (if LXD is installed from snap only).
It should be installed, as the option called If you want to conquire the entire world:
... but I would avoid this direction as it looses K.I.S.S. Let's focus on the reported issue: avoid long update if currently installed LXD is fine for you. I will address all comments, but IMHO it follows 1) + 2) above right now. |
Just to clarify: I think we should only consider "checking for install" as "is LXD installed with a snap" -- I don't think we should cater for LXD from other sources. This is a Canonical Github Action, and we only really distribute through snap, and thus we should only be supporting that in this action :) |
I like @jnsgruk's approach: simple, elegant, and does everything we need to do at the moment. I'll update my PR #5 to match. We can always revisit it if we need to later. This will break current default behaviour, but this action is in early stages so we make no guarantee of compatibility here. In fact, I'll add a note about that to the README. |
Resolving the PR as the proper fix should be addressed in #5 (as mentioned #4 (comment)). Tnx! |
Hi,
After migration from 'whywaita/setup-lxd' to 'canonical/setup-lxd' we noticed significant performance slows down (90x times),
see canonical/charmed-mongodb-rock#2 (comment)
TL;DR. LXD is already installed on GitHub 'ubuntu-latest' image, so 'whywaita/setup-lxd' did nothing spending ~10 seconds but 'canonical/setup-lxd' is always upgrading LXD which tooks ~15 minutes.
The PR proposes to make 'LXD refresh' optional (in a backward compatible way). Tnx!