Skip to content

Conversation

delinak
Copy link
Contributor

@delinak delinak commented Feb 28, 2025

Issue #2349

Added update logic of tags in the load_balancer resource for elbv2-controller.
Supported tags for other elbv2-controller resources: listener, rule, and target_group.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@ack-prow ack-prow bot requested review from a-hilaly and michaelhtm February 28, 2025 21:15
Copy link

ack-prow bot commented Feb 28, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: delinak
Once this PR has been reviewed and has the lgtm label, please assign a-hilaly for approval by writing /assign @a-hilaly in a comment. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ack-prow ack-prow bot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Feb 28, 2025
Copy link

ack-prow bot commented Feb 28, 2025

Hi @delinak. Thanks for your PR.

I'm waiting for a aws-controllers-k8s member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Copy link
Member

@michaelhtm michaelhtm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @delinak,
Thanks for the contribution!! 🚀 🚀
Left a few inline comments.
Also a nit: would you be able to separate out these changes and make one PR per resource?


rm.setStatusDefaults(ko)
if ko.Spec.Tags != nil {
return nil, ackrequeue.NeededAfter(fmt.Errorf("Requing due to tags in CREATE"), RequeueAfterUpdateDuration)
Copy link
Member

@michaelhtm michaelhtm Mar 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: rename RequeueAfterUpdateDuration to RequeueAfterDuration
Since it's not being specifically used after an UpdateCall

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same for the other RequeueAfterUpdateDuration's

return nil, err
}
}
if !delta.DifferentAt("Spec.Tags") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if !delta.DifferentAt("Spec.Tags") {
if !delta.DifferentExcept("Spec.Tags") {

return tags.GetResourceTags(ctx, rm.sdkapi, rm.metrics, resourceARN )
}

func (rm *resourceManager) updateTags(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where is this used?

Comment on lines +28 to +32
var (
_ = svcapitypes.Tag{}
_ = acktags.NewTags()
ACKSystemTags = []string{"services.k8s.aws/namespace", "services.k8s.aws/controller-version"}
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure if this is needed here

Comment on lines +127 to +144
mainLoop:
for _, aElement := range a {
visitedIndexes = append(visitedIndexes, *aElement.Key)
for _, bElement := range b {
if equalStrings(aElement.Key, bElement.Key) {
if !equalStrings(aElement.Value, bElement.Value) {
addedOrUpdated = append(addedOrUpdated, bElement)
}
continue mainLoop
}
}
removed = append(removed, *aElement.Key)
}
for _, bElement := range b {
if !ackutil.InStrings(*bElement.Key, visitedIndexes) {
addedOrUpdated = append(addedOrUpdated, bElement)
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I know we have examples in ACK that uses this method, but I have since learned that readability and maintainability is something i wanted to pay more attention to, especially in these cases.

Here's an example i try to follow, feel free to implement it, or not :)

@@ -0,0 +1,3 @@
if desired.ko.Spec.Tags != nil {
return nil, ackrequeue.NeededAfter(fmt.Errorf("Requing due to tags in UPDATE"), RequeueAfterUpdateDuration)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return nil, ackrequeue.NeededAfter(fmt.Errorf("Requing due to tags in UPDATE"), RequeueAfterUpdateDuration)
return nil, ackrequeue.NeededAfter(fmt.Errorf("Requeuing to sync tags in UPDATE"), RequeueAfterUpdateDuration)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto for others below

@@ -0,0 +1 @@
Spec.Tags, err = rm.getTags(ctx, string(*ko.Status.ACKResourceMetadata.ARN)) No newline at end of file
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i see a diff between this and the line in listner/sdk.go..

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto for other resources

Comment on lines +22 to +27
if delta.DifferentAt("Spec.Priority") {
if err = rm.setRulePriority(ctx, desired); err != nil {
return nil, err
}
} else if !delta.DifferentExcept("Spec.Priority") {
return desired, nil
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are we also supporting Priority updates?

Comment on lines +1 to +9
if delta.DifferentAt("Spec.Tags") {
err = rm.updateTags(ctx, desired, latest)
if err != nil {
return nil, err
}
}
if !delta.DifferentAt("Spec.Tags") {
return desired, nil
} No newline at end of file
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems like this is not needed since it's written in hooks.go

@ack-bot
Copy link
Collaborator

ack-bot commented Aug 30, 2025

Issues go stale after 180d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 60d of inactivity and eventually close.
If this issue is safe to close now please do so with /close.
Provide feedback via https://github.com/aws-controllers-k8s/community.
/lifecycle stale

@ack-prow ack-prow bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Aug 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants