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

overlord/snapstate: track time of postponed refreshes #6621

Merged
merged 5 commits into from Apr 9, 2019

Conversation

zyga
Copy link
Collaborator

@zyga zyga commented Mar 19, 2019

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

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>
@zyga zyga requested review from pedronis and chipaca March 19, 2019 13:34
@zyga zyga added this to In progress in Refresh App Awareness via automation Mar 19, 2019
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>
Copy link
Contributor

@mvo5 mvo5 left a 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.

overlord/snapstate/snapmgr.go Outdated Show resolved Hide resolved
overlord/snapstate/snapmgr.go Outdated Show resolved Hide resolved
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>
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, but don't land it until you have the PR that uses this approved as well.

overlord/snapstate/snapmgr.go Outdated Show resolved Hide resolved
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.

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

zyga commented Apr 3, 2019

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.

@zyga
Copy link
Collaborator Author

zyga commented Apr 4, 2019

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.
EDIT: The follow up that uses this is in #6690

@zyga zyga merged commit 20eeb72 into snapcore:master Apr 9, 2019
Refresh App Awareness automation moved this from In progress to Done Apr 9, 2019
@zyga zyga deleted the feature/per-snap-refresh-skip-time branch April 9, 2019 11:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
4 participants