-
Notifications
You must be signed in to change notification settings - Fork 576
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
o/snapstate: handle refreshing a snap that only has component revision changes #14486
o/snapstate: handle refreshing a snap that only has component revision changes #14486
Conversation
…that are used with store actions
…-component-during-refresh
@@ -561,12 +565,6 @@ func (m *SnapManager) doUnlinkComponent(t *state.Task, _ *tomb.Tomb) (err error) | |||
return err | |||
} | |||
|
|||
// TODO:COMPS: test taking this branch when unlinking components during a | |||
// refresh where we lose components | |||
if err := saveCurrentKernelModuleComponents(t, snapSup, snapSt); err != nil { |
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.
This was in the wrong place. We now do this in these 3 places:
link-component
unlink-current-component
link-snap
Previously we had it in unlink-component
, rather than unlink-current-component
. unlink-component
isn't run during a snap refresh, that is only run when we are explicitly removing a snap (with its components)
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.
are we sure we do not need to save the kernel-modules components here too? For instance, if we are removing one of these components, to get the state restored on rollback. I'm not sure if in that case we do an unlink current component.
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.
In that case we use "unlink-current-component", since we don't support removing components for anything but the current snap revision.
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.
5befa9a
to
0c1194a
Compare
0c1194a
to
188128b
Compare
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.
thanks, some comments also I'm not sure I fully understand the change in handlers.go
overlord/snapstate/component.go
Outdated
compSetupTaskID string | ||
beforeLink []*state.Task | ||
linkTask *state.Task | ||
postOpHookToDiscard []*state.Task |
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.
what does ToDiscard means here?
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.
The range of the tasks, [post-refresh/install hook -> discard). I'm happy to take suggestions on naming there.
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.
maybe all *state.Task field should have a name ending in "Task", and all the []*state.Task ones, one ending in "Tasks" ?
overlord/snapstate/snapstate.go
Outdated
@@ -1881,12 +1885,32 @@ type update struct { | |||
// revision of the snap. |
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.
it seems the doc comment for this needs changes, also I wonder if turning this around and calling it revisionDiverged wouldn't be clear?
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 personally think that "satisfied" works better here as a method on update
, since it reads as the update has already been satisfied. Using diverged implies something different to me, almost as if something has unexpectedly changed.
overlord/snapstate/handlers.go
Outdated
@@ -2714,7 +2714,7 @@ func (m *SnapManager) undoLinkSnap(t *state.Task, _ *tomb.Tomb) error { | |||
return err | |||
} | |||
|
|||
if len(snapst.Sequence.Revisions) == 1 { | |||
if oldCurrent.Unset() { |
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.
this mean doing this only on firstInstall ? maybe is a good idea to call the name the predicate like that and use the var? I'm not entirely sure I understand the need for this change
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.
During a refresh where we only refresh components, we treat it a lot like snap refresh --revision=n snapname
, where n
is the current revision of the snap. In that case, this undo handler wouldn't do the right thing. We don't want to treat it as if the snap is completely removed, since it isn't.
Naming the predicate to firstInstall
is a good idea, I'll do that.
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.
Added tests for this case here: 541066d
…esh-only-components
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.
thanks, I answered about the naming question
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.
Thanks, I have a couple of questions
overlord/snapstate/component.go
Outdated
compSetupTaskID string | ||
beforeLinkTasks []*state.Task | ||
linkTask *state.Task | ||
postOpHookToDiscardTasks []*state.Task |
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.
nitpick²: maybe postLinkHookToDiscardTasks
now that you are changing names? The "Op" is not saying too much I think.
@@ -561,12 +565,6 @@ func (m *SnapManager) doUnlinkComponent(t *state.Task, _ *tomb.Tomb) (err error) | |||
return err | |||
} | |||
|
|||
// TODO:COMPS: test taking this branch when unlinking components during a | |||
// refresh where we lose components | |||
if err := saveCurrentKernelModuleComponents(t, snapSup, snapSt); err != nil { |
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.
are we sure we do not need to save the kernel-modules components here too? For instance, if we are removing one of these components, to get the state restored on rollback. I'm not sure if in that case we do an unlink current component.
06d7322
to
9254023
Compare
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, thanks!
…esh-only-components
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #14486 +/- ##
=======================================
Coverage 78.83% 78.83%
=======================================
Files 1078 1078
Lines 145031 145096 +65
=======================================
+ Hits 114332 114393 +61
- Misses 23540 23543 +3
- Partials 7159 7160 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
This handles the case where we go to refresh a snap and see that only components have been refreshed, rather than just the snap.