Skip to content

Commit

Permalink
Don't wait for aws-efs-csi-driver if cluster has no nodegroups (#6960)
Browse files Browse the repository at this point in the history
  • Loading branch information
TiberiuGC committed Aug 16, 2023
1 parent 2e9d27a commit 299403d
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 3 deletions.
7 changes: 5 additions & 2 deletions pkg/actions/addon/addon.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,12 @@ func New(clusterConfig *api.ClusterConfig, eksAPI awsapi.EKS, stackManager manag
}

func (a *Manager) waitForAddonToBeActive(ctx context.Context, addon *api.Addon, waitTimeout time.Duration) error {
// Don't wait for coredns or aws-ebs-csi-driver if there are no nodegroups.
// Don't wait for coredns, aws-ebs-csi-driver or aws-efs-csi-driver if there are no nodegroups.
// They will be in degraded state until nodegroups are added.
if (addon.Name == api.CoreDNSAddon || addon.Name == api.AWSEBSCSIDriverAddon) && !a.clusterConfig.HasNodes() {
if (addon.Name == api.CoreDNSAddon ||
addon.Name == api.AWSEBSCSIDriverAddon ||
addon.Name == api.AWSEFSCSIDriverAddon) &&
!a.clusterConfig.HasNodes() {
return nil
}
activeWaiter := eks.NewAddonActiveWaiter(a.eksAPI)
Expand Down
4 changes: 4 additions & 0 deletions pkg/actions/addon/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,10 @@ func (a *Manager) getRecommendedPolicies(addon *api.Addon) (api.InlineDocument,
return nil, nil, &api.WellKnownPolicies{
EBSCSIController: true,
}
case api.AWSEFSCSIDriverAddon:
return nil, nil, &api.WellKnownPolicies{
EFSCSIController: true,
}
default:
return nil, nil, nil
}
Expand Down
30 changes: 29 additions & 1 deletion pkg/actions/addon/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ var _ = Describe("Create", func() {
}
})

DescribeTable("addons created with a waitTimeout", func(e createAddonEntry) {
DescribeTable("addons created with a waitTimeout when there are no active nodes", func(e createAddonEntry) {
expectedDescribeCallsCount := 1
if e.shouldWait {
expectedDescribeCallsCount++
Expand All @@ -404,6 +404,9 @@ var _ = Describe("Create", func() {
Entry("should not wait for Amazon EBS CSI driver to become active", createAddonEntry{
addonName: api.AWSEBSCSIDriverAddon,
}),
Entry("should not wait for Amazon EFS CSI driver to become active", createAddonEntry{
addonName: api.AWSEFSCSIDriverAddon,
}),
Entry("should wait for VPC CNI to become active", createAddonEntry{
addonName: api.VPCCNIAddon,
shouldWait: true,
Expand Down Expand Up @@ -630,6 +633,31 @@ var _ = Describe("Create", func() {
Expect(*createAddonInput.ServiceAccountRoleArn).To(Equal("role-arn"))
})
})

When("it's the aws-efs-csi-driver addon", func() {
It("creates a role with the recommended policies and attaches it to the addon", func() {
err := manager.Create(context.Background(), &api.Addon{
Name: api.AWSEFSCSIDriverAddon,
Version: "v1.0.0-eksbuild.1",
}, 0)
Expect(err).NotTo(HaveOccurred())

Expect(fakeStackManager.CreateStackCallCount()).To(Equal(1))
_, name, resourceSet, tags, _, _ := fakeStackManager.CreateStackArgsForCall(0)
Expect(name).To(Equal("eksctl-my-cluster-addon-aws-efs-csi-driver"))
Expect(resourceSet).NotTo(BeNil())
Expect(tags).To(Equal(map[string]string{
api.AddonNameTag: api.AWSEFSCSIDriverAddon,
}))
output, err := resourceSet.RenderJSON()
Expect(err).NotTo(HaveOccurred())
Expect(string(output)).To(ContainSubstring("PolicyEFSCSIController"))
Expect(*createAddonInput.ClusterName).To(Equal("my-cluster"))
Expect(*createAddonInput.AddonName).To(Equal(api.AWSEFSCSIDriverAddon))
Expect(*createAddonInput.AddonVersion).To(Equal("v1.0.0-eksbuild.1"))
Expect(*createAddonInput.ServiceAccountRoleArn).To(Equal("role-arn"))
})
})
})
})

Expand Down
1 change: 1 addition & 0 deletions pkg/apis/eksctl.io/v1alpha5/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@ const (
KubeProxyAddon = "kube-proxy"
CoreDNSAddon = "coredns"
AWSEBSCSIDriverAddon = "aws-ebs-csi-driver"
AWSEFSCSIDriverAddon = "aws-efs-csi-driver"
)

// supported version of Karpenter
Expand Down

0 comments on commit 299403d

Please sign in to comment.