Configurable Load Balancing
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.
[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.
Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment
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.
Codecov Report
:x: Patch coverage is 89.67391% with 19 lines in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 80.15%. Comparing base (083ce78) to head (a404914).
:warning: 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 :warning: |
| pkg/apis/serving/metadata_validation.go | 0.00% | 8 Missing :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## main #16082 +/- ##
==========================================
+ Coverage 80.05% 80.15% +0.09%
==========================================
Files 214 214
Lines 16940 17072 +132
==========================================
+ Hits 13562 13684 +122
- Misses 3018 3029 +11
+ Partials 360 359 -1
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
/retest
@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.
/ok-to-test
There are empty aliases in OWNER_ALIASES, cleanup is advised.
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.
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
mainto simplify the diff.
can do
/retest
The committers listed above are authorized under a signed CLA.
- :white_check_mark: login: elijah-rou / name: Elijah Roussos (0fb7c3f332d32e9915a302d9a1c5c89727e03867, 21fa299eca97646f5395cd2b3189fe9e632baa39, 36e87657b23acbc686140a0e6a0c110a9ee6460f, 42183b789a6fe66d8791435e6edd2d241b0b11d0, 4c5c6d867d252ee047a16bbc9829d53dbde7fffa, 50f3b5007fe0340bec2f541f8139045b9e1eed77, 5d4f7ec588be8124bc32d55d910cc41e42f7599f, 60fa3b48db17747bbe9a18f4f7bfff159090812e, 6b6c31297604031d7019775685688635a7bc3c3c, 812bb174dfdbd66f2b6612035aa674fbed5a87a9, 95de31a3ab9c1539932cdf3991af1c7e4855880b, a404914f0ad2c645ce384e9b5f0f8062e9c6cad8, cdc62085c0876101432536f00e55feb466ce762d, fc2fb37fb0f86aec5156a808db402635621bbd4a)
- :white_check_mark: login: knative-automation / name: Knative Automation (7dd5de567ff7b9469094d001c23714c5bcaeba1f, 86af8375e4e89918a29e13fa397bdb3237df02ab, 9dc7804bb0bfc525e5f6cdf0a8ea9b087c6d4a2c)
/retest-required