Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions cmd/check-host-config/check/kernel.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,19 @@
log.Printf("Kernel name check passed: %s is installed\n", expected.Name)
}

if expected.Version != "" {

Check failure on line 37 in cmd/check-host-config/check/kernel.go

View workflow job for this annotation

GitHub Actions / ⌨ Lint

expected.Version undefined (type *blueprint.KernelCustomization has no field or method Version)
stdout, _, _, err := ExecString("rpm", "-q", "--queryformat", "%{VERSION}-%{RELEASE}", expected.Name)
if err != nil {
return Fail("failed to query kernel version:", err)
}

if !strings.HasPrefix(stdout, expected.Version) {

Check failure on line 43 in cmd/check-host-config/check/kernel.go

View workflow job for this annotation

GitHub Actions / ⌨ Lint

expected.Version undefined (type *blueprint.KernelCustomization has no field or method Version)
return Fail("kernel version mismatch: expected", expected.Version, "got", stdout)

Check failure on line 44 in cmd/check-host-config/check/kernel.go

View workflow job for this annotation

GitHub Actions / ⌨ Lint

expected.Version undefined (type *blueprint.KernelCustomization has no field or method Version)
}

log.Printf("Kernel version check passed: %s matches %s\n", stdout, expected.Version)

Check failure on line 47 in cmd/check-host-config/check/kernel.go

View workflow job for this annotation

GitHub Actions / ⌨ Lint

expected.Version undefined (type *blueprint.KernelCustomization has no field or method Version) (typecheck)
}
Comment on lines +37 to +48

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thinking about how to test this:
We could have a test config with a custom repo pointing to an older snapshot with an older kernel and pin it in the config. We could do it with an older distro version, something with long term support (RHEL 9.6 probably), so we don't need to change it any time soon.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yea this sounds like something that should work. I was going to initially maybe not provide a test config for this yet on the other hand if it's straightforward to test maybe we should.


if len(expected.Append) > 0 {
cmdline, err := ReadFile("/proc/cmdline")
if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions pkg/distro/generic/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@
// an argument as fallback or make it not return the standard "kernel"
// when it's unset.
osc.KernelName = c.GetKernel().Name
osc.KernelVersion = c.GetKernel().Version

Check failure on line 56 in pkg/distro/generic/images.go

View workflow job for this annotation

GitHub Actions / 🔍 Check source preparation and test configs

c.GetKernel().Version undefined (type *blueprint.KernelCustomization has no field or method Version)

Check failure on line 56 in pkg/distro/generic/images.go

View workflow job for this annotation

GitHub Actions / Validate manifest checksums

c.GetKernel().Version undefined (type *blueprint.KernelCustomization has no field or method Version)
if imageConfig.DefaultKernelName != nil {
osc.KernelName = *imageConfig.DefaultKernelName
osc.KernelVersion = ""
}
osc.KernelOptionsAppend = kernelOptions(t, c)
if imageConfig.KernelOptionsBootloader != nil {
Expand Down
12 changes: 10 additions & 2 deletions pkg/manifest/os.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ type OSCustomizations struct {
// package.
KernelName string

// KernelVersion optionally pins the kernel to a specific version.
// When set, the version is appended to KernelName as a DNF version
// constraint for depsolving (e.g. "kernel-6.12.0-211").
KernelVersion string

// KernelOptionsAppend are appended to the kernel commandline
KernelOptionsAppend []string

Expand Down Expand Up @@ -283,8 +288,11 @@ func (p *OS) getPackageSetChain(Distro) ([]rpmmd.PackageSet, error) {
}

if p.OSCustomizations.KernelName != "" {
// kernel is considered part of the platform package set
platformPackages = append(platformPackages, p.OSCustomizations.KernelName)
kernelSpec := p.OSCustomizations.KernelName
if p.OSCustomizations.KernelVersion != "" {
kernelSpec += "-" + p.OSCustomizations.KernelVersion
}
platformPackages = append(platformPackages, kernelSpec)
}

customizationPackages := make([]string, 0)
Expand Down
Loading