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 @@ func kernelCheck(meta *Metadata, config *buildconfig.BuildConfig) error {
log.Printf("Kernel name check passed: %s is installed\n", expected.Name)
}

if expected.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) {
return Fail("kernel version mismatch: expected", expected.Version, "got", stdout)
}

log.Printf("Kernel version check passed: %s matches %s\n", stdout, expected.Version)
}
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: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ require (
github.com/opencontainers/go-digest v1.0.0
github.com/opencontainers/image-spec v1.1.1
github.com/oracle/oci-go-sdk/v54 v54.0.0
github.com/osbuild/blueprint v1.32.0
github.com/osbuild/blueprint v1.33.0
github.com/spf13/cobra v1.10.2
github.com/spf13/pflag v1.0.10
github.com/stretchr/testify v1.11.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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 @@ func osCustomizations(t *imageType, osPackageSet rpmmd.PackageSet, options distr
// 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
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