From fbe5c97d4bd1e093bf20e94d72534cf34cd8eedf Mon Sep 17 00:00:00 2001 From: Rogger Vasquez Date: Fri, 16 Jun 2023 11:23:32 -0500 Subject: [PATCH 1/3] rpk: fix kernel version checker. We were checking if the version was >= 4.19 while redpanda supports >= 3.19. --- src/go/rpk/pkg/tuners/kernel_version.go | 6 ++-- src/go/rpk/pkg/tuners/kernel_version_test.go | 34 ++++++++++---------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/go/rpk/pkg/tuners/kernel_version.go b/src/go/rpk/pkg/tuners/kernel_version.go index 9f35c869238da..847cd629aa150 100644 --- a/src/go/rpk/pkg/tuners/kernel_version.go +++ b/src/go/rpk/pkg/tuners/kernel_version.go @@ -12,7 +12,7 @@ package tuners import "fmt" const ( - ExpectedKernelVersion string = "4.19" + ExpectedKernelVersion string = "3.19" ) func NewKernelVersionChecker( @@ -38,7 +38,7 @@ func (kernelVersionChecker) GetSeverity() Severity { } func (kernelVersionChecker) GetRequiredAsString() string { - return "4.19" + return ExpectedKernelVersion } func (c kernelVersionChecker) Check() *CheckResult { @@ -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 } diff --git a/src/go/rpk/pkg/tuners/kernel_version_test.go b/src/go/rpk/pkg/tuners/kernel_version_test.go index 2f6405f312f86..6f7cfe7016b93 100644 --- a/src/go/rpk/pkg/tuners/kernel_version_test.go +++ b/src/go/rpk/pkg/tuners/kernel_version_test.go @@ -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", }, }, { @@ -65,21 +65,21 @@ 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"), }, }, @@ -87,14 +87,14 @@ func Test_kernelVersionChecker_Check(t *testing.T) { 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"), }, }, @@ -102,14 +102,14 @@ func Test_kernelVersionChecker_Check(t *testing.T) { 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"), }, }, @@ -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", }, }, } From 95f6d813428a17391a6934dbbc53b82ed4d6d1d8 Mon Sep 17 00:00:00 2001 From: Rogger Vasquez Date: Fri, 16 Jun 2023 11:25:36 -0500 Subject: [PATCH 2/3] rpk: fix error handling bug while reading redpanda.yaml If the error was not of the type afero.ErrFileNotFound, then rpk would have processed the file (empty) as if it had been correctly read. --- src/go/rpk/pkg/config/params.go | 1 + 1 file changed, 1 insertion(+) diff --git a/src/go/rpk/pkg/config/params.go b/src/go/rpk/pkg/config/params.go index b35351015b648..5dd254b9511f2 100644 --- a/src/go/rpk/pkg/config/params.go +++ b/src/go/rpk/pkg/config/params.go @@ -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 { From bf2076b66b5afb89e960897cdc896605d7f0c409 Mon Sep 17 00:00:00 2001 From: Rogger Vasquez Date: Fri, 16 Jun 2023 11:31:13 -0500 Subject: [PATCH 3/3] rpk: add severity to checker logs, move to warn level --- src/go/rpk/pkg/cli/redpanda/start.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/go/rpk/pkg/cli/redpanda/start.go b/src/go/rpk/pkg/cli/redpanda/start.go index 9b662a9304b80..dfac0a9894be2 100644 --- a/src/go/rpk/pkg/cli/redpanda/start.go +++ b/src/go/rpk/pkg/cli/redpanda/start.go @@ -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