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

image: block installation of parallel snap instances #5417

Conversation

bboozzoo
Copy link
Collaborator

Block installation of parallel snap instances either coming from the model
assertion or directly form the command line.

Block installation of parallel snap instances either coming from the model
assertion or directly form the command line.

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
image/image.go Outdated
}

func validateNonLocalSnaps(snaps []string) error {
nonLocalSnaps := make([]string, len(snaps))
Copy link
Collaborator

Choose a reason for hiding this comment

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

This makes an array of len(snaps) empty strings. This is not what you wanted.

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.

Did a first pass.

image/image.go Outdated
for _, snapName := range snaps {
_, instanceKey := snap.SplitInstanceName(snapName)
if instanceKey != "" {
return fmt.Errorf("cannot use snap %q, parallel snap instances are unsupported",
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a slightly unusual line wrapping. Its more common to put snapName into the same line (we don't care about 80char lines etc).

image/image.go Outdated
}

func validateNonLocalSnaps(snaps []string) error {
nonLocalSnaps := make([]string, len(snaps))
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is meant to be nonLocalSnaps := make([]string, 0, len(snaps).

_, err = image.DecodeModelAssertion(&image.Options{
ModelFile: fn,
})
c.Check(err, ErrorMatches, `cannot use snap "foo_instance", parallel snap instances are unsupported`)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we test for kernel,gadget,base here as well? That those are not parallel installs?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added

image/image.go Outdated
@@ -183,6 +206,10 @@ func decodeModelAssertion(opts *Options) (*asserts.Model, error) {
}
}

if err := validateNoParallelSnapInstances(modela.RequiredSnaps()); err != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not specific to this PR but why modela and not just model?

image/image.go Outdated
_, instanceKey := snap.SplitInstanceName(snapName)
if instanceKey != "" {
return fmt.Errorf("cannot use snap %q, parallel snap instances are unsupported",
snapName)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nitpick, squeeze that one one line.

image/image.go Outdated
return nil
}

func validateNonLocalSnaps(snaps []string) error {
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 add a comment to this function. I also find it a bit annoying to read since the words together make it harder to distinguish Non from No.

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

codecov-io commented Jun 27, 2018

Codecov Report

Merging #5417 into master will increase coverage by 0.1%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master    #5417     +/-   ##
=========================================
+ Coverage   79.05%   79.16%   +0.1%     
=========================================
  Files         504      504             
  Lines       38081    38326    +245     
=========================================
+ Hits        30106    30340    +234     
- Misses       5551     5555      +4     
- Partials     2424     2431      +7
Impacted Files Coverage Δ
image/image.go 72.6% <100%> (+2.52%) ⬆️
i18n/xgettext-go/main.go 87.8% <0%> (-0.95%) ⬇️
asserts/account.go 100% <0%> (ø) ⬆️
interfaces/builtin/udisks2.go 100% <0%> (ø) ⬆️
overlord/hookstate/ctlcmd/ctlcmd.go 94.23% <0%> (+0.29%) ⬆️
daemon/api.go 76.45% <0%> (+0.46%) ⬆️
overlord/ifacestate/helpers.go 68.35% <0%> (+1.68%) ⬆️
overlord/ifacestate/handlers.go 69.83% <0%> (+4.27%) ⬆️

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 c525b0f...d53f8b9. Read the comment docs.

@bboozzoo bboozzoo merged commit c3dd5d6 into snapcore:master Jun 28, 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