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

cmd/snapctl: allow snapctl -h without a context (regression fix). #3907

Merged
merged 1 commit into from
Sep 12, 2017

Conversation

stolowski
Copy link
Contributor

Fix a subtle regression introduced with ephemeral contexts: snapctl -h wouldn't work anymore outside of hooks. Also fix the broken test that checks that.

@codecov-io
Copy link

codecov-io commented Sep 12, 2017

Codecov Report

Merging #3907 into master will increase coverage by <.01%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3907      +/-   ##
==========================================
+ Coverage   75.91%   75.91%   +<.01%     
==========================================
  Files         416      416              
  Lines       35972    35969       -3     
==========================================
- Hits        27308    27306       -2     
+ Misses       6747     6746       -1     
  Partials     1917     1917
Impacted Files Coverage Δ
daemon/api.go 72.56% <0%> (+0.11%) ⬆️
overlord/ifacestate/helpers.go 62.33% <0%> (-0.67%) ⬇️

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 aebdc91...0061abf. Read the comment docs.

Copy link
Contributor

@niemeyer niemeyer left a comment

Choose a reason for hiding this comment

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

LGTM, but let's please double check the following:

}
// Ignore missing context error to allow 'snapctl -h' without a context;
// Actual context is validated later by get/set.
context, _ := c.d.overlord.HookManager().Context(snapctlOptions.ContextID)
stdout, stderr, err := ctlcmd.Run(context, snapctlOptions.Args)
Copy link
Contributor

Choose a reason for hiding this comment

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

This line would never get a nil context, but now it can. Are we sure it won't crash (panic) if the context is actually used (say, "snapctl get" out of hooks, rather than -h).

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, it's fine, we check for nils early in get/set and we have unit tests for nil context for both get and set.

@mvo5 mvo5 added this to the 2.28 milestone Sep 12, 2017
@@ -11,6 +11,7 @@ execute: |
echo "Verify that snapctl -h runs without a context"
if ! snapctl -h; then
echo "Expected snapctl -h to be successful"
exit 1
Copy link
Contributor

Choose a reason for hiding this comment

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

🤦‍♂️ I thought we had a test for it! Don't run a git blame.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I won't, it stays between us ;)

@mvo5 mvo5 merged commit 4f8cd12 into canonical:master Sep 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants