Skip to content

Commit

Permalink
kernel should be active long support version 4.19 or later.
Browse files Browse the repository at this point in the history
Signed-off-by: Paco Xu <paco.xu@daocloud.io>
  • Loading branch information
pacoxu committed Aug 6, 2024
1 parent 592c212 commit e6e7785
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 12 deletions.
2 changes: 1 addition & 1 deletion validators/kernel_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func (k *KernelValidator) validateKernelVersion(kSpec KernelSpec) error {
}
}
k.Reporter.Report("KERNEL_VERSION", k.kernelRelease, bad)
return fmt.Errorf("unsupported kernel release: %s", k.kernelRelease)
return fmt.Errorf("kernel release %s is unsupported. %s", k.kernelRelease, kSpec.VersionsNote)
}

// validateKernelConfig validates the kernel configurations.
Expand Down
37 changes: 31 additions & 6 deletions validators/kernel_validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,45 @@ func TestValidateKernelVersion(t *testing.T) {
// they may be different.
// This is fine, because the test mainly tests the kernel version validation logic,
// not the DefaultSysSpec. The DefaultSysSpec should be tested with node e2e.
testRegex := []string{`^3\.[1-9][0-9].*$`, `^([4-9]|[1-9][0-9]+)\.([0-9]+)\.([0-9]+).*$`}
testRegex := []string{`^4\.19.*$`, `^4\.[2-9][0-9].*$`, `^([5-9]|[1-9][0-9]+)\.([0-9]+)\.([0-9]+).*$`}
for _, test := range []struct {
name string
version string
err bool
}{
{
name: "3.19.9-99-test first version regex matches",
name: "3.19.9-99-test no version regex matches",
version: "3.19.9-99-test",
err: false,
err: true,
},
{
name: "4.4.14+ one of version regexes matches",
name: "4.4.14+ no version regex matches",
version: "4.4.14+",
err: true,
},
{
name: "4.7.1 no version regex matches",
version: "4.7.1",
err: true,
},
{
name: "4.17.3 no version regex matches",
version: "4.17.3",
err: true,
},
{
name: "4.19.3-99-test matches",
version: "4.19.3-99-test",
err: false,
},
{
name: "4.20.3+ matches",
version: "4.20.3+",
err: false,
},
{
name: "5.12.3 matches",
version: "5.12.3",
err: false,
},
{
Expand Down Expand Up @@ -79,7 +104,7 @@ func TestValidateKernelVersion(t *testing.T) {
if !test.err {
assert.Nil(t, err, "Expect error not to occur with kernel version %q", test.version)
} else {
assert.NotNil(t, err, "Expect error to occur with kenrel version %q", test.version)
assert.NotNil(t, err, "Expect error to occur with kernel version %q", test.version)
}
})
}
Expand Down Expand Up @@ -189,7 +214,7 @@ func TestValidateCachedKernelConfig(t *testing.T) {
if !test.err {
assert.Nil(t, err, "Expect error not to occur with kernel config %q", test.config)
} else {
assert.NotNil(t, err, "Expect error to occur with kenrel config %q", test.config)
assert.NotNil(t, err, "Expect error to occur with kernel config %q", test.config)
}
})
}
Expand Down
2 changes: 2 additions & 0 deletions validators/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ type KernelConfig struct {
type KernelSpec struct {
// Versions define supported kernel version. It is a group of regexps.
Versions []string `json:"versions,omitempty"`
// VersionsNote provides additional information if Versions do not match.
VersionsNote string `json:"versionsNote,omitempty"`
// Required contains all kernel configurations required to be enabled
// (built in or as module).
Required []KernelConfig `json:"required,omitempty"`
Expand Down
4 changes: 3 additions & 1 deletion validators/types_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ import (
var DefaultSysSpec = SysSpec{
OS: "Linux",
KernelSpec: KernelSpec{
Versions: []string{`^3\.[1-9][0-9].*$`, `^([4-9]|[1-9][0-9]+)\.([0-9]+)\.([0-9]+).*$`}, // Requires 3.10+, or newer
// 4.19 is an active kernel Long Term Support (LTS) release, tracked in https://www.kernel.org/category/releases.html.
Versions: []string{`^4\.19.*$`, `^4\.[2-9][0-9].*$`, `^([5-9]|[1-9][0-9]+)\.([0-9]+)\.([0-9]+).*$`},
VersionsNote: "Recommended LTS version from the 4.x series is 4.19. Any 5.x or 6.x versions are also supported. For cgroups v2 support, the minimal version is 4.15 and the recommended version is 5.8+",
// TODO(random-liu): Add more config
// TODO(random-liu): Add description for each kernel configuration:
Required: []KernelConfig{
Expand Down
9 changes: 5 additions & 4 deletions validators/types_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ import (
var DefaultSysSpec = SysSpec{
OS: "Microsoft Windows Server 2016",
KernelSpec: KernelSpec{
Versions: []string{`10\.0\.1439[3-9]`, `10\.0\.14[4-9][0-9]{2}`, `10\.0\.1[5-9][0-9]{3}`, `10\.0\.[2-9][0-9]{4}`, `10\.[1-9]+\.[0-9]+`}, //requires >= '10.0.14393'
Required: []KernelConfig{},
Optional: []KernelConfig{},
Forbidden: []KernelConfig{},
Versions: []string{`10\.0\.1439[3-9]`, `10\.0\.14[4-9][0-9]{2}`, `10\.0\.1[5-9][0-9]{3}`, `10\.0\.[2-9][0-9]{4}`, `10\.[1-9]+\.[0-9]+`}, //requires >= '10.0.14393'
VersionsNote: "The kernel version should be >= '10.0.14393'",
Required: []KernelConfig{},
Optional: []KernelConfig{},
Forbidden: []KernelConfig{},
},
RuntimeSpec: RuntimeSpec{
DockerSpec: &DockerSpec{
Expand Down

0 comments on commit e6e7785

Please sign in to comment.