From d8c94a6ad6c780e9adf99f92f7044dc2b4ff25d9 Mon Sep 17 00:00:00 2001 From: Steven Powell Date: Wed, 14 Aug 2024 10:31:53 -0700 Subject: [PATCH] fix new lint errors --- cmd/auto-pause/auto-pause-hook/config.go | 3 +- cmd/minikube/cmd/config/profile_list.go | 2 +- cmd/minikube/cmd/config/prompt.go | 4 +- cmd/minikube/cmd/delete.go | 2 +- cmd/minikube/cmd/image.go | 2 +- cmd/minikube/cmd/service.go | 8 +- pkg/addons/addons_test.go | 4 +- pkg/addons/validations.go | 3 +- .../bootstrapper/bsutil/kverify/pod_ready.go | 3 +- .../bsutil/kverify/system_pods.go | 4 +- pkg/minikube/download/iso.go | 2 +- pkg/minikube/exit/exit.go | 2 +- pkg/minikube/machine/cache_images.go | 6 +- pkg/minikube/machine/client.go | 2 +- pkg/minikube/machine/machine.go | 5 +- pkg/minikube/node/start.go | 2 +- pkg/minikube/notify/notify_test.go | 2 +- pkg/minikube/out/out.go | 94 ++++++++++++++----- pkg/minikube/out/out_test.go | 28 ++++-- pkg/minikube/reason/match_test.go | 4 +- .../storageclass/storageclass_test.go | 4 +- pkg/minikube/tests/host_mock.go | 4 +- pkg/minikube/tunnel/tunnel.go | 6 +- test/integration/ha_test.go | 8 +- test/integration/multinode_test.go | 8 +- 25 files changed, 137 insertions(+), 75 deletions(-) diff --git a/cmd/auto-pause/auto-pause-hook/config.go b/cmd/auto-pause/auto-pause-hook/config.go index 5fe8c83f002d..5b92437eeaa0 100644 --- a/cmd/auto-pause/auto-pause-hook/config.go +++ b/cmd/auto-pause/auto-pause-hook/config.go @@ -20,7 +20,6 @@ import ( "context" "crypto/tls" "crypto/x509" - "fmt" "log" v1 "k8s.io/api/admissionregistration/v1" @@ -59,7 +58,7 @@ func apiServerCert(clientset *kubernetes.Clientset) []byte { pem, ok := c.Data["requestheader-client-ca-file"] if !ok { - klog.Fatalf(fmt.Sprintf("cannot find the ca.crt in the configmap, configMap.Data is %#v", c.Data)) + klog.Fatalf("cannot find the ca.crt in the configmap, configMap.Data is %#v", c.Data) } klog.Info("client-ca-file=", pem) return []byte(pem) diff --git a/cmd/minikube/cmd/config/profile_list.go b/cmd/minikube/cmd/config/profile_list.go index 2c9faac95c64..99d151759e36 100644 --- a/cmd/minikube/cmd/config/profile_list.go +++ b/cmd/minikube/cmd/config/profile_list.go @@ -241,7 +241,7 @@ func warnInvalidProfiles(invalidProfiles []*config.Profile) { out.ErrT(style.Tip, "You can delete them using the following command(s): ") for _, p := range invalidProfiles { - out.Err(fmt.Sprintf("\t $ minikube delete -p %s \n", p.Name)) + out.Errf("\t $ minikube delete -p %s \n", p.Name) } } diff --git a/cmd/minikube/cmd/config/prompt.go b/cmd/minikube/cmd/config/prompt.go index 1a8b49821dff..5e6c3a9eef4d 100644 --- a/cmd/minikube/cmd/config/prompt.go +++ b/cmd/minikube/cmd/config/prompt.go @@ -36,7 +36,7 @@ func AskForYesNoConfirmation(s string, posResponses, negResponses []string) bool reader := bufio.NewReader(os.Stdin) for { - out.String("%s [y/n]: ", s) + out.Stringf("%s [y/n]: ", s) response, err := reader.ReadString('\n') if err != nil { @@ -78,7 +78,7 @@ func AskForStaticValueOptional(s string) string { } func getStaticValue(reader *bufio.Reader, s string) string { - out.String("%s", s) + out.String(s) response, err := reader.ReadString('\n') if err != nil { diff --git a/cmd/minikube/cmd/delete.go b/cmd/minikube/cmd/delete.go index 20ccbd1c0c85..1fa0862bac57 100644 --- a/cmd/minikube/cmd/delete.go +++ b/cmd/minikube/cmd/delete.go @@ -642,7 +642,7 @@ func killProcess(path string) error { // if multiple errors were encountered, combine them into a single error out.Styled(style.Failure, "Multiple errors encountered:") for _, e := range errs { - out.Err("%v\n", e) + out.Errf("%v\n", e) } return errors.New("multiple errors encountered while closing mount processes") } diff --git a/cmd/minikube/cmd/image.go b/cmd/minikube/cmd/image.go index 85eb23f710ed..27b8ee2b7721 100644 --- a/cmd/minikube/cmd/image.go +++ b/cmd/minikube/cmd/image.go @@ -314,7 +314,7 @@ var buildImageCmd = &cobra.Command{ if runtime.GOOS == "windows" && strings.Contains(dockerFile, "\\") { // if dockerFile is a DOS path, translate it into UNIX path // because we are going to build this image in UNIX environment - out.String("minikube detects that you are using DOS-style path %s. minikube will convert it to UNIX-style by replacing all \\ to /", dockerFile) + out.Stringf("minikube detects that you are using DOS-style path %s. minikube will convert it to UNIX-style by replacing all \\ to /", dockerFile) dockerFile = strings.ReplaceAll(dockerFile, "\\", "/") } if err := machine.BuildImage(img, dockerFile, tag, push, buildEnv, buildOpt, []*config.Profile{profile}, allNodes, nodeName); err != nil { diff --git a/cmd/minikube/cmd/service.go b/cmd/minikube/cmd/service.go index 4723cc65ab2d..227271cfe1f2 100644 --- a/cmd/minikube/cmd/service.go +++ b/cmd/minikube/cmd/service.go @@ -147,7 +147,7 @@ You may select another namespace by using 'minikube service {{.service}} -n (2 * time.Second) { diff --git a/pkg/minikube/bootstrapper/bsutil/kverify/system_pods.go b/pkg/minikube/bootstrapper/bsutil/kverify/system_pods.go index 397113fb8b23..7da7512312db 100644 --- a/pkg/minikube/bootstrapper/bsutil/kverify/system_pods.go +++ b/pkg/minikube/bootstrapper/bsutil/kverify/system_pods.go @@ -58,7 +58,7 @@ func WaitForSystemPods(r cruntime.Manager, bs bootstrapper.Bootstrapper, cfg con klog.Infof("%d kube-system pods found", len(pods.Items)) for _, pod := range pods.Items { - klog.Infof(podStatusMsg(pod)) + klog.Info(podStatusMsg(pod)) } if len(pods.Items) < 2 { @@ -86,7 +86,7 @@ func ExpectAppsRunning(cs *kubernetes.Clientset, expected []string) error { klog.Infof("%d kube-system pods found", len(pods.Items)) for _, pod := range pods.Items { - klog.Infof(podStatusMsg(pod)) + klog.Info(podStatusMsg(pod)) if pod.Status.Phase != core.PodRunning { continue diff --git a/pkg/minikube/download/iso.go b/pkg/minikube/download/iso.go index 5c62ce9e5bb6..964d3b328bd9 100644 --- a/pkg/minikube/download/iso.go +++ b/pkg/minikube/download/iso.go @@ -100,7 +100,7 @@ func ISO(urls []string, skipChecksum bool) (string, error) { msg.WriteString(fmt.Sprintf(" %s: %s\n", u, err)) } - return "", fmt.Errorf(msg.String()) + return "", errors.New(msg.String()) } // downloadISO downloads an ISO URL diff --git a/pkg/minikube/exit/exit.go b/pkg/minikube/exit/exit.go index 71a9dcff03a6..775c8ef0e994 100644 --- a/pkg/minikube/exit/exit.go +++ b/pkg/minikube/exit/exit.go @@ -70,7 +70,7 @@ func Message(r reason.Kind, format string, args ...out.V) { // Code will exit with a code func Code(code int) { if shell { - out.Output(os.Stdout, fmt.Sprintf("false exit code %d\n", code)) + out.Outputf(os.Stdout, "false exit code %d\n", code) } os.Exit(code) } diff --git a/pkg/minikube/machine/cache_images.go b/pkg/minikube/machine/cache_images.go index 2e0c6be38002..56303e6907f2 100644 --- a/pkg/minikube/machine/cache_images.go +++ b/pkg/minikube/machine/cache_images.go @@ -762,21 +762,21 @@ func ListImages(profile *config.Profile, format string) error { klog.Warningf("Error marshalling images list: %v", err.Error()) return nil } - fmt.Printf(string(json) + "\n") + fmt.Printf("%s\n", string(json)) case "yaml": yaml, err := yaml.Marshal(uniqueImages) if err != nil { klog.Warningf("Error marshalling images list: %v", err.Error()) return nil } - fmt.Printf(string(yaml) + "\n") + fmt.Printf("%s\n", string(yaml)) default: res := []string{} for _, item := range uniqueImages { res = append(res, item.RepoTags...) } sort.Sort(sort.Reverse(sort.StringSlice(res))) - fmt.Printf(strings.Join(res, "\n") + "\n") + fmt.Printf("%s\n", strings.Join(res, "\n")) } return nil diff --git a/pkg/minikube/machine/client.go b/pkg/minikube/machine/client.go index ff959365da42..67f370f649e9 100644 --- a/pkg/minikube/machine/client.go +++ b/pkg/minikube/machine/client.go @@ -191,7 +191,7 @@ func (api *LocalClient) Create(h *host.Host) error { // CA cert and client cert should be generated atomically, otherwise might cause bad certificate error. lockErr := api.flock.LockWithTimeout(time.Second * 5) if lockErr != nil { - return fmt.Errorf("failed to acquire bootstrap client lock: %v " + lockErr.Error()) + return fmt.Errorf("failed to acquire bootstrap client lock: %v", lockErr) } defer func() { lockErr = api.flock.Unlock() diff --git a/pkg/minikube/machine/machine.go b/pkg/minikube/machine/machine.go index d006e4464464..62a24d4bae65 100644 --- a/pkg/minikube/machine/machine.go +++ b/pkg/minikube/machine/machine.go @@ -17,7 +17,6 @@ limitations under the License. package machine import ( - "fmt" "os/exec" "path" "strings" @@ -173,7 +172,7 @@ func backup(h host.Host, files []string) error { } } if len(errs) > 0 { - return errors.Errorf(fmt.Sprintf("%v", errs)) + return errors.Errorf("%v", errs) } return nil } @@ -208,7 +207,7 @@ func restore(h host.Host) error { } } if len(errs) > 0 { - return errors.Errorf(fmt.Sprintf("%v", errs)) + return errors.Errorf("%v", errs) } return nil } diff --git a/pkg/minikube/node/start.go b/pkg/minikube/node/start.go index 0ca736708d16..ccf6e830ed10 100755 --- a/pkg/minikube/node/start.go +++ b/pkg/minikube/node/start.go @@ -632,7 +632,7 @@ func setupKubeconfig(h host.Host, cc config.ClusterConfig, n config.Node, cluste exit.Message(reason.DrvCPEndpoint, fmt.Sprintf("failed to construct cluster server address: %v", err), out.V{"profileArg": fmt.Sprintf("--profile=%s", clusterName)}) } } - addr := fmt.Sprintf("https://" + net.JoinHostPort(host, strconv.Itoa(port))) + addr := fmt.Sprintf("https://%s", net.JoinHostPort(host, strconv.Itoa(port))) if cc.KubernetesConfig.APIServerName != constants.APIServerName { addr = strings.ReplaceAll(addr, host, cc.KubernetesConfig.APIServerName) diff --git a/pkg/minikube/notify/notify_test.go b/pkg/minikube/notify/notify_test.go index 9073ddf57139..72ecca3f6116 100644 --- a/pkg/minikube/notify/notify_test.go +++ b/pkg/minikube/notify/notify_test.go @@ -122,7 +122,7 @@ func TestLatestVersionFromURLCorrect(t *testing.T) { latestVersion, err := latestVersionFromURL(server.URL) if err != nil { - t.Fatalf(err.Error()) + t.Fatal(err.Error()) } expectedVersion, _ := semver.Make(versionFromURL) if latestVersion.Compare(expectedVersion) != 0 { diff --git a/pkg/minikube/out/out.go b/pkg/minikube/out/out.go index 4ce9ac62d1f8..9c3dcae95218 100644 --- a/pkg/minikube/out/out.go +++ b/pkg/minikube/out/out.go @@ -126,12 +126,12 @@ func boxedCommon(printFunc func(format string, a ...interface{}), cfg box.Config // Boxed writes a stylized and templated message in a box to stdout using the default style config func Boxed(format string, a ...V) { - boxedCommon(String, defaultBoxCfg, "", format, a...) + boxedCommon(Stringf, defaultBoxCfg, "", format, a...) } // BoxedErr writes a stylized and templated message in a box to stderr using the default style config func BoxedErr(format string, a ...V) { - boxedCommon(Err, defaultBoxCfg, "", format, a...) + boxedCommon(Errf, defaultBoxCfg, "", format, a...) } // BoxedWithConfig writes a templated message in a box with customized style config to stdout @@ -141,7 +141,7 @@ func BoxedWithConfig(cfg box.Config, st style.Enum, title string, text string, a } // need to make sure no newlines are in the title otherwise box-cli-maker panics title = strings.ReplaceAll(title, "\n", "") - boxedCommon(String, cfg, title, text, a...) + boxedCommon(Stringf, cfg, title, text, a...) } // Sprintf is used for returning the string (doesn't write anything) @@ -159,8 +159,32 @@ func Infof(format string, a ...V) { String(outStyled) } +// String writes a basic string to stdout +func String(s string) { + // Flush log buffer so that output order makes sense + klog.Flush() + defer klog.Flush() + + if silent || JSON { + klog.Info(s) + return + } + + if outFile == nil { + klog.Warningf("[unset outFile]: %s", s) + return + } + klog.Info(s) + // if spin is active from a previous step, it will stop spinner displaying + if spin.Active() { + spin.Stop() + } + + Output(outFile, s) +} + // String writes a basic formatted string to stdout -func String(format string, a ...interface{}) { +func Stringf(format string, a ...interface{}) { // Flush log buffer so that output order makes sense klog.Flush() defer klog.Flush() @@ -180,11 +204,18 @@ func String(format string, a ...interface{}) { spin.Stop() } - Output(outFile, format, a...) + Outputf(outFile, format, a...) } -// Output writes a basic formatted string -func Output(file fdWriter, format string, a ...interface{}) { +// Output writes a basic string +func Output(file fdWriter, s string) { + if _, err := fmt.Fprint(file, s); err != nil { + klog.Errorf("Fprint failed: %v", err) + } +} + +// Outputf writes a basic formatted string +func Outputf(file fdWriter, format string, a ...interface{}) { _, err := fmt.Fprintf(file, format, a...) if err != nil { klog.Errorf("Fprintf failed: %v", err) @@ -192,28 +223,28 @@ func Output(file fdWriter, format string, a ...interface{}) { } // spinnerString writes a basic formatted string to stdout with spinner character -func spinnerString(format string, a ...interface{}) { +func spinnerString(s string) { // Flush log buffer so that output order makes sense klog.Flush() if outFile == nil { - klog.Warningf("[unset outFile]: %s", fmt.Sprintf(format, a...)) + klog.Warningf("[unset outFile]: %s", s) return } - klog.Infof(format, a...) + klog.Info(s) // if spin is active from a previous step, it will stop spinner displaying if spin.Active() { spin.Stop() } - Output(outFile, format, a...) + Output(outFile, s) // Start spinning at the end of the printed line spin.Start() } // Ln writes a basic formatted string with a newline to stdout func Ln(format string, a ...interface{}) { - String(format+"\n", a...) + Stringf(format+"\n", a...) } // ErrT writes a stylized and templated error message to stderr @@ -222,8 +253,31 @@ func ErrT(st style.Enum, format string, a ...V) { Err(errStyled) } -// Err writes a basic formatted string to stderr -func Err(format string, a ...interface{}) { +// Err writes a basic string to stderr +func Err(s string) { + if JSON { + register.PrintError(s) + klog.Warning(s) + return + } + register.RecordError(s) + + if errFile == nil { + klog.Errorf("[unset errFile]: %s", s) + return + } + + klog.Warning(s) + + // if spin is active from a previous step, it will stop spinner displaying + if spin.Active() { + spin.Stop() + } + Output(errFile, s) +} + +// Errf writes a basic formatted string to stderr +func Errf(format string, a ...interface{}) { if JSON { register.PrintError(format) klog.Warningf(format, a...) @@ -242,12 +296,12 @@ func Err(format string, a ...interface{}) { if spin.Active() { spin.Stop() } - Output(errFile, format, a...) + Outputf(errFile, format, a...) } // ErrLn writes a basic formatted string with a newline to stderr func ErrLn(format string, a ...interface{}) { - Err(format+"\n", a...) + Errf(format+"\n", a...) } // SuccessT is a shortcut for writing a templated success message to stdout @@ -361,7 +415,7 @@ func LogEntries(msg string, err error, entries map[string][]string) { // displayError prints the error and displays the standard minikube error messaging func displayError(msg string, err error) { - klog.Warningf(fmt.Sprintf("%s: %v", msg, err)) + klog.Warningf("%s: %v", msg, err) if JSON { ErrT(style.Fatal, "{{.msg}}: {{.err}}", V{"msg": translate.T(msg), "err": err}) return @@ -452,12 +506,6 @@ func applyTmpl(format string, a ...V) string { // Return quotes back to normal out = html.UnescapeString(out) - - // escape any outstanding '%' signs so that they don't get interpreted - // as a formatting directive down the line - out = strings.ReplaceAll(out, "%", "%%") - // avoid doubling up in case this function is called multiple times - out = strings.ReplaceAll(out, "%%%%", "%%") return out } diff --git a/pkg/minikube/out/out_test.go b/pkg/minikube/out/out_test.go index 76be25399e2e..f1629a3373c8 100644 --- a/pkg/minikube/out/out_test.go +++ b/pkg/minikube/out/out_test.go @@ -33,7 +33,7 @@ import ( "k8s.io/minikube/pkg/minikube/translate" ) -func TestOutT(t *testing.T) { +func TestStep(t *testing.T) { // Set the system locale to Arabic and define a dummy translation file. translate.SetPreferredLanguage(language.Arabic) @@ -70,14 +70,14 @@ func TestOutT(t *testing.T) { want = tc.want } if got != want { - t.Errorf("OutStyle() = %q (%d runes), want %q (%d runes)", got, len(got), want, len(want)) + t.Errorf("Step() = %q (%d runes), want %q (%d runes)", got, len(got), want, len(want)) } }) } } } -func TestOut(t *testing.T) { +func TestString(t *testing.T) { t.Setenv(OverrideEnv, "") testCases := []struct { @@ -97,11 +97,11 @@ func TestOut(t *testing.T) { if tc.arg == nil { String(tc.format) } else { - String(tc.format, tc.arg) + Stringf(tc.format, tc.arg) } got := f.String() if got != tc.want { - t.Errorf("Out(%s, %s) = %q, want %q", tc.format, tc.arg, got, tc.want) + t.Errorf("String(%s, %s) = %q, want %q", tc.format, tc.arg, got, tc.want) } }) } @@ -111,16 +111,30 @@ func TestErr(t *testing.T) { t.Setenv(OverrideEnv, "0") f := tests.NewFakeFile() SetErrFile(f) - Err("xyz123 %s\n", "%s%%%d") + Err("xyz123\n") Ln("unrelated message") got := f.String() - want := "xyz123 %s%%%d\n" + want := "xyz123\n" if got != want { t.Errorf("Err() = %q, want %q", got, want) } } +func TestErrf(t *testing.T) { + t.Setenv(OverrideEnv, "0") + f := tests.NewFakeFile() + SetErrFile(f) + Errf("xyz123 %s\n", "%s%%%d") + Ln("unrelated message") + got := f.String() + want := "xyz123 %s%%%d\n" + + if got != want { + t.Errorf("Errf() = %q, want %q", got, want) + } +} + func createLogFile() (string, error) { td := os.TempDir() name := filepath.Join(td, "minikube_test_test_test.log") diff --git a/pkg/minikube/reason/match_test.go b/pkg/minikube/reason/match_test.go index 2b111bb8ee93..5eb4e6c88431 100644 --- a/pkg/minikube/reason/match_test.go +++ b/pkg/minikube/reason/match_test.go @@ -17,7 +17,7 @@ limitations under the License. package reason import ( - "fmt" + "errors" "testing" ) @@ -68,7 +68,7 @@ VBoxManage.exe: error: Details: code E_FAIL (0x80004005), component MachineWrap, } for _, tc := range tests { t.Run(tc.want, func(t *testing.T) { - got := MatchKnownIssue(Kind{}, fmt.Errorf(tc.err), tc.os) + got := MatchKnownIssue(Kind{}, errors.New(tc.err), tc.os) if got == nil { if tc.want != "" { t.Errorf("FromError(%q)=nil, want %s", tc.err, tc.want) diff --git a/pkg/minikube/storageclass/storageclass_test.go b/pkg/minikube/storageclass/storageclass_test.go index 3ed785a596ab..f5d90c744a61 100644 --- a/pkg/minikube/storageclass/storageclass_test.go +++ b/pkg/minikube/storageclass/storageclass_test.go @@ -230,13 +230,13 @@ func TestGetStoragev1(t *testing.T) { } configFile, err := os.CreateTemp("/tmp", "") if err != nil { - t.Fatalf(err.Error()) + t.Fatal(err.Error()) } defer os.Remove(configFile.Name()) for _, test := range tests { t.Run(test.description, func(t *testing.T) { if err := setK8SConfig(t, test.config, configFile.Name()); err != nil { - t.Fatalf(err.Error()) + t.Fatal(err.Error()) } // context name is hardcoded by mockK8sConfig diff --git a/pkg/minikube/tests/host_mock.go b/pkg/minikube/tests/host_mock.go index dc25df43b7f4..377af318114b 100644 --- a/pkg/minikube/tests/host_mock.go +++ b/pkg/minikube/tests/host_mock.go @@ -17,7 +17,7 @@ limitations under the License. package tests import ( - "fmt" + "errors" "github.com/docker/machine/libmachine/drivers" ) @@ -49,7 +49,7 @@ func (m MockHost) RunSSHCommand(cmd string) (string, error) { return output, nil } if m.Error != "" { - return "", fmt.Errorf(m.Error) + return "", errors.New(m.Error) } return "", nil } diff --git a/pkg/minikube/tunnel/tunnel.go b/pkg/minikube/tunnel/tunnel.go index a80a7aaaaea9..9ac3747b8865 100644 --- a/pkg/minikube/tunnel/tunnel.go +++ b/pkg/minikube/tunnel/tunnel.go @@ -100,7 +100,7 @@ func (t *tunnel) cleanup() *Status { err := t.router.Cleanup(t.status.TunnelID.Route) if err != nil { t.status.RouteError = errors.Errorf("error cleaning up route: %v", err) - klog.V(3).Infof(t.status.RouteError.Error()) + klog.V(3).Info(t.status.RouteError.Error()) } else { err = t.registry.Remove(t.status.TunnelID.Route) if err != nil { @@ -211,7 +211,7 @@ func setupBridge(t *tunnel) { command = exec.Command("sudo", "ifconfig", "bridge100", "deletem", member) klog.Infof("About to run command: %s\n", command.Args) response, err = command.CombinedOutput() - klog.Infof(string(response)) + klog.Info(string(response)) if err != nil { t.status.RouteError = fmt.Errorf("couldn't remove member %s: %s", member, err) return @@ -220,7 +220,7 @@ func setupBridge(t *tunnel) { command = exec.Command("sudo", "ifconfig", "bridge100", "addm", member) klog.Infof("About to run command: %s\n", command.Args) response, err = command.CombinedOutput() - klog.Infof(string(response)) + klog.Info(string(response)) if err != nil { t.status.RouteError = fmt.Errorf("couldn't re-add member %s: %s", member, err) return diff --git a/test/integration/ha_test.go b/test/integration/ha_test.go index 258c4be88fd8..4cbbc941ca98 100644 --- a/test/integration/ha_test.go +++ b/test/integration/ha_test.go @@ -140,17 +140,17 @@ func validateHADeployApp(ctx context.Context, t *testing.T, profile string) { rr, err := Run(t, exec.CommandContext(ctx, Target(), "kubectl", "-p", profile, "--", "get", "pods", "-o", "jsonpath='{.items[*].status.podIP}'")) if err != nil { err := fmt.Errorf("failed to retrieve Pod IPs (may be temporary): %v", err) - t.Logf(err.Error()) + t.Log(err.Error()) return err } podIPs := strings.Split(strings.Trim(rr.Stdout.String(), "'"), " ") if len(podIPs) != 3 { err := fmt.Errorf("expected 3 Pod IPs but got %d (may be temporary), output: %q", len(podIPs), rr.Output()) - t.Logf(err.Error()) + t.Log(err.Error()) return err } else if podIPs[0] == podIPs[1] || podIPs[0] == podIPs[2] || podIPs[1] == podIPs[2] { err := fmt.Errorf("expected 3 different pod IPs but got %s and %s (may be temporary), output: %q", podIPs[0], podIPs[1], rr.Output()) - t.Logf(err.Error()) + t.Log(err.Error()) return err } return nil @@ -419,7 +419,7 @@ func validateHARestartSecondaryNode(ctx context.Context, t *testing.T, profile s // start stopped node(s) back up rr, err := Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "node", "start", SecondNodeName, "-v=7", "--alsologtostderr")) if err != nil { - t.Logf(rr.Stderr.String()) + t.Log(rr.Stderr.String()) t.Errorf("secondary control-plane node start returned an error. args %q: %v", rr.Command(), err) } diff --git a/test/integration/multinode_test.go b/test/integration/multinode_test.go index 3800f4b4f9b4..a775358f33f2 100644 --- a/test/integration/multinode_test.go +++ b/test/integration/multinode_test.go @@ -281,7 +281,7 @@ func validateStartNodeAfterStop(ctx context.Context, t *testing.T, profile strin // Start the node back up rr, err := Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "node", "start", ThirdNodeName, "-v=7", "--alsologtostderr")) if err != nil { - t.Logf(rr.Stderr.String()) + t.Log(rr.Stderr.String()) t.Errorf("node start returned an error. args %q: %v", rr.Command(), err) } @@ -505,17 +505,17 @@ func validateDeployAppToMultiNode(ctx context.Context, t *testing.T, profile str rr, err := Run(t, exec.CommandContext(ctx, Target(), "kubectl", "-p", profile, "--", "get", "pods", "-o", "jsonpath='{.items[*].status.podIP}'")) if err != nil { err := fmt.Errorf("failed to retrieve Pod IPs (may be temporary): %v", err) - t.Logf(err.Error()) + t.Log(err.Error()) return err } podIPs := strings.Split(strings.Trim(rr.Stdout.String(), "'"), " ") if len(podIPs) != 2 { err := fmt.Errorf("expected 2 Pod IPs but got %d (may be temporary), output: %q", len(podIPs), rr.Output()) - t.Logf(err.Error()) + t.Log(err.Error()) return err } else if podIPs[0] == podIPs[1] { err := fmt.Errorf("expected 2 different pod IPs but got %s and %s (may be temporary), output: %q", podIPs[0], podIPs[1], rr.Output()) - t.Logf(err.Error()) + t.Log(err.Error()) return err } return nil