From f70110b53761853448a04bd1dbcf7806b83dcdad Mon Sep 17 00:00:00 2001 From: Adrian Stobbe Date: Tue, 12 Sep 2023 11:47:28 +0200 Subject: [PATCH] better error handling --- cli/internal/kubecmd/kubecmd.go | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/cli/internal/kubecmd/kubecmd.go b/cli/internal/kubecmd/kubecmd.go index e6db339532..08dde7c80b 100644 --- a/cli/internal/kubecmd/kubecmd.go +++ b/cli/internal/kubecmd/kubecmd.go @@ -117,13 +117,12 @@ func (k *KubeCmd) UpgradeK8sVersion(ctx context.Context, k8sVersion versions.Val string(k8sVersion), fmt.Errorf("no version config matching K8s %s", k8sVersion)) } components, err = k.updateK8s(&nodeVersion, versionConfig.ClusterVersion, versionConfig.KubernetesComponents, force) - if err == nil { - err = k.applyComponentsCM(ctx, components) - if err != nil { - return fmt.Errorf("applying k8s components ConfigMap: %w", err) - } + if err != nil { + return fmt.Errorf("updating K8s: %w", err) + } + if err := k.applyComponentsCM(ctx, components); err != nil { + return fmt.Errorf("applying k8s components ConfigMap: %w", err) } - fmt.Println("Successfully updated Kubernetes version", nodeVersion.Spec.KubernetesClusterVersion, "conf", k8sVersion) updatedNodeVersion, err := k.applyNodeVersion(ctx, nodeVersion) if err != nil { return fmt.Errorf("applying upgrade: %w", err) @@ -133,7 +132,6 @@ func (k *KubeCmd) UpgradeK8sVersion(ctx context.Context, k8sVersion versions.Val // UpgradeImageVersion upgrades the cluster's image. // The versions set in the config are validated against the versions running in the cluster. -// TODO(elchead): AB#3434 Split K8s and image upgrade of UpgradeNodeVersion. func (k *KubeCmd) UpgradeImageVersion(ctx context.Context, conf *config.Config, force bool) error { provider := conf.GetProvider() attestationVariant := conf.GetAttestationConfig().GetVariant()