Skip to content

Commit

Permalink
Merge pull request #378 from weaveworks/fix-get-nodegroups
Browse files Browse the repository at this point in the history
Do not re-use stacks slice
  • Loading branch information
errordeveloper authored Dec 28, 2018
2 parents 7d9259d + 90116b4 commit d93bb63
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
7 changes: 4 additions & 3 deletions pkg/cfn/manager/nodegroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,17 @@ func (c *StackCollection) DescribeNodeGroupStacks() ([]*Stack, error) {
return nil, err
}

nodeGroupStacks := []*Stack{}
for _, s := range stacks {
if *s.StackStatus == cfn.StackStatusDeleteComplete {
continue
}
if getNodeGroupName(s) != "" {
stacks = append(stacks, s)
nodeGroupStacks = append(nodeGroupStacks, s)
}
}
logger.Debug("nodegroups = %v", stacks)
return stacks, nil
logger.Debug("nodegroups = %v", nodeGroupStacks)
return nodeGroupStacks, nil
}

// DeleteNodeGroup deletes a nodegroup stack
Expand Down
12 changes: 11 additions & 1 deletion pkg/cfn/manager/nodegroup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ var _ = Describe("StackCollection NodeGroup", func() {
StackName: aws.String("eksctl-test-cluster-nodegroup-12345"),
StackId: aws.String("eksctl-test-cluster-nodegroup-12345-id"),
StackStatus: aws.String("CREATE_COMPLETE"),
Tags: []*cfn.Tag{
&cfn.Tag{
Key: aws.String(NodeGroupNameTag),
Value: aws.String("12345"),
},
},
},
},
}, nil)
Expand Down Expand Up @@ -125,10 +131,14 @@ var _ = Describe("StackCollection NodeGroup", func() {
Expect(err).NotTo(HaveOccurred())
})

It("should have called AWS CloudFormation GetTemplate once", func() {
It("should not have called AWS CloudFormation GetTemplate", func() {
Expect(p.MockCloudFormation().AssertNumberOfCalls(GinkgoT(), "GetTemplate", 1)).To(BeTrue())
})

It("should have called AWS CloudFormation DescribeStacks once", func() {
Expect(p.MockCloudFormation().AssertNumberOfCalls(GinkgoT(), "DescribeStacks", 1)).To(BeTrue())
})

It("the output should equal the expectation", func() {
Expect(out).To(HaveLen(1))
Expect(out[0].StackName).To(Equal("eksctl-test-cluster-nodegroup-12345"))
Expand Down

0 comments on commit d93bb63

Please sign in to comment.