Skip to content

Commit

Permalink
eks/mng: retries on missing MNG security group
Browse files Browse the repository at this point in the history
Signed-off-by: Gyuho Lee <leegyuho@amazon.com>
  • Loading branch information
gyuho committed May 25, 2020
1 parent 41029a5 commit 9a070c9
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions eks/mng/nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ func (ts *tester) createASG() error {
ts.cfg.EKSConfig.Sync()

timeStart = time.Now()
if err := ts.waitForNodes(cur.Name); err != nil {
if err := ts.waitForNodes(cur.Name, 3); err != nil {
return err
}
timeEnd = time.Now()
Expand Down Expand Up @@ -774,7 +774,7 @@ func (ts *tester) setStatus(sv ManagedNodeGroupStatus) error {
return ts.cfg.EKSConfig.Sync()
}

func (ts *tester) waitForNodes(mngName string) error {
func (ts *tester) waitForNodes(mngName string, retriesLeft int) error {
cur, ok := ts.cfg.EKSConfig.AddOnManagedNodeGroups.MNGs[mngName]
if !ok {
return fmt.Errorf("Managed Node Group %q not found", mngName)
Expand All @@ -800,6 +800,14 @@ func (ts *tester) waitForNodes(mngName string) error {
if cur.RemoteAccessSecurityGroupID == "" {
cur.RemoteAccessSecurityGroupID = aws.StringValue(dout.Nodegroup.Resources.RemoteAccessSecurityGroup)
}
if cur.RemoteAccessSecurityGroupID == "" {
if retriesLeft > 0 {
ts.cfg.Logger.Warn("remote access security group ID not found; retrying", zap.String("mng-name", mngName), zap.Int("retries-left", retriesLeft))
time.Sleep(5 * time.Second)
return ts.waitForNodes(mngName, retriesLeft-1)
}
return fmt.Errorf("remote access security group ID not found for mng %q", mngName)
}
ts.cfg.EKSConfig.AddOnManagedNodeGroups.MNGs[mngName] = cur
ts.cfg.EKSConfig.Sync()

Expand Down

0 comments on commit 9a070c9

Please sign in to comment.