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

{device,snap}state: skip kernel extraction in seeding #10595

Merged
merged 4 commits into from
Aug 9, 2021

Conversation

mvo5
Copy link
Contributor

@mvo5 mvo5 commented Aug 6, 2021

When seeding the device we currently extract the kernel. This is
unneeded because the kernel is already in place (without it the
system would not have been booted). Either ubuntu-image or "install"
mode extracted the kernel into the right place already.

This commit changes the code to skip kernel extraction when seeding.

This is an alternative and kind of complementary way to #10594. We
probably want to make the low-level bits also a bit more robust but this
high level approach is hopefully simpler.

When seeding the device we currently extract the kernel. This is
unneeded because the kernel is already in place (without it the
system would not have been booted). Either ubuntu-image or "install"
mode extracted the kernel into the right place already.

This commit changes the code to skip kernel extraction when seeding.
@mvo5 mvo5 added the Run nested The PR also runs tests inluded in nested suite label Aug 6, 2021
@mvo5 mvo5 requested a review from pedronis August 6, 2021 14:27
@@ -243,6 +243,15 @@ func populateStateFromSeedImpl(st *state.State, opts *populateStateFromSeedOptio
// wait for the previous configTss
configTss = chainTs(configTss, configTs)
}
// XXX: put this into "snapstate.Flags" instead?
Copy link
Collaborator

Choose a reason for hiding this comment

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

yes, it should be a Flag like SkipConfigure

@mvo5 mvo5 added the Squash-merge Please squash this PR when merging. label Aug 9, 2021
@mvo5 mvo5 force-pushed the no-kernel-double-extract-managers branch 2 times, most recently from 9bc3790 to 60c5324 Compare August 9, 2021 07:22
@mvo5 mvo5 force-pushed the no-kernel-double-extract-managers branch from 60c5324 to 2cd5f73 Compare August 9, 2021 07:23
@mvo5 mvo5 added this to the 2.51 milestone Aug 9, 2021
@mvo5 mvo5 requested a review from anonymouse64 August 9, 2021 10:06
@mvo5 mvo5 added the ⚠ Critical High-priority stuff (e.g. to fix master) label Aug 9, 2021
@mvo5
Copy link
Contributor Author

mvo5 commented Aug 9, 2021

I got a verbal okay from Samuele for the general idea and the implementation using snapstate.Flags so just a "normal" review is now required for the landing. I would like to include this in 2.51 but opinions are welcome.

It should be safe but we should make sure this is tested on a freshly generated pi image with UC18. Spread will only test this on UC20 because on UC18 nothing in the kernel gets extracted for the architectures that spread uses.

Copy link
Member

@anonymouse64 anonymouse64 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 as noted we should confirm that the stars are aligned for this working as expected on uc18 on a pi

Copy link
Contributor

@MiguelPires MiguelPires left a comment

Choose a reason for hiding this comment

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

LGTM, just one small naming nitpick

@@ -39,8 +39,16 @@ type InstallRecord struct {
TargetSnapExisted bool `json:"target-snap-existed,omitempty"`
}

type SetupSnapOpts struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

super small nitpick: I think most options I've seen in the code end with "Options" instead of "Opts" so that would be a more consistent alternative

return snapType, nil, fmt.Errorf("cannot install kernel: %s", err)
if !setupOpts.SkipKernelExtraction {
if err := boot.Kernel(s, t, dev).ExtractKernelAssets(snapf); err != nil {
return snapType, nil, fmt.Errorf("cannot install kernel: %s", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

I didn't check if err can be of some type which we might want to distinguish but using the %w verb would make fmt.Errorf return an error that wraps err. Probably not be useful here at all, just thought to mention it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for raising this. I won't change it here because the existing code is written in this way but it's a good point. We are underusing %w a bit - partly for historic reasons because until recently we were stuck in the go-1.9 stone age :) Fortunately this has changed now!

Copy link
Member

Choose a reason for hiding this comment

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

yeah we should probably have a separate PR which goes through and changes everything over to use %w, we have numerous places around the codebase that could benefit from using %w but never could use it previously.

We also have other cruft too like ctrl17.go and ctrl16.go which should be updated/removed too now that we are on a more modern Go version

Copy link
Contributor

@mardy mardy left a comment

Choose a reason for hiding this comment

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

Code-wise LGTM; I'm not entitled to judge the high-level picture :-)

@mvo5 mvo5 merged commit 990afb7 into snapcore:master Aug 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cherry-picked ⚠ Critical High-priority stuff (e.g. to fix master) Run nested The PR also runs tests inluded in nested suite Squash-merge Please squash this PR when merging.
Projects
None yet
5 participants