Commit 50f3b50
committed
feat: Add configurable load balancing policy for Knative revisions
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.1 parent 86af837 commit 50f3b50
File tree
17 files changed
+700
-218
lines changed- config/core/300-resources
- docs
- pkg
- activator/net
- apis
- config
- serving
- v1
- autoscaler/metrics
- test/test_images/grpc-ping/proto
17 files changed
+700
-218
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
438 | 438 | | |
439 | 439 | | |
440 | 440 | | |
441 | | - | |
| 441 | + | |
442 | 442 | | |
443 | 443 | | |
444 | 444 | | |
| |||
606 | 606 | | |
607 | 607 | | |
608 | 608 | | |
609 | | - | |
| 609 | + | |
610 | 610 | | |
611 | 611 | | |
612 | 612 | | |
| |||
871 | 871 | | |
872 | 872 | | |
873 | 873 | | |
874 | | - | |
| 874 | + | |
875 | 875 | | |
876 | 876 | | |
877 | 877 | | |
| |||
1027 | 1027 | | |
1028 | 1028 | | |
1029 | 1029 | | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
1030 | 1036 | | |
1031 | 1037 | | |
1032 | 1038 | | |
| |||
1291 | 1297 | | |
1292 | 1298 | | |
1293 | 1299 | | |
1294 | | - | |
| 1300 | + | |
1295 | 1301 | | |
1296 | 1302 | | |
1297 | 1303 | | |
| |||
1314 | 1320 | | |
1315 | 1321 | | |
1316 | 1322 | | |
1317 | | - | |
| 1323 | + | |
1318 | 1324 | | |
1319 | 1325 | | |
1320 | 1326 | | |
| |||
1325 | 1331 | | |
1326 | 1332 | | |
1327 | 1333 | | |
1328 | | - | |
| 1334 | + | |
1329 | 1335 | | |
1330 | 1336 | | |
1331 | 1337 | | |
| |||
1335 | 1341 | | |
1336 | 1342 | | |
1337 | 1343 | | |
1338 | | - | |
| 1344 | + | |
1339 | 1345 | | |
1340 | 1346 | | |
1341 | 1347 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
414 | 414 | | |
415 | 415 | | |
416 | 416 | | |
417 | | - | |
| 417 | + | |
418 | 418 | | |
419 | 419 | | |
420 | 420 | | |
| |||
582 | 582 | | |
583 | 583 | | |
584 | 584 | | |
585 | | - | |
| 585 | + | |
586 | 586 | | |
587 | 587 | | |
588 | 588 | | |
| |||
847 | 847 | | |
848 | 848 | | |
849 | 849 | | |
850 | | - | |
| 850 | + | |
851 | 851 | | |
852 | 852 | | |
853 | 853 | | |
| |||
1003 | 1003 | | |
1004 | 1004 | | |
1005 | 1005 | | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
1006 | 1012 | | |
1007 | 1013 | | |
1008 | 1014 | | |
| |||
1267 | 1273 | | |
1268 | 1274 | | |
1269 | 1275 | | |
1270 | | - | |
| 1276 | + | |
1271 | 1277 | | |
1272 | 1278 | | |
1273 | 1279 | | |
| |||
1290 | 1296 | | |
1291 | 1297 | | |
1292 | 1298 | | |
1293 | | - | |
| 1299 | + | |
1294 | 1300 | | |
1295 | 1301 | | |
1296 | 1302 | | |
| |||
1301 | 1307 | | |
1302 | 1308 | | |
1303 | 1309 | | |
1304 | | - | |
| 1310 | + | |
1305 | 1311 | | |
1306 | 1312 | | |
1307 | 1313 | | |
| |||
1311 | 1317 | | |
1312 | 1318 | | |
1313 | 1319 | | |
1314 | | - | |
| 1320 | + | |
1315 | 1321 | | |
1316 | 1322 | | |
1317 | 1323 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
456 | 456 | | |
457 | 457 | | |
458 | 458 | | |
459 | | - | |
| 459 | + | |
460 | 460 | | |
461 | 461 | | |
462 | 462 | | |
| |||
624 | 624 | | |
625 | 625 | | |
626 | 626 | | |
627 | | - | |
| 627 | + | |
628 | 628 | | |
629 | 629 | | |
630 | 630 | | |
| |||
889 | 889 | | |
890 | 890 | | |
891 | 891 | | |
892 | | - | |
| 892 | + | |
893 | 893 | | |
894 | 894 | | |
895 | 895 | | |
| |||
1045 | 1045 | | |
1046 | 1046 | | |
1047 | 1047 | | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
1048 | 1054 | | |
1049 | 1055 | | |
1050 | 1056 | | |
| |||
1309 | 1315 | | |
1310 | 1316 | | |
1311 | 1317 | | |
1312 | | - | |
| 1318 | + | |
1313 | 1319 | | |
1314 | 1320 | | |
1315 | 1321 | | |
| |||
1332 | 1338 | | |
1333 | 1339 | | |
1334 | 1340 | | |
1335 | | - | |
| 1341 | + | |
1336 | 1342 | | |
1337 | 1343 | | |
1338 | 1344 | | |
| |||
1343 | 1349 | | |
1344 | 1350 | | |
1345 | 1351 | | |
1346 | | - | |
| 1352 | + | |
1347 | 1353 | | |
1348 | 1354 | | |
1349 | 1355 | | |
| |||
1353 | 1359 | | |
1354 | 1360 | | |
1355 | 1361 | | |
1356 | | - | |
| 1362 | + | |
1357 | 1363 | | |
1358 | 1364 | | |
1359 | 1365 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
948 | 948 | | |
949 | 949 | | |
950 | 950 | | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
951 | 965 | | |
952 | 966 | | |
953 | 967 | | |
| |||
1438 | 1452 | | |
1439 | 1453 | | |
1440 | 1454 | | |
| 1455 | + | |
| 1456 | + | |
| 1457 | + | |
| 1458 | + | |
| 1459 | + | |
| 1460 | + | |
| 1461 | + | |
| 1462 | + | |
| 1463 | + | |
| 1464 | + | |
| 1465 | + | |
| 1466 | + | |
| 1467 | + | |
| 1468 | + | |
1441 | 1469 | | |
1442 | 1470 | | |
1443 | 1471 | | |
| |||
1666 | 1694 | | |
1667 | 1695 | | |
1668 | 1696 | | |
| 1697 | + | |
| 1698 | + | |
| 1699 | + | |
| 1700 | + | |
| 1701 | + | |
| 1702 | + | |
| 1703 | + | |
| 1704 | + | |
| 1705 | + | |
| 1706 | + | |
| 1707 | + | |
| 1708 | + | |
| 1709 | + | |
| 1710 | + | |
1669 | 1711 | | |
1670 | 1712 | | |
1671 | 1713 | | |
| |||
0 commit comments