Skip to content

Conversation

zac-nixon
Copy link
Collaborator

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

  • Added tests that cover your change (if possible)
  • Added/modified documentation as required (such as the README.md, or the docs directory)
  • Manually tested
  • Made sure the title of the PR is a good description that can go into the release notes

BONUS POINTS checklist: complete for good vibes and maybe prizes?! 🤯

  • Backfilled missing tests for code in same general area 🎉
  • Refactored something and made the world a better place 🌟

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jul 22, 2025
@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 22, 2025
@zac-nixon zac-nixon force-pushed the znixon/refactor-missing-backends branch from 930ca2f to 895b54c Compare July 22, 2025 19:48
@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jul 22, 2025
@zac-nixon zac-nixon force-pushed the znixon/refactor-missing-backends branch from 895b54c to 0d2b9a3 Compare July 22, 2025 19:58
@zac-nixon zac-nixon force-pushed the znixon/refactor-missing-backends branch from 0d2b9a3 to ebefb4f Compare July 22, 2025 23:28
}
backend := routeDescriptor.GetAttachedRules()[0].GetBackends()[0]

if backend.Weight == 0 {
Copy link
Collaborator

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?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

// 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 {
Copy link
Collaborator

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."

Copy link
Collaborator Author

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)

if shouldProvisionActions(targetGroupTuples) {
actions = buildL7ListenerForwardActions(targetGroupTuples, nil)
}

when we generate no forward actions:

if len(actions) == 0 {
l.logger.Info("Filling in no backend actions with fixed 503")
actions = buildL7ListenerNoBackendActions()
}

@shraddhabang
Copy link
Collaborator

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 23, 2025
@shuqz
Copy link
Collaborator

shuqz commented Jul 23, 2025

/lgtm /approved

@k8s-ci-robot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot merged commit 2f5aed0 into kubernetes-sigs:main Jul 23, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants