Skip to content
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

Merged
merged 109 commits into from May 4, 2017

Conversation

mvo5
Copy link
Contributor

@mvo5 mvo5 commented Apr 26, 2017

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:

$ snap refresh --time
schedule: 00:00-04:59/5:00-10:59/11:00-16:59/17:00-23:59
last: 2017-04-26 07:47:00 +0200 CEST
next: 2017-04-26 16:33:00 +0200 CEST

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.

Copy link
Contributor

@chipaca chipaca left a 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 :-)

@@ -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"),
Copy link
Contributor

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

Copy link
Contributor

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”)

Copy link
Collaborator

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` 

Copy link
Collaborator

@zyga zyga left a 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

@@ -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"),
Copy link
Collaborator

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` 

@@ -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)
Copy link
Collaborator

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?

Copy link
Contributor Author

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!

break
fi
sleep 1
echo "Doing something that triggers ensure"
snap install test-snapd-python-webserver
Copy link
Collaborator

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?

@pedronis pedronis requested a review from niemeyer April 27, 2017 16:06
@@ -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) {
Copy link
Collaborator

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

Copy link
Collaborator

@pedronis pedronis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@pedronis
Copy link
Collaborator

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

@chipaca chipaca merged commit cbd7b51 into snapcore:master May 4, 2017
@robert-ancell
Copy link
Contributor

I just noticed this change, I've put some documentation in https://github.com/snapcore/snapd/wiki/REST-API but a couple of questions:

  • The time formats are inconsistent with the rest of snapd - e.g. they don't match install-date from snap objects.

Only my system:
system-info: 2017-06-14 09:04:00 +1200 NZST
install-date: 2017-02-07T06:49:09+13:00

Could we change them to use the RFC3339 UTC format?

  • What format is the schedule in?

@robert-ancell
Copy link
Contributor

PR for date formats #3528

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants