From 998f33272d90e4360053d64066b9722288a25aae Mon Sep 17 00:00:00 2001 From: Davanum Srinivas Date: Sun, 22 Oct 2017 19:45:41 -0400 Subject: [PATCH] Better error check for kubectl cluster-info In RunClusterInfo, We try to connect to the api service and get some information, but we just ignore the errors from Do().Visit(). We should return the error returned by Do().Visit() so the "kubectl cluster-info" would fail correctly with an error code. --- pkg/kubectl/cmd/clusterinfo.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/kubectl/cmd/clusterinfo.go b/pkg/kubectl/cmd/clusterinfo.go index 83b90c04eee..142b7bab0ab 100644 --- a/pkg/kubectl/cmd/clusterinfo.go +++ b/pkg/kubectl/cmd/clusterinfo.go @@ -77,7 +77,7 @@ func RunClusterInfo(f cmdutil.Factory, out io.Writer, cmd *cobra.Command) error SelectorParam("kubernetes.io/cluster-service=true"). ResourceTypeOrNameArgs(false, []string{"services"}...). Latest() - b.Do().Visit(func(r *resource.Info, err error) error { + err = b.Do().Visit(func(r *resource.Info, err error) error { if err != nil { return err } @@ -125,7 +125,7 @@ func RunClusterInfo(f cmdutil.Factory, out io.Writer, cmd *cobra.Command) error return nil }) out.Write([]byte("\nTo further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.\n")) - return nil + return err // TODO consider printing more information about cluster }