From 0cbd76ecfbabaa69a65c1333cb8a7b5da9f4dc15 Mon Sep 17 00:00:00 2001 From: John Gardiner Myers Date: Tue, 31 Dec 2019 10:25:55 -0800 Subject: [PATCH 1/2] Simplify code for rolling updates of nodes --- pkg/instancegroups/rollingupdate.go | 36 +++++++++-------------------- 1 file changed, 11 insertions(+), 25 deletions(-) diff --git a/pkg/instancegroups/rollingupdate.go b/pkg/instancegroups/rollingupdate.go index c8cc340ee4..ed7d57c548 100644 --- a/pkg/instancegroups/rollingupdate.go +++ b/pkg/instancegroups/rollingupdate.go @@ -148,42 +148,28 @@ func (c *RollingUpdateCluster) RollingUpdate(groups map[string]*cloudinstances.C } } - // Upgrade nodes, with greater parallelism + // Upgrade nodes { - var wg sync.WaitGroup - // We run nodes in series, even if they are in separate instance groups // typically they will not being separate instance groups. If you roll the nodes in parallel // you can get into a scenario where you can evict multiple statefulset pods from the same // statefulset at the same time. Further improvements needs to be made to protect from this as // well. - wg.Add(1) + for k := range nodeGroups { + results[k] = fmt.Errorf("function panic nodes") + } - go func() { - for k := range nodeGroups { - resultsMutex.Lock() - results[k] = fmt.Errorf("function panic nodes") - resultsMutex.Unlock() + for k, group := range nodeGroups { + g, err := NewRollingUpdateInstanceGroup(c.Cloud, group) + if err == nil { + err = g.RollingUpdate(c, cluster, false, c.NodeInterval, c.ValidationTimeout) } - defer wg.Done() + results[k] = err - for k, group := range nodeGroups { - g, err := NewRollingUpdateInstanceGroup(c.Cloud, group) - if err == nil { - err = g.RollingUpdate(c, cluster, false, c.NodeInterval, c.ValidationTimeout) - } - - resultsMutex.Lock() - results[k] = err - resultsMutex.Unlock() - - // TODO: Bail on error? - } - }() - - wg.Wait() + // TODO: Bail on error? + } } for _, err := range results { From cd499f6f09ca28759fc1d943f15c6432fc08b372 Mon Sep 17 00:00:00 2001 From: John Gardiner Myers Date: Tue, 31 Dec 2019 14:33:05 -0800 Subject: [PATCH 2/2] Remove unused code --- pkg/instancegroups/instancegroups.go | 9 --------- 1 file changed, 9 deletions(-) diff --git a/pkg/instancegroups/instancegroups.go b/pkg/instancegroups/instancegroups.go index 4d8a3365a1..f8d967512a 100644 --- a/pkg/instancegroups/instancegroups.go +++ b/pkg/instancegroups/instancegroups.go @@ -377,12 +377,3 @@ func (r *RollingUpdateInstanceGroup) deleteNode(node *corev1.Node, rollingUpdate return nil } - -// Delete a CloudInstanceGroups -func (r *RollingUpdateInstanceGroup) Delete() error { - if r.CloudGroup == nil { - return fmt.Errorf("group has to be set") - } - // TODO: Leaving func in place in order to cordon and drain nodes - return r.Cloud.DeleteGroup(r.CloudGroup) -}