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
snap: add snap refresh --time
option
#3240
snap: add snap refresh --time
option
#3240
Conversation
… next refresh is calculated earlier
…l-refresh-schedule-info
…l-refresh-schedule-info
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.
+1 with a comment :-)
cmd/snap/cmd_snap_op.go
Outdated
@@ -919,6 +941,7 @@ func init() { | |||
waitDescs.also(channelDescs).also(modeDescs).also(map[string]string{ | |||
"revision": i18n.G("Refresh to the given revision"), | |||
"list": i18n.G("Show available snaps for refresh"), | |||
"time": i18n.G("Show auto refresh information"), |
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'd mention here that adding --time
will not perform a refresh
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 see that list
has the same problem of not saying “this will not perform the action”)
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.
10:57 < mvo_> Chipaca: I like your suggestion about the --time help output. how about "Only show refresh time information" or "Only show refresh times information but not
perform any refresh"?
10:59 < zyga> mvo_: maybe `snap refresh --query`
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.
One question for Schedule.String below
cmd/snap/cmd_snap_op.go
Outdated
@@ -919,6 +941,7 @@ func init() { | |||
waitDescs.also(channelDescs).also(modeDescs).also(map[string]string{ | |||
"revision": i18n.G("Refresh to the given revision"), | |||
"list": i18n.G("Show available snaps for refresh"), | |||
"time": i18n.G("Show auto refresh information"), |
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.
10:57 < mvo_> Chipaca: I like your suggestion about the --time help output. how about "Only show refresh time information" or "Only show refresh times information but not
perform any refresh"?
10:59 < zyga> mvo_: maybe `snap refresh --query`
timeutil/schedule.go
Outdated
@@ -62,6 +66,13 @@ type Schedule struct { | |||
Weekday string | |||
} | |||
|
|||
func (sched *Schedule) String() string { | |||
if sched.Weekday == "" { | |||
return fmt.Sprintf("%s:%s", sched.Start, sched.End) |
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.
Is this a typo? The start:end
vs start-end
below?
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.
Yes, thank you very much for spotting this!
tests/main/auto-refresh/task.yaml
Outdated
break | ||
fi | ||
sleep 1 | ||
echo "Doing something that triggers ensure" | ||
snap install test-snapd-python-webserver |
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.
Don't we have snap debug ensure-state-soon
for this?
@@ -450,15 +450,23 @@ func autoRefreshInFlight(st *state.State) bool { | |||
return false | |||
} | |||
|
|||
func lastRefresh(st *state.State) (time.Time, error) { | |||
func (m *SnapManager) LastRefresh() (time.Time, error) { |
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.
they should grow a doc comment I think, that also explains they need to be used with the state lock
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
Personally I think it's fine to expose this on /system-info, and maybe/likely later repeat it on GET of some kind of /refresh(-schedule) endpoint as well, once we need an endpoint to control this as well |
I just noticed this change, I've put some documentation in https://github.com/snapcore/snapd/wiki/REST-API but a couple of questions:
Only my system: Could we change them to use the RFC3339 UTC format?
|
PR for date formats #3528 |
Based on #2833
This branch adds a new
snap refresh --time
option that will display information around the refresh times. This is useful for users to make things more transparent and also useful for debugging.Here is the example output:
One thing I wonder about is if this information should be part of sysinfo or if we should create a dedicated endpoint. The branch is currently using sysinfo, but it seems a dedicated endpoint might be needed anyway when we implement something like
snap refresh --delay 2h
. Opinions welcome.