-
Notifications
You must be signed in to change notification settings - Fork 578
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 creation of target groups and listeners in the reconcile loop #5017
Conversation
We were comparing pointers that were never going to be equal. Let's check their pointed-to values instead. Also added a break when the listener is found. Changed the `createdListeners` list to only include a listener if it was created. This list is currently not used for anything, so this change should have no impact.
We cannot compare target groups by name because every time we get the desired spec, it contains newly-generated random names. Instead, let's check that the prefixes match and that the port and protocol properties are the same.
Hi @r4f4. Thanks for your PR. I'm waiting for a kubernetes-sigs 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-sigs/prow repository. |
/ok-to-test |
I'm currently running the Openshift e2e on this fix. Will report back when I have results. |
/test pull-cluster-api-provider-aws-e2e |
/retest |
LGTM |
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.
/lgtm
@mtulio: changing LGTM is restricted to collaborators In response to this:
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-sigs/prow repository. |
All the openshift tests in this PR, except for one, reached a running cluster stage. In the job that failed, no duplicated target groups/listeners are created so the issue seems to be fixed. |
/retest |
/approve Holding until it passes e2e. Failures appear to be unrelated to this change, though. /assign @damdo |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: nrb The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/test pull-cluster-api-provider-aws-e2e |
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.
Matching the groups based on naming sounds like it could become a little fragile over time, for example if we ever decided to change the names.
Is there any reason not to go straight to checking the port and the type rather than relying on names?
What would happen if a manually created target group matched the spec but wasn't named correctly, would the cluster still function?
Yes. I tried to move the used prefixes to
I was discussing this with @mtulio. Ideally we would check the owned tag but I'm reluctant about adding even more API calls (one of the failures reasons we observed was API rate limitting). If it's acceptable that we might match target groups that were not created by CAPA, then we can check just port/type.
Then CAPA would create a new target group. As long as an associated listener doesn't exist for that port, it should work. If there is no listener, then the target group was not associated with the LB and CAPA wouldn't have discovered it in the first place. I haven't tested this though. |
/test pull-cluster-api-provider-aws-e2e |
Having discussed out of band, the current approach is better than what we have in main today, which is broken and has potential for leaking resources. I would like to see some more testing of the scenarios where users bring their own target groups or start modifying the target groups after the LB is created, but that needn't block this PR |
@@ -1604,8 +1615,9 @@ func (s *Service) reconcileTargetGroupsAndListeners(lbARN string, spec *infrav1. | |||
|
|||
var listener *elbv2.Listener | |||
for _, l := range existingListeners.Listeners { | |||
if l.DefaultActions != nil && len(l.DefaultActions) > 0 && l.DefaultActions[0].TargetGroupArn == group.TargetGroupArn { | |||
if l.DefaultActions != nil && len(l.DefaultActions) > 0 && *l.DefaultActions[0].TargetGroupArn == *group.TargetGroupArn { |
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.
According to https://docs.aws.amazon.com/sdk-for-go/api/service/elbv2/#ELBV2.CreateListener:
This operation is idempotent, which means that it completes at most one time. If you attempt to create multiple listeners with the same settings, each call succeeds.
So we could probably drop this check for an existing listener and always try createListener
.
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.
E2Es passed. The fix LGTM
Thanks @r4f4
/lgtm
/hold cancel |
What type of PR is this?
/kind bug
What this PR does / why we need it:
Fixes an error where capa will create duplicate target groups and listeners.
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Fixes #5015
Special notes for your reviewer:
Checklist:
Release note: