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: only show "next" refresh time if its after the hold time #5789

Merged
merged 3 commits into from Oct 26, 2018

Conversation

mvo5
Copy link
Contributor

@mvo5 mvo5 commented Sep 7, 2018

We got a bugreport that the the output of snap refresh --time
is confusing when the "core.refresh.hold" option is used. The
issue here is that "next" may display a time before the hold
time set by the user. The reason is that the internal next
will always be calculated and then when its about to run we
check against the hold time. But this is something internal
so an easy fix to avoid confusion is to simply hide "next"
if its before "hold".

See https://forum.snapcraft.io/t/7230

We got a bugreport that the the output of `snap refresh --time`
is confusing when the "core.refresh.hold" option is used. The
issue here is that "next" may display a time before the hold
time set by the user. The reason is that the internal next
will always be calculated and then when its about to run we
check against the hold time. But this is something internal
so an easy fix to avoid confusion is to simply hide "next"
if its before "hold".

See https://forum.snapcraft.io/t/7230
@pedronis
Copy link
Collaborator

pedronis commented Sep 7, 2018

doing this though we lose information, if the user resets the hold that will be the next time, maybe we should display the next but mark it somehow, as "held next: TIME", or "next: TIME (but held)", or "next: (TIME)" in parenthesis

@mvo5
Copy link
Contributor Author

mvo5 commented Sep 7, 2018

@pedronis Yeah, the fact that next: vanishes completely may be a problem. I'm not sure how much of a problem though. If the user resets the hold time and runs snap refresh --time again the next: time will visible again. OTOH removing it completely might be confusing as well. I pushed your suggestion, its easy enough to revert if we decide something else.

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.

I was sold as soon as I saw the ... (but held) part.

if next.Before(hold) {
fmt.Fprintf(Stdout, "next: %s (but held)\n", x.fmtTime(next))
} else {
fmt.Fprintf(Stdout, "next: %s\n", x.fmtTime(next))
Copy link
Collaborator

Choose a reason for hiding this comment

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

This branch does not seem to be tested.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The next: %s\n output is tested in TestRefreshTimer and TestRefreshLegacyTime (or do you mean something else maybe?).

fmt.Fprintf(Stdout, "next: %s\n", x.fmtTime(t))
// only show "next" if its after "hold" to not confuse users
if !next.IsZero() {
if next.Before(hold) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Before || Equal? Maybe it does not matter as it's running at the ensure loop pace anyway.

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, this is correct. I doubt its a big deal in practise given the precision of time.Time but its correct so I added it.

@codecov-io
Copy link

Codecov Report

Merging #5789 into master will decrease coverage by 0.16%.
The diff coverage is 81.56%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #5789      +/-   ##
==========================================
- Coverage   79.13%   78.96%   -0.17%     
==========================================
  Files         530      538       +8     
  Lines       40412    41941    +1529     
==========================================
+ Hits        31980    33120    +1140     
- Misses       5845     6108     +263     
- Partials     2587     2713     +126
Impacted Files Coverage Δ
cmd/snap/cmd_create_key.go 42.85% <ø> (ø) ⬆️
osutil/mkdirallchown.go 50% <ø> (+3.84%) ⬆️
interfaces/builtin/opengl.go 100% <ø> (ø) ⬆️
interfaces/builtin/avahi_observe.go 100% <ø> (ø) ⬆️
interfaces/builtin/browser_support.go 76.47% <ø> (ø) ⬆️
cmd/snap/cmd_userd.go 66.66% <ø> (ø) ⬆️
cmd/snap/cmd_pack.go 90.9% <ø> (ø) ⬆️
interfaces/builtin/network_control.go 100% <ø> (ø) ⬆️
interfaces/repo.go 96.09% <ø> (ø) ⬆️
interfaces/builtin/account_control.go 84.61% <ø> (ø) ⬆️
... and 178 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1982859...0b300a4. Read the comment docs.

Copy link
Collaborator

@bboozzoo bboozzoo left a comment

Choose a reason for hiding this comment

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

LGTM

@zyga zyga merged commit 0ad0926 into snapcore:master Oct 26, 2018
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