-
Notifications
You must be signed in to change notification settings - Fork 1.6k
refactor how no backends are modeled in NLB / ALB Gateways #4273
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
refactor how no backends are modeled in NLB / ALB Gateways #4273
Conversation
930ca2f
to
895b54c
Compare
895b54c
to
0d2b9a3
Compare
0d2b9a3
to
ebefb4f
Compare
} | ||
backend := routeDescriptor.GetAttachedRules()[0].GetBackends()[0] | ||
|
||
if backend.Weight == 0 { |
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.
do we wanna check backend.Weight != nil here?
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.
This can't be nil. The route loader forces all nil
values to be 1 per Gateway API spec:
https://github.com/kubernetes-sigs/aws-load-balancer-controller/blob/main/pkg/gateway/routeutils/backend.go#L205-L219
// The criteria - | ||
// 1/ One or more target groups are present. | ||
// 2/ At least one target group has a weight greater than zero. | ||
func shouldProvisionActions(targetGroups []elbv2model.TargetGroupTuple) bool { |
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 might missed it, but where is this part being implemented?
"ALB - We special case all target groups having weight = 0, we will instead insert a 503 fixed response rule."
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.
actions are built here (IIF there are going to be target groups to send to)
aws-load-balancer-controller/pkg/gateway/model/model_build_listener.go
Lines 224 to 226 in ebefb4f
if shouldProvisionActions(targetGroupTuples) { | |
actions = buildL7ListenerForwardActions(targetGroupTuples, nil) | |
} |
when we generate no forward actions:
aws-load-balancer-controller/pkg/gateway/model/model_build_listener.go
Lines 242 to 245 in ebefb4f
if len(actions) == 0 { | |
l.logger.Info("Filling in no backend actions with fixed 503") | |
actions = buildL7ListenerNoBackendActions() | |
} |
/lgtm |
/lgtm /approved |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: shuqz, zac-nixon 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 |
Description
follow up from: #4267
Key changes:
1/ No longer filter out weight = 0 backends in the route builder. Instead, we let the model builder handle the backend depending on which LB type we are working with.
NLB -> Only 1 TG allowed in a Listener, don't provision listener when the TG has weight = 0
ALB -> Propagate all weight = 0 target groups. We special case all target groups having weight = 0, we will instead insert a 503 fixed response rule. HOWEVER, the target groups and targets are still provisioned meaning that customers don't need to re-provision these resources later.
2/ When an NLB / ALB Listener has no backends, we follow the same rules as outlined above.
I was able to manually test NLB and ALB. Further, I've updated the E2E tests to also test that the behavior I have described above is actually implemented.
I noticed that the ListenerRules builder had no UT, so I've gone ahead and created two basic ones for my own scenarios I have added.
Checklist
README.md
, or thedocs
directory)BONUS POINTS checklist: complete for good vibes and maybe prizes?! 🤯