Skip to content

Commit 4591066

Browse files
committed
fix(addons): avoid infinite reconciliation loop
1 parent 9283e64 commit 4591066

File tree

3 files changed

+35
-6
lines changed

3 files changed

+35
-6
lines changed

pkg/cloud/services/eks/addons.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ func (s *Service) translateAPIToAddon(addons []ekscontrolplanev1.Addon) []*eksad
197197
convertedAddon := &eksaddons.EKSAddon{
198198
Name: &addon.Name,
199199
Version: &addon.Version,
200-
Configuration: &addon.Configuration,
200+
Configuration: convertConfiguration(addon.Configuration),
201201
Tags: ngTags(s.scope.Cluster.Name, s.scope.AdditionalTags()),
202202
ResolveConflict: convertConflictResolution(*addon.ConflictResolution),
203203
ServiceAccountRoleARN: addon.ServiceAccountRoleArn,
@@ -215,3 +215,10 @@ func convertConflictResolution(conflict ekscontrolplanev1.AddonResolution) *stri
215215
}
216216
return aws.String(eks.ResolveConflictsOverwrite)
217217
}
218+
219+
func convertConfiguration(configuration string) *string {
220+
if configuration == "" {
221+
return nil
222+
}
223+
return &configuration
224+
}

pkg/eks/addons/types.go

+1-5
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ package addons
1818

1919
import (
2020
"github.com/google/go-cmp/cmp"
21-
2221
infrav1 "sigs.k8s.io/cluster-api-provider-aws/v2/api/v1beta2"
2322
)
2423

@@ -36,7 +35,7 @@ type EKSAddon struct {
3635

3736
// IsEqual determines if 2 EKSAddon are equal.
3837
func (e *EKSAddon) IsEqual(other *EKSAddon, includeTags bool) bool {
39-
//NOTE: we do not compare the ARN as that is only for existing addons
38+
// NOTE: we do not compare the ARN as that is only for existing addons
4039
if e == other {
4140
return true
4241
}
@@ -49,9 +48,6 @@ func (e *EKSAddon) IsEqual(other *EKSAddon, includeTags bool) bool {
4948
if !cmp.Equal(e.Configuration, other.Configuration) {
5049
return false
5150
}
52-
if !cmp.Equal(e.ResolveConflict, other.ResolveConflict) {
53-
return false
54-
}
5551

5652
if includeTags {
5753
diffTags := e.Tags.Difference(other.Tags)

pkg/eks/addons/types_test.go

+26
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,32 @@ func TestAddOnEqual(t *testing.T) {
5454
},
5555
result: gomega.BeTrueBecause("addon values are equal (except status)"),
5656
},
57+
{
58+
orig: &EKSAddon{
59+
Version: ptr("a"),
60+
ServiceAccountRoleARN: ptr("b"),
61+
Configuration: nil,
62+
},
63+
other: &EKSAddon{
64+
Version: ptr("a"),
65+
ServiceAccountRoleARN: ptr("b"),
66+
Configuration: nil,
67+
},
68+
result: gomega.BeTrueBecause("addon values are equal with optional nil configuration"),
69+
},
70+
{
71+
orig: &EKSAddon{
72+
Version: ptr("a"),
73+
ServiceAccountRoleARN: ptr("b"),
74+
ResolveConflict: ptr("OVERWRITE"),
75+
},
76+
other: &EKSAddon{
77+
Version: ptr("a"),
78+
ServiceAccountRoleARN: ptr("b"),
79+
ResolveConflict: nil,
80+
},
81+
result: gomega.BeTrueBecause("addon values are equal with expected diff on resolve conflict"),
82+
},
5783
{
5884
orig: &EKSAddon{
5985
Version: ptr("a"),

0 commit comments

Comments
 (0)