From 2522e782ddd7d3702f1229c0e0ad54b96e5f8659 Mon Sep 17 00:00:00 2001 From: Odin Ugedal Date: Fri, 26 Jul 2019 18:51:29 +0200 Subject: [PATCH] Fix error handling issue in kubeadm upgrade The error was unintentionally set inside the scope of the if statement, hiding possible errors. --- cmd/kubeadm/app/cmd/upgrade/diff.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cmd/kubeadm/app/cmd/upgrade/diff.go b/cmd/kubeadm/app/cmd/upgrade/diff.go index 93a45a76d92..9aab0698e0c 100644 --- a/cmd/kubeadm/app/cmd/upgrade/diff.go +++ b/cmd/kubeadm/app/cmd/upgrade/diff.go @@ -25,6 +25,7 @@ import ( "github.com/spf13/cobra" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/util/version" + client "k8s.io/client-go/kubernetes" "k8s.io/klog" kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm" "k8s.io/kubernetes/cmd/kubeadm/app/cmd/options" @@ -86,7 +87,8 @@ func runDiff(flags *diffFlags, args []string) error { if flags.cfgPath != "" { cfg, err = configutil.LoadInitConfigurationFromFile(flags.cfgPath) } else { - client, err := kubeconfigutil.ClientSetFromFile(flags.kubeConfigPath) + var client *client.Clientset + client, err = kubeconfigutil.ClientSetFromFile(flags.kubeConfigPath) if err != nil { return errors.Wrapf(err, "couldn't create a Kubernetes client from file %q", flags.kubeConfigPath) }