Skip to content

Commit 2037f39

Browse files
committed
kubeadm: use 'writer' everywhere in util/apiclient/wait.go
1 parent 310723b commit 2037f39

File tree

1 file changed

+15
-15
lines changed
  • cmd/kubeadm/app/util/apiclient

1 file changed

+15
-15
lines changed

cmd/kubeadm/app/util/apiclient/wait.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ func getControlPlaneComponents(podMap map[string]*v1.Pod, addressAPIServer strin
246246

247247
// WaitForControlPlaneComponents waits for all control plane components to report "ok".
248248
func (w *KubeWaiter) WaitForControlPlaneComponents(podMap map[string]*v1.Pod, apiSeverAddress string) error {
249-
fmt.Printf("[control-plane-check] Waiting for healthy control plane components."+
249+
_, _ = fmt.Fprintf(w.writer, "[control-plane-check] Waiting for healthy control plane components."+
250250
" This can take up to %v\n", w.timeout)
251251

252252
components, err := getControlPlaneComponents(podMap, apiSeverAddress)
@@ -259,7 +259,7 @@ func (w *KubeWaiter) WaitForControlPlaneComponents(podMap map[string]*v1.Pod, ap
259259

260260
for _, comp := range components {
261261
url := fmt.Sprintf("https://%s/%s", comp.addressPort, comp.endpoint)
262-
fmt.Printf("[control-plane-check] Checking %s at %s\n", comp.name, url)
262+
_, _ = fmt.Fprintf(w.writer, "[control-plane-check] Checking %s at %s\n", comp.name, url)
263263

264264
go func(comp controlPlaneComponent) {
265265
tr := &http.Transport{
@@ -305,11 +305,11 @@ func (w *KubeWaiter) WaitForControlPlaneComponents(podMap map[string]*v1.Pod, ap
305305
return true, nil
306306
})
307307
if err != nil {
308-
fmt.Printf("[control-plane-check] %s is not healthy after %v\n", comp.name, time.Since(start))
308+
_, _ = fmt.Fprintf(w.writer, "[control-plane-check] %s is not healthy after %v\n", comp.name, time.Since(start))
309309
errChan <- lastError
310310
return
311311
}
312-
fmt.Printf("[control-plane-check] %s is healthy after %v\n", comp.name, time.Since(start))
312+
_, _ = fmt.Fprintf(w.writer, "[control-plane-check] %s is healthy after %v\n", comp.name, time.Since(start))
313313
errChan <- nil
314314
}(comp)
315315
}
@@ -324,7 +324,7 @@ func (w *KubeWaiter) WaitForControlPlaneComponents(podMap map[string]*v1.Pod, ap
324324

325325
// WaitForAPI waits for the API Server's /healthz endpoint to report "ok"
326326
func (w *KubeWaiter) WaitForAPI() error {
327-
fmt.Printf("[api-check] Waiting for a healthy API server. This can take up to %v\n", w.timeout)
327+
_, _ = fmt.Fprintf(w.writer, "[api-check] Waiting for a healthy API server. This can take up to %v\n", w.timeout)
328328

329329
start := time.Now()
330330
err := wait.PollUntilContextTimeout(
@@ -340,11 +340,11 @@ func (w *KubeWaiter) WaitForAPI() error {
340340
return true, nil
341341
})
342342
if err != nil {
343-
fmt.Printf("[api-check] The API server is not healthy after %v\n", time.Since(start))
343+
_, _ = fmt.Fprintf(w.writer, "[api-check] The API server is not healthy after %v\n", time.Since(start))
344344
return err
345345
}
346346

347-
fmt.Printf("[api-check] The API server is healthy after %v\n", time.Since(start))
347+
_, _ = fmt.Fprintf(w.writer, "[api-check] The API server is healthy after %v\n", time.Since(start))
348348
return nil
349349
}
350350

@@ -359,12 +359,12 @@ func (w *KubeWaiter) WaitForPodsWithLabel(kvLabel string) error {
359359
listOpts := metav1.ListOptions{LabelSelector: kvLabel}
360360
pods, err := w.client.CoreV1().Pods(metav1.NamespaceSystem).List(context.TODO(), listOpts)
361361
if err != nil {
362-
fmt.Fprintf(w.writer, "[apiclient] Error getting Pods with label selector %q [%v]\n", kvLabel, err)
362+
_, _ = fmt.Fprintf(w.writer, "[apiclient] Error getting Pods with label selector %q [%v]\n", kvLabel, err)
363363
return false, nil
364364
}
365365

366366
if lastKnownPodNumber != len(pods.Items) {
367-
fmt.Fprintf(w.writer, "[apiclient] Found %d Pods for label selector %s\n", len(pods.Items), kvLabel)
367+
_, _ = fmt.Fprintf(w.writer, "[apiclient] Found %d Pods for label selector %s\n", len(pods.Items), kvLabel)
368368
lastKnownPodNumber = len(pods.Items)
369369
}
370370

@@ -391,10 +391,10 @@ func (w *KubeWaiter) WaitForKubelet(healthzAddress string, healthzPort int32) er
391391
)
392392

393393
if healthzPort == 0 {
394-
fmt.Println("[kubelet-check] Skipping the kubelet health check because the healthz port is set to 0")
394+
_, _ = fmt.Fprintln(w.writer, "[kubelet-check] Skipping the kubelet health check because the healthz port is set to 0")
395395
return nil
396396
}
397-
fmt.Printf("[kubelet-check] Waiting for a healthy kubelet at %s. This can take up to %v\n",
397+
_, _ = fmt.Fprintf(w.writer, "[kubelet-check] Waiting for a healthy kubelet at %s. This can take up to %v\n",
398398
healthzEndpoint, w.timeout)
399399

400400
formatError := func(cause string) error {
@@ -429,11 +429,11 @@ func (w *KubeWaiter) WaitForKubelet(healthzAddress string, healthzPort int32) er
429429
return true, nil
430430
})
431431
if err != nil {
432-
fmt.Printf("[kubelet-check] The kubelet is not healthy after %v\n", time.Since(start))
432+
_, _ = fmt.Fprintf(w.writer, "[kubelet-check] The kubelet is not healthy after %v\n", time.Since(start))
433433
return lastError
434434
}
435435

436-
fmt.Printf("[kubelet-check] The kubelet is healthy after %v\n", time.Since(start))
436+
_, _ = fmt.Fprintf(w.writer, "[kubelet-check] The kubelet is healthy after %v\n", time.Since(start))
437437
return nil
438438
}
439439

@@ -540,10 +540,10 @@ func PrintControlPlaneErrorHelpScreen(outputWriter io.Writer, criSocket string)
540540
Socket: criSocket,
541541
}
542542
_ = controlPlaneFailTempl.Execute(outputWriter, context)
543-
fmt.Println("")
543+
_, _ = fmt.Fprintln(outputWriter, "")
544544
}
545545

546546
// PrintKubeletErrorHelpScreen prints help text on kubelet errors.
547547
func PrintKubeletErrorHelpScreen(outputWriter io.Writer) {
548-
fmt.Fprintln(outputWriter, kubeletFailMsg)
548+
_, _ = fmt.Fprintln(outputWriter, kubeletFailMsg)
549549
}

0 commit comments

Comments
 (0)