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
many: support refresh hold/unhold to API and CLI #12073
Conversation
060e468
to
13ebf7d
Compare
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.
thank you, did a pass. mostly small things and trying to clarify messages and help
@degville could you review the outputted text in this PR please? We'd like to make the help, output and error messages clear to users. They're in |
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.
Thanks for pinging me! I've made a few comments, with the main suggestion being for the principle help text - but it's nothing major. It's difficult to find the path of least cognitive resistance with hold and held. Please feel free to ignore or update accordingly.
cmd/snap/cmd_snap_op.go
Outdated
Holds (--hold) specified for snaps are only applied to general refreshes ('snap | ||
refresh' without specifying snaps and auto-refreshes), but snaps can still be | ||
refreshed in specific refreshes (i.e, 'snap refresh snap-a snap-b'). Using | ||
--hold without specifying any snaps will only hold auto-refreshes for all snaps. |
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 tried tweaking this slightly to hopefully make our intentions clearer (I left the time specifics and syntax to the command options list):
Holds (--hold) specified for snaps are only applied to general refreshes ('snap | |
refresh' without specifying snaps and auto-refreshes), but snaps can still be | |
refreshed in specific refreshes (i.e, 'snap refresh snap-a snap-b'). Using | |
--hold without specifying any snaps will only hold auto-refreshes for all snaps. | |
Hold (--hold) is used to postpone general snap refresh updates for either all | |
snaps, or for the specified snaps. It is only effective with auto-refreshes and | |
refreshes that do not target snaps specifically. If a snap is first held but | |
then added to a refresh command, such as `snap refresh target-snap`, it will | |
still be refreshed. |
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.
@degville I think in the reformulation is lost that "snap refresh --hold" blocks only auto-refreshes and not "snap refresh" (no specific snap) itself.
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.
Thanks @pedronis, I'd forgotten that it didn't block a general snap refresh. Does this make it clearer?
Holds (--hold) specified for snaps are only applied to general refreshes ('snap | |
refresh' without specifying snaps and auto-refreshes), but snaps can still be | |
refreshed in specific refreshes (i.e, 'snap refresh snap-a snap-b'). Using | |
--hold without specifying any snaps will only hold auto-refreshes for all snaps. | |
Hold (--hold) is used to postpone automatic snap refresh updates for all snaps | |
when no snaps are specified, or for the specified snaps. It is only effective | |
with auto-refreshes and will not block either general refresh requests from | |
`snap refresh` or specific snap requests from `snap refresh target-snap`. |
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 does block general refreshes for specific snaps. So I still don't think I read that in the new version. Maybe the easiest is really to have two paragraphs, one about "snap refresh --hold" and a separate one about "snap refresh --hold <snap>"?
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 tried to split into a general/intro paragraph and then one paragraph about when no snaps are specified and one for snaps being specified.
thanks @degville, I'll review your comments first and then @MiguelPires we'll see how to proceed |
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.
the summaries for the remove cases can probably be made to match more @degville suggestions for the cmd/snap ones
daemon/api_snaps.go
Outdated
} | ||
|
||
tss = []*state.TaskSet{ts} | ||
msg = i18n.G("Remove hold on auto-refreshes of all snaps.") |
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.
this probably can be changed to be a bit more like the new cmd/snap message
daemon/api_snaps.go
Outdated
return nil, err | ||
} | ||
|
||
msg = fmt.Sprintf(i18n.G("Remove hold on general refreshes of %s."), strutil.Quoted(inst.Snaps)) |
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
marking blocked as while the command behavior matches our knoewn use cases and precedent, we likely want first to make the API itself less implicit/ambiguous I talked about this with @MiguelPires |
b1aacfc
to
757f30e
Compare
I rebased this on master and switched it to use the new API. Next step is adding a level parameter to the hold APIs themselves |
Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
it can have values "auto-refresh" or "general" matching snapstate.HoldAutoRefresh or snapstate.HoldGeneral holding general refreshes for all snaps is not supported atm
757f30e
to
2f8f540
Compare
When specific snaps are mentioned --hold is effective on their auto-refreshes | ||
and will also silently block general refresh requests from 'snap refresh' of | ||
those snaps while explicit targeted 'snap refresh target-snap' will not be | ||
blocked. |
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.
@pedronis Thanks for thinking about this - I much prefer your split approach, which I think is far easier to understand. It all looks good but I've tried to clarify the final paragraph slightly by copying the terminology and structure of the previous paragraph.
When specific snaps are mentioned --hold is effective on their auto-refreshes | |
and will also silently block general refresh requests from 'snap refresh' of | |
those snaps while explicit targeted 'snap refresh target-snap' will not be | |
blocked. | |
When snaps are specified --hold is effective on both their auto-refreshes | |
and general refresh requests from `snap refresh`. However, specific snap | |
requests from 'snap refresh target-snap' remain unblocked and will proceed. |
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.
The recent changes LGTM
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.
Thanks, this is fine and my nitpicks can be follwups
changeID, err = x.client.HoldRefreshesMany(names, &opts) | ||
} | ||
|
||
if err != nil { |
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.
(super)nitpick. I would remove the newline so that the err check is as close as possible to the branches that generate the errors.
names := installedSnapNames(x.Positional.Snaps) | ||
var changeID string | ||
opts.HoldLevel = "general" | ||
if len(names) == 0 { |
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.
(nitpick^3) I wonder if this would looks nicer as a switch ?
if inst.Time == "" { | ||
return errors.New("hold action requires a non-empty time value") | ||
} else if inst.Time != "forever" { | ||
_, err := time.Parse(time.RFC3339, inst.Time) |
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.
(nitpick) this could be a sinfle line: if _, err := time...; err != nil {
Looking at the spread tests I see one issue that looks related to this PR:
|
it seems the auto-refresh for which we check above is still in progress, is the grep check wrong? or do we have a very unexpected race? |
A missing ! was preventing the test from failing if the auto-refresh for test-snapd-tools_instance wasn't completed by the end of retry. This commit also adds another check to ensure that the other snap isn't auto-refreshed. Since this bug was discovered because the auto-refresh was still ongoing after the retry, it's possible that even with the fix more retries are necessary so I doubled the number. Signed-off-by: Miguel Pires <miguel.pires@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.
Thank you!
snap refresh --hold/--unhold
commands to thesnap
tool