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

store: add Store.SnapAction to support the new install/refresh api endpoint #4771

Closed
wants to merge 12 commits into from

Conversation

pedronis
Copy link
Collaborator

@pedronis pedronis commented Feb 28, 2018

This is quite large, most of it is additions to store_test.go to cover the new code.

See pedronis@f3914cd for a preview of how it's going to be used.

Support for macaroon refreshes will be in its own follow up PR. It needs to be there when we start using this though.

@pedronis
Copy link
Collaborator Author

based on #4770

@codecov-io
Copy link

codecov-io commented Mar 5, 2018

Codecov Report

Merging #4771 into master will increase coverage by 0.01%.
The diff coverage is 88.3%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4771      +/-   ##
==========================================
+ Coverage   78.97%   78.98%   +0.01%     
==========================================
  Files         477      478       +1     
  Lines       34763    35045     +282     
==========================================
+ Hits        27455    27682     +227     
- Misses       5120     5163      +43     
- Partials     2188     2200      +12
Impacted Files Coverage Δ
store/errors.go 61.36% <100%> (+61.36%) ⬆️
store/store.go 81.32% <86.11%> (+0.53%) ⬆️
snap/info.go 78.67% <0%> (-6.65%) ⬇️
interfaces/apparmor/spec.go 86.78% <0%> (-2.7%) ⬇️
cmd/snap/cmd_run.go 67.64% <0%> (ø) ⬆️
interfaces/ifacetest/backendtest.go 0% <0%> (ø) ⬆️
interfaces/builtin/modem_manager.go 60% <0%> (ø) ⬆️
overlord/snapstate/snapstate.go 81.53% <0%> (ø) ⬆️
httputil/redirect18.go 100% <0%> (ø)
snap/info_snap_yaml.go 93.18% <0%> (+0.02%) ⬆️
... and 4 more

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 482f8cb...fb767a0. Read the comment docs.

store/store.go Outdated
// installed snaps in installedCtxt. If the request was overall
// successul (200) but there were reported errors it will return both
// the snap infos and an InstallRefreshError.
func (s *Store) InstallRefresh(installedCtxt []*CurrentSnap, actions []*InstallRefreshAction, user *auth.UserState, opts *RefreshOptions) ([]*snap.Info, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

any reason not to give this a context.Context, to make it cancelable?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this is done, it was necessary also to integrate with other current work

@pedronis pedronis added this to the 2.33 milestone Mar 15, 2018
@pedronis pedronis added ⚠ Critical High-priority stuff (e.g. to fix master) Reviewed labels Mar 27, 2018
@pedronis pedronis removed the Reviewed label Mar 28, 2018
@pedronis pedronis changed the title store: add Store.InstallRefresh to support the new install/refresh api endpoint store: add Store.SnapAction to support the new install/refresh api endpoint Mar 28, 2018
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 with some additional suggestions:

store/store.go Outdated

const (
apiV1 apiLevel = 0
apiV2 apiLevel = 1
Copy link
Contributor

Choose a reason for hiding this comment

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

That's quite misleading. Why is that not V0 and V1 respectively, or V1 = 1 and V2 = 2?

store/store.go Outdated
Fields []string `json:"fields"`
}

type snapActionResp struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

Resp vs. Result isn't clear. They both mean the same thing. Would ResultList be correct here?

store/errors.go Outdated
if len(e.Other) > 0 {
es = append(es, "other install/refresh errors:")
for _, e := range e.Other {
es = append(es, fmt.Sprintf(" - %v", e))
Copy link
Contributor

Choose a reason for hiding this comment

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

The format here feels a bit verbose and perhaps unfriendly to read.

Perhaps we can separate this in two cases: if there is only one error, whatever it is, let's spell it out. For example:

cannot refresh snap %q: %v"

This will probably be the most common case, so it's nice to make it very friendly.

Then, if there are more problems, we can generalize the message:

cannot refresh snaps:
snap %q: %s
snap %q: %s
snap %q: %s

No need for the initial "-". The first word is already the leading sign.

The first sentence would change according to the errors, but it would be a single message. One of these:

  • cannot install snaps:
  • cannot refresh snaps:
  • cannot install or refresh snaps:

pedronis added a commit that referenced this pull request Mar 28, 2018
@pedronis
Copy link
Collaborator Author

squashed merged the next bit instead to reduce the number of PRs that we will need to backport

@pedronis pedronis closed this Mar 28, 2018
@pedronis pedronis deleted the store-install-refresh branch March 28, 2018 21:23
pedronis added a commit to pedronis/snappy that referenced this pull request Mar 29, 2018
mvo5 pushed a commit to mvo5/snappy that referenced this pull request Apr 3, 2018
pedronis added a commit to pedronis/snappy that referenced this pull request Apr 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⚠ Critical High-priority stuff (e.g. to fix master)
Projects
None yet
4 participants