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

daemon, overlord/snapstate: set instance name when installing from snap file #5670

Merged
merged 12 commits into from Aug 21, 2018

Conversation

bboozzoo
Copy link
Collaborator

The changes enable setting of instance name when installing from snap file by issuing a command snap install --name foo_bar foo.snap. The client part of the change is already in. This PR adds the backend part.

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
…ed for local installs

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
…aded snaps

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
…ieces

Update the test to enable the experimental flag and account for the missing bits
that prevent snap from running at the moment.

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
@codecov-io
Copy link

codecov-io commented Aug 16, 2018

Codecov Report

Merging #5670 into master will decrease coverage by <.01%.
The diff coverage is 85%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #5670      +/-   ##
==========================================
- Coverage   78.95%   78.95%   -0.01%     
==========================================
  Files         522      522              
  Lines       39941    39965      +24     
==========================================
+ Hits        31537    31553      +16     
- Misses       5839     5843       +4     
- Partials     2565     2569       +4
Impacted Files Coverage Δ
overlord/devicestate/firstboot.go 77.9% <100%> (ø) ⬆️
overlord/snapstate/snapstate.go 81.72% <81.81%> (-0.23%) ⬇️
daemon/api.go 77.25% <88.23%> (+0.03%) ⬆️
image/image.go 72.13% <0%> (-0.2%) ⬇️

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 160270e...1f05d0c. Read the comment docs.

Copy link
Contributor

@stolowski stolowski left a comment

Choose a reason for hiding this comment

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

Looks good, thak you! Just really minor stuff

@@ -1477,6 +1477,16 @@ out:
origPath = form.Value["snap-path"][0]
}

var instanceName string

if len(form.Value["name"]) > 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is "name" only reflecting what's been already agreed and implemented in the client code? No super strong opinion on this, but looking at snap-path above, and the semantics of this one, it feels like a slightly more elaborate attribute name would be more appropriate - e.g instance-name?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah the client part is already merged and was introduced in #5426. That's also where name was discussed.

@@ -2335,10 +2335,14 @@ func (s *apiSuite) sideloadCheck(c *check.C, content string, head map[string]str
ensureStateSoonImpl(st)
}

mockedName := "local"
if expectedInstanceName == "" {
expectedInstanceName = mockedName
Copy link
Contributor

Choose a reason for hiding this comment

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

IMHO it's better to explicitely pass "local" to all invocations of sideloadCheck (there are just a few of them) rather than this special-casing. But maybe I missed something, is there a specific reason to do it this way?

c.Assert(rsp.Type, check.Equals, ResponseTypeError)
c.Check(rsp.Result.(*errorResult).Message, check.Equals, `instance name "foo_instance" does not match snap name "bar"`)
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Nice tests.

_, err := snapstate.InstallPath(s.state, si, mockSnap, "some-snap_foo", "", snapstate.Flags{})
c.Assert(err, ErrorMatches, "experimental feature disabled - test it by setting 'experimental.parallel-instances' to true")

// enable layouts
Copy link
Contributor

Choose a reason for hiding this comment

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

Ha, got you! copy-paste ;)

@@ -0,0 +1,43 @@
summary: Checks for parallel installation of sideloaded snaps
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice test!

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
Copy link
Contributor

@stolowski stolowski left a comment

Choose a reason for hiding this comment

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

Thank you!

@bboozzoo bboozzoo merged commit c91ea95 into snapcore:master Aug 21, 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
4 participants