Skip to content

Commit 4b1ee0f

Browse files
authored
fix(network_acl): Preserve desired entries order after update (#208)
This patch addresses an issue where the EC2 API may return entries in a different order than specified. Causing the controller to go change the desired state spec. Now, after updating the NACL, we fetch the latest resource status but we preserve the order of entries. By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 39a6d3b commit 4b1ee0f

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

pkg/resource/network_acl/hooks.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,6 @@ func (rm *resourceManager) customUpdateNetworkAcl(
4141
exit := rlog.Trace("rm.customUpdateNetworkAcl")
4242
defer func(err error) { exit(err) }(err)
4343

44-
// Default `updated` to `desired` because it is likely
45-
// EC2 `modify` APIs do NOT return output, only errors.
46-
// If the `modify` calls (i.e. `sync`) do NOT return
47-
// an error, then the update was successful and desired.Spec
48-
// (now updated.Spec) reflects the latest resource state.
4944
updated = rm.concreteResource(desired.DeepCopy())
5045

5146
if delta.DifferentAt("Spec.Tags") {
@@ -68,11 +63,17 @@ func (rm *resourceManager) customUpdateNetworkAcl(
6863
return nil, err
6964
}
7065
}
71-
updated, err = rm.sdkFind(ctx, desired)
66+
67+
latestResource, err := rm.sdkFind(ctx, desired)
7268
if err != nil {
7369
return nil, err
7470
}
7571

72+
// The ec2 API can sometimes sort the entries in a different order than the
73+
// ones we have in the desired spec. Hence, we need to conserve the order of
74+
// entries in the desired spec.
75+
updated.ko.Status = latestResource.ko.Status
76+
7677
return updated, nil
7778
}
7879

0 commit comments

Comments
 (0)