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: on multi-snap refresh make sure bases and core are finished before dependent snaps #5018

Merged
merged 2 commits into from Apr 10, 2018

Conversation

pedronis
Copy link
Collaborator

@pedronis pedronis commented Apr 9, 2018

This makes sure non-base snaps wait for core (source of snapctl etc) and possibly their base if those are being updated in the same multi-snap refresh change, otherwise the current link of core or the base could go away and break running hooks or services of the snap during the snap own refresh process.

The issue is more general than this, but this covers the auto-refresh case for example.

TODO: in general we should raise conflicts between changes where a snap is being operated on in one change, and their base or core is going through unlink-snap or unlink-current-snap in another.

…ly their base if those are being updated in the same change, otherwise the current link of core or the base could go away and break running hooks or services of the snap
@pedronis pedronis added the Squash-merge Please squash this PR when merging. label Apr 9, 2018
@pedronis pedronis added this to the 2.32 milestone Apr 9, 2018
@pedronis pedronis requested a review from mvo5 April 9, 2018 18:25
@codecov-io
Copy link

codecov-io commented Apr 9, 2018

Codecov Report

Merging #5018 into master will increase coverage by 0.02%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #5018      +/-   ##
==========================================
+ Coverage   79.13%   79.16%   +0.02%     
==========================================
  Files         479      479              
  Lines       35541    35569      +28     
==========================================
+ Hits        28127    28157      +30     
+ Misses       5185     5184       -1     
+ Partials     2229     2228       -1
Impacted Files Coverage Δ
overlord/snapstate/snapstate.go 81.86% <100%> (+0.53%) ⬆️
overlord/snapstate/handlers.go 72.02% <0%> (+0.28%) ⬆️

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 e12d873...0c3862c. Read the comment docs.

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.

Thanks for adding this.

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.

LGTM with one comment inline.

@@ -744,6 +745,16 @@ func doUpdate(st *state.State, names []string, updates []*snap.Info, params func
reportUpdated[snapName] = true
}

// first core, bases, then rest
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice, this is a very good way to order snaps by kind.

Copy link
Collaborator

Choose a reason for hiding this comment

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

On second thought, do we need to put gadget ahead of apps here? Also kernel (probably)

Copy link
Collaborator Author

@pedronis pedronis Apr 10, 2018

Choose a reason for hiding this comment

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

not for the current problem, gadget or kernel shouldn't block running hooks in other snaps. Kernel provokes a reboot but that's a different issue.

// first core, bases, then rest
sort.Sort(byKind(updates))
prereqs := make(map[string]*state.TaskSet)
waitPrereq := func(ts *state.TaskSet, prereqName string) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

So waitPrereq is a helper that given snap name, adds the prerequisites of that snap, if any, to the given task set.

@@ -786,6 +797,20 @@ func doUpdate(st *state.State, names []string, updates []*snap.Info, params func
}
ts.JoinLane(st.NewLane())

if update.Type == snap.TypeOS || update.Type == snap.TypeBase {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you please add a comment that this loop iterates over updates ordered by the priority and this makes this newly added code safe, that is, that we always have prerequisites by the time we need to read them.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

that's was the intention of the comments inside the two if sides, but it seems they are not clear enough

@pedronis pedronis merged commit f46cbf8 into snapcore:master Apr 10, 2018
pedronis added a commit to pedronis/snappy that referenced this pull request Apr 10, 2018
…e finished before dependent snaps (snapcore#5018)

This makes sure non-base snaps wait for core (source of snapctl etc) and possibly their base if those are being updated in the same multi-snap refresh change, otherwise the current link of core or the base could go away and break running hooks or services of the snap during the snap own refresh process.

The issue is more general than this, but this covers the auto-refresh case for example.

TODO: in general we should raise conflicts between changes where a snap is being operated on in one change, and their base or core is going through unlink-snap or unlink-current-snap in another.
@pedronis pedronis deleted the on-update-base-needs-to-be-active branch April 12, 2018 09:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Squash-merge Please squash this PR when merging.
Projects
None yet
4 participants