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: discard mount namespace when undoing 1st link snap #6509

Merged
merged 2 commits into from Feb 14, 2019

Conversation

zyga
Copy link
Collaborator

@zyga zyga commented Feb 14, 2019

When a snap is installed for the first time but the installation fails,
e.g. because the install hook fails or because a service fails to start,
the mount namespace would remain behind, possibly messing up subsequent
attempts to install the snap.

When the undo handler for "link-snap" detects that it runs for the 1st
revision is already removes snap cookies, this is the perfect place to
add the logic to discard the mount namespace.

Thanks to Samuele for pointing this out!

Fixes: https://bugs.launchpad.net/snapd/+bug/1815722
Signed-off-by: Zygmunt Krynicki me@zygoon.pl

When a snap is installed for the first time but the installation fails,
e.g. because the install hook fails or because a service fails to start,
the mount namespace would remain behind, possibly messing up subsequent
attempts to install the snap.

When the undo handler for "link-snap" detects that it runs for the 1st
revision is already removes snap cookies, this is the perfect place to
add the logic to discard the mount namespace.

Thanks to Samuele for pointing this out!

Fixes: https://bugs.launchpad.net/snapd/+bug/1815722
Signed-off-by: Zygmunt Krynicki <me@zygoon.pl>
@zyga zyga added this to the 2.37 milestone Feb 14, 2019
err = m.backend.DiscardSnapNamespace(snapsup.InstanceName())
if err != nil {
t.Errorf("cannot discard snap namespace %q, will retry in 3 mins: %s", snapsup.InstanceName(), err)
return &state.Retry{After: 3 * time.Minute}
Copy link
Contributor

@stolowski stolowski Feb 14, 2019

Choose a reason for hiding this comment

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

3 minutes is a lot, is there a reason to wait that long?

Also two questions:

  • shouldn't we bail out if it keeps failing? Unlike Retry in other places where we know a problem (e.g. a conflict) will eventually go away, in this case it might be a persistent issue (until rebooted)?
  • what happens if there is a reboot before we execute undo and the namespace is naturally gone? Will we hit an error here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We also use 3 minutes in the natural case in discard-snap. I don't recall why we wait this long but I didn't want to invent a new time now.

  • This doesn't fail in any way I know of
  • If there's a reboot this gets cleaned up and snap-discard-ns just happily goes ahead

@codecov-io
Copy link

Codecov Report

Merging #6509 into master will decrease coverage by 0.01%.
The diff coverage is 25%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #6509      +/-   ##
==========================================
- Coverage   79.16%   79.15%   -0.02%     
==========================================
  Files         575      575              
  Lines       44518    44522       +4     
==========================================
- Hits        35244    35241       -3     
- Misses       6424     6428       +4     
- Partials     2850     2853       +3
Impacted Files Coverage Δ
overlord/snapstate/handlers.go 71.63% <25%> (-0.17%) ⬇️
overlord/hookstate/hookmgr.go 73.55% <0%> (-0.97%) ⬇️
overlord/ifacestate/handlers.go 64.16% <0%> (-0.22%) ⬇️

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 20e9175...cd36bfc. Read the comment docs.

Copy link
Collaborator

@pedronis pedronis left a comment

Choose a reason for hiding this comment

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

+1

@mvo5 mvo5 merged commit 0672268 into snapcore:master Feb 14, 2019
@zyga zyga deleted the fix/lp-1815722 branch February 17, 2019 09:43
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