Skip to content

Commit dccd073

Browse files
author
Kubernetes Submit Queue
authored
Merge pull request kubernetes#39495 from apprenda/kubeadm_89-remove_preflight_stutter
Automatic merge from submit-queue (batch tested with PRs 39495, 39547) kubeadm: updated preflight types to avoid stutter Small change to kubeadm preflight pkg to remove stutter from preflight types PreFlightError and PreFlightCheck (now names Error and Checker). **Release note**: `NONE`
2 parents 1fbb22e + 8f0f09c commit dccd073

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
lines changed

cmd/kubeadm/app/preflight/checks.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,17 @@ import (
3737

3838
const bridgenf string = "/proc/sys/net/bridge/bridge-nf-call-iptables"
3939

40-
type PreFlightError struct {
40+
type Error struct {
4141
Msg string
4242
}
4343

44-
func (e *PreFlightError) Error() string {
44+
func (e *Error) Error() string {
4545
return fmt.Sprintf("[preflight] Some fatal errors occurred:\n%s%s", e.Msg, "[preflight] If you know what you are doing, you can skip pre-flight checks with `--skip-preflight-checks`")
4646
}
4747

48-
// PreFlightCheck validates the state of the system to ensure kubeadm will be
48+
// Checker validates the state of the system to ensure kubeadm will be
4949
// successful as often as possilble.
50-
type PreFlightCheck interface {
50+
type Checker interface {
5151
Check() (warnings, errors []error)
5252
}
5353

@@ -304,7 +304,7 @@ func (sysver SystemVerificationCheck) Check() (warnings, errors []error) {
304304
}
305305

306306
func RunInitMasterChecks(cfg *kubeadmapi.MasterConfiguration) error {
307-
checks := []PreFlightCheck{
307+
checks := []Checker{
308308
SystemVerificationCheck{},
309309
IsRootCheck{},
310310
HostnameCheck{},
@@ -346,7 +346,7 @@ func RunInitMasterChecks(cfg *kubeadmapi.MasterConfiguration) error {
346346
}
347347

348348
func RunJoinNodeChecks(cfg *kubeadmapi.NodeConfiguration) error {
349-
checks := []PreFlightCheck{
349+
checks := []Checker{
350350
SystemVerificationCheck{},
351351
IsRootCheck{},
352352
HostnameCheck{},
@@ -372,7 +372,7 @@ func RunJoinNodeChecks(cfg *kubeadmapi.NodeConfiguration) error {
372372
}
373373

374374
func RunRootCheckOnly() error {
375-
checks := []PreFlightCheck{
375+
checks := []Checker{
376376
IsRootCheck{},
377377
}
378378

@@ -381,7 +381,7 @@ func RunRootCheckOnly() error {
381381

382382
// RunChecks runs each check, displays it's warnings/errors, and once all
383383
// are processed will exit if any errors occurred.
384-
func RunChecks(checks []PreFlightCheck, ww io.Writer) error {
384+
func RunChecks(checks []Checker, ww io.Writer) error {
385385
found := []error{}
386386
for _, c := range checks {
387387
warnings, errs := c.Check()
@@ -395,7 +395,7 @@ func RunChecks(checks []PreFlightCheck, ww io.Writer) error {
395395
for _, i := range found {
396396
errs.WriteString("\t" + i.Error() + "\n")
397397
}
398-
return &PreFlightError{Msg: errs.String()}
398+
return &Error{Msg: errs.String()}
399399
}
400400
return nil
401401
}

cmd/kubeadm/app/preflight/checks_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ func (pfct preflightCheckTest) Check() (warning, errors []error) {
3838

3939
func TestRunChecks(t *testing.T) {
4040
var tokenTest = []struct {
41-
p []PreFlightCheck
41+
p []Checker
4242
expected bool
4343
output string
4444
}{
45-
{[]PreFlightCheck{}, true, ""},
46-
{[]PreFlightCheck{preflightCheckTest{"warning"}}, true, "[preflight] WARNING: warning\n"}, // should just print warning
47-
{[]PreFlightCheck{preflightCheckTest{"error"}}, false, ""},
48-
{[]PreFlightCheck{preflightCheckTest{"test"}}, false, ""},
45+
{[]Checker{}, true, ""},
46+
{[]Checker{preflightCheckTest{"warning"}}, true, "[preflight] WARNING: warning\n"}, // should just print warning
47+
{[]Checker{preflightCheckTest{"error"}}, false, ""},
48+
{[]Checker{preflightCheckTest{"test"}}, false, ""},
4949
}
5050
for _, rt := range tokenTest {
5151
buf := new(bytes.Buffer)

cmd/kubeadm/app/util/error.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func checkErr(prefix string, err error, handleErr func(string, int)) {
6161
switch err.(type) {
6262
case nil:
6363
return
64-
case *preflight.PreFlightError:
64+
case *preflight.Error:
6565
handleErr(err.Error(), PreFlightExitCode)
6666
default:
6767
handleErr(err.Error(), DefaultErrorExitCode)

cmd/kubeadm/app/util/error_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func TestCheckErr(t *testing.T) {
3535
}{
3636
{nil, 0},
3737
{fmt.Errorf(""), DefaultErrorExitCode},
38-
{&preflight.PreFlightError{}, PreFlightExitCode},
38+
{&preflight.Error{}, PreFlightExitCode},
3939
}
4040

4141
for _, rt := range tokenTest {

0 commit comments

Comments
 (0)