Skip to content

fix: Per-route load balancing algorithm not reverting to platform default on removal#552

Merged
hoffmaen merged 6 commits intocloudfoundry:developfrom
sap-contributions:fix-pool-lb-algorithm-reset
Apr 13, 2026
Merged

fix: Per-route load balancing algorithm not reverting to platform default on removal#552
hoffmaen merged 6 commits intocloudfoundry:developfrom
sap-contributions:fix-pool-lb-algorithm-reset

Conversation

@hoffmaen
Copy link
Copy Markdown
Contributor

@hoffmaen hoffmaen commented Apr 9, 2026

Summary

Fixes the bug where removing a per-route load balancing algorithm (e.g., via cf update-route -r loadbalancing) left the pool using the old algorithm instead of reverting to the platform default. Fixes #551

Changes

  • Default the endpoint's load balancing algorithm to the global platform algorithm (config.LoadBalance) in mbus/subscriber.go; only override when the NATS message contains a non-empty value
  • Clean up hash-based routing state (HashLookupTable, HashRoutingProperties) in EndpointPool.setPoolLoadBalancingAlgorithm when switching away from hash-based routing

Backward Compatibility

Breaking Change? No

Note on AI usage

Parts of this code and tests were developed with assistance from Claude Code (claude-opus-4-20250514).

…-route algorithm is removed

When a per-route load balancing algorithm (e.g. hash-based) was removed,
the pool retained the old algorithm because setPoolLoadBalancingAlgorithm
ignored empty values. This fix distinguishes between "field absent" (no
change) and "field explicitly empty" (reset to default) by using a
*string in the NATS message struct and a sentinel value LOAD_BALANCE_DEFAULT.
hoffmaen and others added 2 commits April 10, 2026 14:05
Co-authored-by: Tamara Boehm <tamara.boehm@sap.com>
@hoffmaen hoffmaen marked this pull request as ready for review April 10, 2026 13:09
@hoffmaen hoffmaen requested a review from a team as a code owner April 10, 2026 13:09
hoffmaen and others added 2 commits April 13, 2026 11:42
Both absent and empty string values in the NATS message produce the
same result (default to platform algorithm), so the pointer type
distinction is unnecessary. The *string type will be re-introduced
on the endpoints-per-pool branch where the nil vs empty distinction
is needed for metric optimization.

Co-authored-by: Tamara Boehm <tamara.boehm@sap.com>
…ngAlgorithm

With the simplified string type for LoadBalancingAlgorithm, makeEndpoint
always sets the algorithm to either globalRoutingAlgo or the explicit
per-route value. The empty-string case is unreachable on this branch.

Co-authored-by: Tamara Boehm <tamara.boehm@sap.com>
b1tamara
b1tamara previously approved these changes Apr 13, 2026
Copy link
Copy Markdown
Contributor

@b1tamara b1tamara left a comment

Choose a reason for hiding this comment

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

LGTM

@github-project-automation github-project-automation bot moved this from Inbox to Pending Merge | Prioritized in Application Runtime Platform Working Group Apr 13, 2026
@hoffmaen hoffmaen merged commit 34c3f9d into cloudfoundry:develop Apr 13, 2026
1 check passed
@github-project-automation github-project-automation bot moved this from Pending Merge | Prioritized to Done in Application Runtime Platform Working Group Apr 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

Per-route load balancing algorithm is not reset to platform default when removed from a route

2 participants