Skip to content

Conversation

elijah-rou
Copy link
Contributor

This commit implements configurable load balancing policy.

  • Add LoadBalancingPolicy field to RevisionSpec in v1 API

  • Support policies: random-choice-2, round-robin, least-connections, first-available

  • Add validation for LoadBalancingPolicy in revision validation

  • Update CRD definitions for Configuration, Revision, and Service resources

  • Add validateLoadBalancingPolicy() to validate policy strings

  • Add pickLBPolicy() to select appropriate LB policy based on configuration

  • Convert lbPolicy and containerConcurrency to atomic types for thread-safe updates

  • Implement dynamic policy updates via revisionUpdated() method

  • Default policy selection based on container concurrency:

    • CC=0: random-choice-2
    • CC=1-3: first-available
    • CC>3: round-robin
  • Fix leastConnectionsPolicy to use weight field instead of removed InFlight()

  • Add nil-safety checks to randomLBPolicy

  • Maintain existing policy implementations with minor safety improvements

  • Add LoadBalancingPolicy to defaults configuration

  • Update generated deepcopy methods for new field

  • Add TestLoadBalancingPolicySelection for policy selection logic

  • Add TestThrottlerUsesRevisionLoadBalancingPolicy for revision-level policies

  • Add TestDynamicLoadBalancingPolicyUpdate for runtime policy changes

  • Fix type mismatches (int32 vs uint32) in weight comparisons

  • Remove unused imports and variables

  • Maintain backward compatibility with existing pod tracking tests

  • Update serving-api.md with LoadBalancingPolicy field documentation

This change enables users to configure load balancing behavior per revision.

Copy link

knative-prow bot commented Sep 12, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: elijah-rou
Once this PR has been reviewed and has the lgtm label, please assign dprotaso for approval. For more information see the 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

@knative-prow-robot knative-prow-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 12, 2025
@knative-prow knative-prow bot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Sep 12, 2025
Copy link

knative-prow bot commented Sep 12, 2025

Hi @elijah-rou. Thanks for your PR.

I'm waiting for a knative 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-sigs/prow repository.

@knative-prow knative-prow bot requested review from dsimansk and skonto September 12, 2025 15:25
@elijah-rou elijah-rou force-pushed the feat/configurable-lbpolicy branch 2 times, most recently from ec52658 to bd81542 Compare September 12, 2025 15:39
@knative-prow-robot knative-prow-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 12, 2025
Copy link

codecov bot commented Sep 12, 2025

Codecov Report

❌ Patch coverage is 89.67391% with 19 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.20%. Comparing base (1ffe339) to head (b3a7a3b).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
pkg/activator/net/throttler.go 89.52% 5 Missing and 6 partials ⚠️
pkg/apis/serving/metadata_validation.go 0.00% 8 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #16082      +/-   ##
==========================================
+ Coverage   80.04%   80.20%   +0.16%     
==========================================
  Files         214      214              
  Lines       16887    17019     +132     
==========================================
+ Hits        13517    13650     +133     
- Misses       3008     3010       +2     
+ Partials      362      359       -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@elijah-rou
Copy link
Contributor Author

/retest

Copy link

knative-prow bot commented Sep 12, 2025

@elijah-rou: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/retest

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.

@elijah-rou elijah-rou force-pushed the feat/configurable-lbpolicy branch 2 times, most recently from 9496641 to 6ed9891 Compare September 12, 2025 18:49
@dprotaso
Copy link
Member

/ok-to-test

@knative-prow knative-prow bot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Sep 15, 2025
@knative-prow-robot knative-prow-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 16, 2025
@elijah-rou elijah-rou force-pushed the feat/configurable-lbpolicy branch from 6ed9891 to 4c6c42a Compare September 30, 2025 16:47
@knative-prow-robot knative-prow-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 30, 2025
Copy link

knative-prow bot commented Sep 30, 2025

There are empty aliases in OWNER_ALIASES, cleanup is advised.

@dprotaso
Copy link
Member

dprotaso commented Oct 1, 2025

Rather than bake this into the revision spec I think it would be more simpler to experiment using an annotation on the revision.

Also the diff has all the excess commits. I would suggest rebasing this on main to simplify the diff.

@elijah-rou
Copy link
Contributor Author

Rather than bake this into the revision spec I think it would be more simpler to experiment using an annotation on the revision.

Also the diff has all the excess commits. I would suggest rebasing this on main to simplify the diff.

can do

knative-automation and others added 6 commits October 2, 2025 11:57
bumping knative.dev/hack f88b7db...af735b2:
  > af735b2 Fix dot releases (# 434)

Signed-off-by: Knative Automation <[email protected]>
This commit implements configurable load balancing policy.

- Add LoadBalancingPolicy field to RevisionSpec in v1 API
- Support policies: random-choice-2, round-robin, least-connections,
first-available
- Add validation for LoadBalancingPolicy in revision validation
- Update CRD definitions for Configuration, Revision, and Service
resources

- Add validateLoadBalancingPolicy() to validate policy strings
- Add pickLBPolicy() to select appropriate LB policy based on
configuration
- Convert lbPolicy and containerConcurrency to atomic types for
thread-safe updates
- Implement dynamic policy updates via revisionUpdated() method
- Default policy selection based on container concurrency:
  - CC=0: random-choice-2
  - CC=1-3: first-available
  - CC>3: round-robin

- Fix leastConnectionsPolicy to use weight field instead of removed
InFlight()
- Add nil-safety checks to randomLBPolicy
- Maintain existing policy implementations with minor safety
improvements

- Add LoadBalancingPolicy to defaults configuration
- Update generated deepcopy methods for new field

- Add TestLoadBalancingPolicySelection for policy selection logic
- Add TestThrottlerUsesRevisionLoadBalancingPolicy for revision-level
policies
- Add TestDynamicLoadBalancingPolicyUpdate for runtime policy changes
- Fix type mismatches (int32 vs uint32) in weight comparisons
- Remove unused imports and variables
- Maintain backward compatibility with existing pod tracking tests

- Update serving-api.md with LoadBalancingPolicy field documentation

This change enables users to configure load balancing behavior per
revision.
@elijah-rou elijah-rou force-pushed the feat/configurable-lbpolicy branch from ebd3fef to 8a7e201 Compare October 2, 2025 15:57
@elijah-rou
Copy link
Contributor Author

/retest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants