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

rpk: change required kernel version in rpk redpanda check + change log levels to rpk checker message. #11502

Merged
merged 3 commits into from
Jun 16, 2023
Merged
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
6 changes: 3 additions & 3 deletions src/go/rpk/pkg/cli/redpanda/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -700,12 +700,12 @@ func check(
if action, exists := checkFailedActions[result.CheckerID]; exists {
action(&result)
}
msg := fmt.Sprintf("System check '%s' failed. Required: %v, Current %v, Error: %v",
result.Desc, result.Required, result.Current, result.Err)
msg := fmt.Sprintf("System check '%s' failed. Required: %v, Current %v, Error: %v, Severity: %v",
result.Desc, result.Required, result.Current, result.Err, result.Severity)
if result.Severity == tuners.Fatal {
return errors.New(msg)
}
fmt.Println(msg)
zap.L().Sugar().Warn(msg)
}
}
return nil
Expand Down
1 change: 1 addition & 0 deletions src/go/rpk/pkg/config/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -1000,6 +1000,7 @@ func (p *Params) readRedpandaConfig(fs afero.Fs, c *Config) error {
if errors.Is(err, afero.ErrFileNotFound) {
continue
}
return fmt.Errorf("unable to read file in %v: %v", path, err)
}

if err := yaml.Unmarshal(file, &c.redpandaYaml); err != nil {
Expand Down
6 changes: 3 additions & 3 deletions src/go/rpk/pkg/tuners/kernel_version.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ package tuners
import "fmt"

const (
ExpectedKernelVersion string = "4.19"
ExpectedKernelVersion string = "3.19"
)

func NewKernelVersionChecker(
Expand All @@ -38,7 +38,7 @@ func (kernelVersionChecker) GetSeverity() Severity {
}

func (kernelVersionChecker) GetRequiredAsString() string {
return "4.19"
return ExpectedKernelVersion
}

func (c kernelVersionChecker) Check() *CheckResult {
Expand All @@ -63,7 +63,7 @@ func (c kernelVersionChecker) Check() *CheckResult {
return res
}

if major < 4 || major == 4 && minor < 19 {
if major < 3 || major == 3 && minor < 19 {
res.Err = fmt.Errorf("%s", "kernel version is too old")
return res
}
Expand Down
34 changes: 17 additions & 17 deletions src/go/rpk/pkg/tuners/kernel_version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,28 +30,28 @@ func Test_kernelVersionChecker_Check(t *testing.T) {
name: "Shall return valid result when condition is met",
check: func(c int) bool { return c == 26 },
renderRequired: func() string { return "0" },
getCurrent: func() (string, error) { return "4.19.0", nil },
getCurrent: func() (string, error) { return "3.19.0", nil },
want: &CheckResult{
CheckerID: KernelVersion,
IsOk: true,
Current: "4.19.0",
Current: "3.19.0",
Desc: "Kernel Version",
Severity: Warning,
Required: "4.19",
Required: "3.19",
},
},
{
name: "Shall return valid result when minor is higher",
check: func(c int) bool { return c == 26 },
renderRequired: func() string { return "0" },
getCurrent: func() (string, error) { return "4.20.0", nil },
getCurrent: func() (string, error) { return "3.20.0", nil },
want: &CheckResult{
CheckerID: KernelVersion,
IsOk: true,
Current: "4.20.0",
Current: "3.20.0",
Desc: "Kernel Version",
Severity: Warning,
Required: "4.19",
Required: "3.19",
},
},
{
Expand All @@ -65,51 +65,51 @@ func Test_kernelVersionChecker_Check(t *testing.T) {
Current: "5.1.0",
Desc: "Kernel Version",
Severity: Warning,
Required: "4.19",
Required: "3.19",
},
},
{
name: "Shall return invalid result when minor is lower",
check: func(c int) bool { return c == 26 },
renderRequired: func() string { return "0" },
getCurrent: func() (string, error) { return "4.18.0", nil },
getCurrent: func() (string, error) { return "3.18.0", nil },
want: &CheckResult{
CheckerID: KernelVersion,
IsOk: false,
Current: "4.18.0",
Current: "3.18.0",
Desc: "Kernel Version",
Severity: Warning,
Required: "4.19",
Required: "3.19",
Err: errors.New("kernel version is too old"),
},
},
{
name: "Shall return invalid result when major is lower",
check: func(c int) bool { return c == 26 },
renderRequired: func() string { return "0" },
getCurrent: func() (string, error) { return "3.19.0", nil },
getCurrent: func() (string, error) { return "2.19.0", nil },
want: &CheckResult{
CheckerID: KernelVersion,
IsOk: false,
Current: "3.19.0",
Current: "2.19.0",
Desc: "Kernel Version",
Severity: Warning,
Required: "4.19",
Required: "3.19",
Err: errors.New("kernel version is too old"),
},
},
{
name: "Shall return invalid result when patch is missing",
check: func(c int) bool { return c == 26 },
renderRequired: func() string { return "0" },
getCurrent: func() (string, error) { return "4.19", nil },
getCurrent: func() (string, error) { return "3.19", nil },
want: &CheckResult{
CheckerID: KernelVersion,
IsOk: false,
Current: "4.19",
Current: "3.19",
Desc: "Kernel Version",
Severity: Warning,
Required: "4.19",
Required: "3.19",
Err: errors.New("failed to parse kernel version"),
},
},
Expand All @@ -124,7 +124,7 @@ func Test_kernelVersionChecker_Check(t *testing.T) {
Current: "5.8.0-19-generic",
Desc: "Kernel Version",
Severity: Warning,
Required: "4.19",
Required: "3.19",
},
},
}
Expand Down