From b45968c9920d9c9aade843cf8cbe583d5e0774b1 Mon Sep 17 00:00:00 2001 From: Ole Markus With Date: Thu, 20 Oct 2022 20:04:18 +0200 Subject: [PATCH] Log and aggregate errors from rolling update Rather than just returning the error from the first failing IG --- pkg/instancegroups/rollingupdate.go | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/pkg/instancegroups/rollingupdate.go b/pkg/instancegroups/rollingupdate.go index ed522d32b2..5b1a50f735 100644 --- a/pkg/instancegroups/rollingupdate.go +++ b/pkg/instancegroups/rollingupdate.go @@ -23,6 +23,7 @@ import ( "sync" "time" + "k8s.io/apimachinery/pkg/util/errors" "k8s.io/kops/pkg/client/simple" "k8s.io/client-go/kubernetes" @@ -186,9 +187,10 @@ func (c *RollingUpdateCluster) RollingUpdate(groups map[string]*cloudinstances.C for _, k := range sortGroups(apiServerGroups) { err := c.rollingUpdateInstanceGroup(apiServerGroups[k], c.NodeInterval) - results[k] = err - + if err != nil { + klog.Errorf("failed to roll InstanceGroup %q: %v", k, err) + } // TODO: Bail on error? } } @@ -207,21 +209,23 @@ func (c *RollingUpdateCluster) RollingUpdate(groups map[string]*cloudinstances.C for _, k := range sortGroups(nodeGroups) { err := c.rollingUpdateInstanceGroup(nodeGroups[k], c.NodeInterval) - results[k] = err - + if err != nil { + klog.Errorf("failed to roll InstanceGroup %q: %v", k, err) + } // TODO: Bail on error? } } + errs := []error{} for _, err := range results { if err != nil { - return err + errs = append(errs, err) } } klog.Infof("Rolling update completed for cluster %q!", c.ClusterName) - return nil + return errors.NewAggregate(errs) } func sortGroups(groupMap map[string]*cloudinstances.CloudInstanceGroup) []string {