Adding support for traffic shaping for more than one alternative backends
What this PR does / why we need it:
This PR enhances the ingress-nginx balancer functionality by adding support for multiple alternative backends. Currently, the balancer can only use one alternative backend, but this change allows defining multiple alternative backends and selecting the first suitable one based on request context.
Types of changes
-
New feature (non-breaking change which adds functionality)
How Has This Been Tested?
- Updated existing unit tests in
balancer_test.luato cover the new functionality - Added comprehensive tests for multiple alternative backends scenarios
- Verified that all existing tests pass with the modified implementation
- Tested various scenarios including canary deployments with cookies, headers, and weights
Checklist:
-
I have updated the documentation accordingly. -
I've read the CONTRIBUTION guide -
I have added unit and/or e2e tests to cover my changes. -
All new and existing tests passed.
Key Changes:
- Replaced
route_to_alternative_balancerwithis_alternative_backend_suitableandget_alternative_or_original_balancer - Added support for multiple alternative backends in
alternative_backendslist - Maintained backward compatibility with existing configurations
- Simplified the
get_balancerfunction logic