many: make kernel-modules components available on initramfs installation#14810
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #14810 +/- ##
=========================================
Coverage ? 78.24%
=========================================
Files ? 1159
Lines ? 153925
Branches ? 0
=========================================
Hits ? 120443
Misses ? 26068
Partials ? 7414
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
2b388eb to
66cc66b
Compare
|
Tue Jan 28 13:39:30 UTC 2025 Failures:Preparing:
Executing:
Restoring:
|
6bcd667 to
652d0f3
Compare
|
This is ready for review now, the core24 dependency is merged and the others are unnecessary as what they did is done now by snap-bootstrap. |
652d0f3 to
77f8567
Compare
pedronis
left a comment
There was a problem hiding this comment.
couple of code org question/comments
alfonsosanchezbeato
left a comment
There was a problem hiding this comment.
@pedronis thanks, comments addressed now
pedronis
left a comment
There was a problem hiding this comment.
thanks, one small thing
overlord/install/install.go
Outdated
| ) | ||
|
|
||
| // BuildKernelBootInfo constructs a KernelBootInfo. | ||
| func BuildKernelBootInfo(kernInfo *snap.Info, compSeedInfos []CompSeedInfo, kernMntPoint string, mntPtForComps map[string]string, isCore, needsDriversTree bool) KernelBootInfo { |
There was a problem hiding this comment.
nitpick: should the two bools become an Options struct ?
Meulengracht
left a comment
There was a problem hiding this comment.
Overall nice, some comments
| if err != nil { | ||
| return nil, err | ||
| } | ||
| if ci.Revision.Unset() { |
There was a problem hiding this comment.
In what cases are the revision unset? And why does it need to be set to x1?
There was a problem hiding this comment.
When reading from the seed, if the component is unasserted. Note that this is the same that was being done for snaps in readSnapInfo. I've added comments to clarify.
| continue | ||
| } | ||
|
|
||
| // Mount ephemerally the kernel-modules components |
There was a problem hiding this comment.
This comment explains what we are doing here, which is farily obvious from the code, maybe a comment about why they are mounted ephemerally would make more sense
There was a problem hiding this comment.
Good point, added more information
| } | ||
|
|
||
| installedSystem, err := gadgetInstallRun(model, gadgetMountDir, kernelSnapInfo, bootDevice, options, installObserver, timings.New(nil)) | ||
| preseed := false |
There was a problem hiding this comment.
i think this should be defined before preseedSeed, ok := currentSeed.(seed.PreseedCapable) instead, it doesn't need to be defined here
| } | ||
|
|
||
| currentSeed, err := mst.LoadSeed(mst.recoverySystem) | ||
| if preseed { |
There was a problem hiding this comment.
A comment about why different behavior is required for this case would be nice
| } | ||
| } | ||
|
|
||
| // Create drivers tree mount units |
There was a problem hiding this comment.
This comment is not very helpful either - i think a comment about the expected behaviour in this case and how it's consumed would be much more helpful
There was a problem hiding this comment.
tweaked a bit
kernel/kernel_drivers.go
Outdated
| return nil | ||
| } | ||
|
|
||
| // NeedsKernelDriversTree tells if we need a kernel drivers tree for this model. |
There was a problem hiding this comment.
| // NeedsKernelDriversTree tells if we need a kernel drivers tree for this model. | |
| // NeedsKernelDriversTree returns true if we need a kernel drivers tree for this model. |
| ReadOnly: true, | ||
| Private: true, | ||
| Ephemeral: true}); err != nil { | ||
| return err |
There was a problem hiding this comment.
Do we need a test in this error case to ensure the unmounts are called correctly?
There was a problem hiding this comment.
I've added a test now
overlord/install/install.go
Outdated
|
|
||
| // CompSeedInfo contains information for a component from the seed and | ||
| // from its metadata. | ||
| type CompSeedInfo struct { |
There was a problem hiding this comment.
This is a nitpick but for me, when it comes to exported structures that are part of an API it feels more appropriate to spell it out ComponentSeedInfo instead of shorting it, which is what you might do for the variable name.
overlord/install/install.go
Outdated
| CompInfo *snap.ComponentInfo | ||
| CompSeed *seed.Component |
There was a problem hiding this comment.
Would read even nicer when used? Anyway, nitpicks here, feel free to ignore
| CompInfo *snap.ComponentInfo | |
| CompSeed *seed.Component | |
| Info *snap.ComponentInfo | |
| Seed *seed.Component |
overlord/install/install.go
Outdated
| ) | ||
|
|
||
| // BuildKernelBootInfo constructs a KernelBootInfo. | ||
| func BuildKernelBootInfo(kernInfo *snap.Info, compSeedInfos []CompSeedInfo, kernMntPoint string, mntPtForComps map[string]string, isCore, needsDriversTree bool) KernelBootInfo { |
alfonsosanchezbeato
left a comment
There was a problem hiding this comment.
@Meulengracht thanks, I've addressed your comments now
| if err != nil { | ||
| return nil, err | ||
| } | ||
| if ci.Revision.Unset() { |
There was a problem hiding this comment.
When reading from the seed, if the component is unasserted. Note that this is the same that was being done for snaps in readSnapInfo. I've added comments to clarify.
| continue | ||
| } | ||
|
|
||
| // Mount ephemerally the kernel-modules components |
There was a problem hiding this comment.
Good point, added more information
| ReadOnly: true, | ||
| Private: true, | ||
| Ephemeral: true}); err != nil { | ||
| return err |
There was a problem hiding this comment.
I've added a test now
| } | ||
|
|
||
| installedSystem, err := gadgetInstallRun(model, gadgetMountDir, kernelSnapInfo, bootDevice, options, installObserver, timings.New(nil)) | ||
| preseed := false |
| } | ||
|
|
||
| currentSeed, err := mst.LoadSeed(mst.recoverySystem) | ||
| if preseed { |
| } | ||
| } | ||
|
|
||
| // Create drivers tree mount units |
There was a problem hiding this comment.
tweaked a bit
overlord/install/install.go
Outdated
|
|
||
| // CompSeedInfo contains information for a component from the seed and | ||
| // from its metadata. | ||
| type CompSeedInfo struct { |
overlord/install/install.go
Outdated
| CompInfo *snap.ComponentInfo | ||
| CompSeed *seed.Component |
overlord/install/install.go
Outdated
| ) | ||
|
|
||
| // BuildKernelBootInfo constructs a KernelBootInfo. | ||
| func BuildKernelBootInfo(kernInfo *snap.Info, compSeedInfos []CompSeedInfo, kernMntPoint string, mntPtForComps map[string]string, isCore, needsDriversTree bool) KernelBootInfo { |
to install package so it can be used by snap-bootstrap.
on first boot, when installing from the initramfs.
b24de36 to
73ccbf2
Compare
Introduce NESTED_COMP_KERNEL_MODULE_NAME and NESTED_KERNEL_MODULES_COMP env vars. If present, a kernel-modules component containing the specified kernel module will be created and will be added when building the nested test image.
Create the drivers tree mounts when installing UC from the initramfs.
to build the drivers tree.
Run the prepare-kernel-modules-components task when creating the pre-seed tarball. This was not happening as pre-seeding stops the run of snap install tasks right before running hooks, and this task is run after them. To workaround this, add a prepare-kernel-modules-components task that runs before hooks, only for preseeding.
It will be part of the preseed tarball.
73ccbf2 to
ac13f3c
Compare
…nstallation (canonical#14810)" This reverts commit b803966.
Make sure that modules shipped in kernel-modules components are available on early boot when the system is installed from the initramfs. This is a follow-up from #14744.
This requires some changes in core-initrd and in snapd-generator, so I am opening as draft for the moment. In fact the pre-requisites are needed for having a working drivers tree at all on first boot after initramfs driven installation.
Depends on