-
Notifications
You must be signed in to change notification settings - Fork 563
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
devicestate/firstboot: check for missing bases early #7219
Changes from 4 commits
8963b75
22c4c54
6b9b686
05cd909
6983f1f
b60b05e
ca5026c
e335078
9199a9f
262d321
7feb293
4a0d40d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,7 @@ import ( | |
"github.com/snapcore/snapd/asserts/snapasserts" | ||
"github.com/snapcore/snapd/dirs" | ||
"github.com/snapcore/snapd/i18n" | ||
"github.com/snapcore/snapd/image" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we want to import in this direction though There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moved CheckBasesAndProviders to snap package (and renamed). |
||
"github.com/snapcore/snapd/osutil" | ||
"github.com/snapcore/snapd/overlord/assertstate" | ||
"github.com/snapcore/snapd/overlord/devicestate/internal" | ||
|
@@ -127,6 +128,9 @@ func populateStateFromSeedImpl(st *state.State, tm timings.Measurer) ([]*state.T | |
} | ||
alreadySeeded := make(map[string]bool, 3) | ||
|
||
// allSnapInfos are collected for cross-check validation of bases | ||
allSnapInfos := make(map[string]*snap.Info, len(seed.Snaps)) | ||
|
||
tsAll := []*state.TaskSet{} | ||
configTss := []*state.TaskSet{} | ||
|
||
|
@@ -149,6 +153,7 @@ func populateStateFromSeedImpl(st *state.State, tm timings.Measurer) ([]*state.T | |
} | ||
tsAll = append(tsAll, ts) | ||
alreadySeeded[snapName] = true | ||
allSnapInfos[snapName] = info | ||
return info, nil | ||
} | ||
|
||
|
@@ -238,6 +243,14 @@ func populateStateFromSeedImpl(st *state.State, tm timings.Measurer) ([]*state.T | |
} | ||
infos = append(infos, info) | ||
infoToTs[info] = ts | ||
allSnapInfos[info.InstanceName()] = info | ||
} | ||
|
||
// validate that all snaps have bases | ||
errs := image.CheckBasesAndProviders(allSnapInfos) | ||
if errs != nil { | ||
// only report the first error encountered | ||
return nil, errs[0] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if we should do something similar to https://github.com/snapcore/snapd/pull/7219/files#diff-da07f373046a0a24e67b18699dc15a70L845 here, i.e. build an error that contains all the individual issues? Maybe we can make the result from "CheckBaseAndProviders" something like: type MultiErr struct {
Header string
errs []errors
}
func (e MultiErr) Add(errs []error) { ... }
func (e MultiErr) Error() string {
var buf bytes.Buffer
for _, err := range e.errs {
fmt.Fprintf(&buf, "\n- %s", err)
}
return fmt.Sprintf("%s:%s", e.Header, buf.Bytes())
} but looking at it it (after I typed it out) it seems like this should probably a separate PR and get a 👍 from @pedrons first :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right, I was considering this and I'm happy to reconsider. The reason I did it this way is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, I don't think it's worth the complexity in seeding code itself. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I misread the issue, I'm fine either way given this will end up in snap/ code. |
||
} | ||
|
||
// now add/chain the tasksets in the right order, note that we | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would split this out into info.EffectiveBase()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as long as we find at least a couple other places that can use it