Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(network_acl): Preserve desired entries order after update #208

Merged
merged 1 commit into from
Aug 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions pkg/resource/network_acl/hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,6 @@ func (rm *resourceManager) customUpdateNetworkAcl(
exit := rlog.Trace("rm.customUpdateNetworkAcl")
defer func(err error) { exit(err) }(err)

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

if delta.DifferentAt("Spec.Tags") {
Expand All @@ -68,11 +63,17 @@ func (rm *resourceManager) customUpdateNetworkAcl(
return nil, err
}
}
updated, err = rm.sdkFind(ctx, desired)

latestResource, err := rm.sdkFind(ctx, desired)
if err != nil {
return nil, err
}

// The ec2 API can sometimes sort the entries in a different order than the
// ones we have in the desired spec. Hence, we need to conserve the order of
// entries in the desired spec.
updated.ko.Status = latestResource.ko.Status

return updated, nil
}

Expand Down