Log and aggregate errors from rolling update

Rather than just returning the error from the first failing IG
This commit is contained in:
Ole Markus With 2022-10-20 20:04:18 +02:00
parent 4546cafdcb
commit b45968c992
1 changed files with 10 additions and 6 deletions

View File

@ -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 {