-
Notifications
You must be signed in to change notification settings - Fork 10
Tags support for elbv2-controller resources #42
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
base: main
Are you sure you want to change the base?
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: delinak 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 |
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 Once the patch is verified, the new status will be reflected by the 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. |
There was a problem hiding this 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) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if !delta.DifferentAt("Spec.Tags") { | |
if !delta.DifferentExcept("Spec.Tags") { |
return tags.GetResourceTags(ctx, rm.sdkapi, rm.metrics, resourceARN ) | ||
} | ||
|
||
func (rm *resourceManager) updateTags( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where is this used?
var ( | ||
_ = svcapitypes.Tag{} | ||
_ = acktags.NewTags() | ||
ACKSystemTags = []string{"services.k8s.aws/namespace", "services.k8s.aws/controller-version"} | ||
) |
There was a problem hiding this comment.
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
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) | ||
} | ||
} |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) | |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto for other resources
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 |
There was a problem hiding this comment.
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?
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 |
There was a problem hiding this comment.
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
Issues go stale after 180d of inactivity. |
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.