-
Notifications
You must be signed in to change notification settings - Fork 41
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
Calling Snap.ensure(....)
with the same revision
shouldn't refresh the snap if the revision is already installed
#120
Comments
@addyess Can you include a repro case? Is this just an optimisation, to avoid starting the |
@benhoyt I don't think it'd be hard to go back to something and reproduce in my charm code. I found a event that was firing regularly into a path which called: cache = snap_lib.SnapCache()
which = cache[MY_SNAP]
log.info("Ensuring %s snap revision=%s", MY_SNAP, MY_REV)
which.ensure(state=SnapState.Present, name=MY_SNAP, revision=MY_REV) Everytime the refresh occurred, snapd would restart the services provided by that even though it was already on that revision. i think i didn't anticipate that |
So I just tested this with the
Here your code is specifying the revision, so We could ask the snap team why it does that, but probably our best bet is to update this library to check "if all of the details are the same, do nothing". Would you be willing to put up a PR and test this? It'll be something like so (completely untested): if (not channel or channel != self._channel or
not revision or revision != self._revision or
# similar constructs for cohort and devmode ...
):
self._refresh(...)
else:
logger.info("Snap already up to date") |
I didn't expect the
ensure(...)
method to actually cause a snap-refresh if the revision requested already matched the installed revision. If one callsensure(...)
with a channel, and the revision is unchanged, no refresh is triggered.So, in my charm where i'm trying to set a specific revision on the snap, I had to add this
if
clause prevent a constant snap refresh to a revision where it already was.The text was updated successfully, but these errors were encountered: