Skip to content

Commit

Permalink
Don't add empty ASGSuspendProcesses slice to CFN (#2562)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelbeaumont authored Aug 20, 2020
1 parent 54d2bb6 commit 0dd76e7
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
18 changes: 18 additions & 0 deletions pkg/cfn/builder/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3007,6 +3007,24 @@ var _ = Describe("CloudFormation template builder API", func() {
HaveKeyWithValue("SuspendProcesses", []interface{}{"Launch", "InstanceRefresh"}),
)
})
Context("empty asgSuspendProcesses", func() {
cfg, ng := newClusterConfigAndNodegroup(true)

ng.ASGSuspendProcesses = []string{}
build(cfg, "eksctl-test-asgSuspendProcesses-empty", ng)

roundtrip()

It("shouldn't be included in resource", func() {
Expect(ngTemplate.Resources).To(HaveKey("NodeGroup"))
ngResource := ngTemplate.Resources["NodeGroup"]
Expect(ng).ToNot(BeNil())
Expect(ngResource.UpdatePolicy).To(HaveKey("AutoScalingRollingUpdate"))
Expect(ngResource.UpdatePolicy["AutoScalingRollingUpdate"]).ToNot(
HaveKey("SuspendProcesses"),
)
})
})
})

})
Expand Down
14 changes: 9 additions & 5 deletions pkg/cfn/builder/nodegroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,15 +326,19 @@ func nodeGroupResource(launchTemplateName *gfnt.Value, vpcZoneIdentifier interfa
}
}

rollingUpdate := map[string]interface{}{
"MinInstancesInService": "0",
"MaxBatchSize": "1",
}
if len(ng.ASGSuspendProcesses) > 0 {
rollingUpdate["SuspendProcesses"] = ng.ASGSuspendProcesses
}

return &awsCloudFormationResource{
Type: "AWS::AutoScaling::AutoScalingGroup",
Properties: ngProps,
UpdatePolicy: map[string]map[string]interface{}{
"AutoScalingRollingUpdate": {
"MinInstancesInService": "0",
"MaxBatchSize": "1",
"SuspendProcesses": ng.ASGSuspendProcesses,
},
"AutoScalingRollingUpdate": rollingUpdate,
},
}
}
Expand Down

0 comments on commit 0dd76e7

Please sign in to comment.