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
overlord/snapstate: track time of postponed refreshes #6621
Conversation
When a refresh is attempted but for skipped because a particular snap is busy then a time-stamp is recorded under snap state (refresh postponed time). This time-stamp can be used to determine when a refresh is mandatory, even if a snap is busy. This can prevent snaps from running old revisions indefinitely simply because an app is open. The patch adds the time-stamp to SnapState and ensures it is reset on refresh. Somewhat arbitrarily the instant that this is done was picked to be the "link-snap" task. The timer is set and reset regardless of the refresh-app-awareness feature flag because otherwise the state would go out-of-sync with reality and this aspect of the change is not complex. Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
Apparently comparing time using c.Check(t1, Equals, t2) (also DeepEquals) works fine as long as TZ is set. When TZ is unset, like when testing in Travis, the returned value is somehow different (even though both t1 and t2 are supposedly the same time, just marshalled back and forth. Using Time.Equals avoids that at the cost of rather ugly c.Check(t1.Equals(t2), Equals, true) Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@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.
Looks good, thanks for working on this.
When we don't refresh a snap while it is running we postpone or inhibit the refresh for a later date. Internally we store the time-stamp of when that first happened. To avoid confusion using the word inhibited implies time-of-occurrence better than postpone which may imply time-of-next-attempt. Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@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.
+1, but don't land it until you have the PR that uses this approved as well.
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.
Ehm, I meant this other +1.
There's on semantic difference but John has pointed out that storing the zero value of refresh inhibited time will leave plenty of serialized time.Time cruft in the state. By switching to a pointer we can just store nil when the time is not necessary. Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
I will unblock and use this after #6684 lands in a follow-up that starts recording and acting on the time in the soft check. |
I have a use case for this now, merging :) EDIT: I see the remark about the PR that is using this being approved as well, oh well. |
When a refresh is attempted but for skipped because a particular snap is
busy then a time-stamp is recorded under snap state (refresh postponed
time). This time-stamp can be used to determine when a refresh is
mandatory, even if a snap is busy. This can prevent snaps from running
old revisions indefinitely simply because an app is open.
The patch adds the time-stamp to SnapState and ensures it is reset on
refresh. Somewhat arbitrarily the instant that this is done was picked
to be the "link-snap" task.
The timer is set and reset regardless of the refresh-app-awareness
feature flag because otherwise the state would go out-of-sync with
reality and this aspect of the change is not complex.
Signed-off-by: Zygmunt Krynicki zygmunt.krynicki@canonical.com