Skip to content

Fix bounded consistent hash with filtered endpoints#4138

Open
shrikant23codes wants to merge 1 commit into
zalando:masterfrom
shrikant23codes:fix/consistent-hashing-routing-filters
Open

Fix bounded consistent hash with filtered endpoints#4138
shrikant23codes wants to merge 1 commit into
zalando:masterfrom
shrikant23codes:fix/consistent-hashing-routing-filters

Conversation

@shrikant23codes

@shrikant23codes shrikant23codes commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Fix boundedLoadSearch so it advances to the next hash ring entry when the current endpoint has been filtered out. Filtered endpoints can happen before load balancing, for example through fade-in.

In bounded-load mode, the algorithm starts from the normal consistent-hash target. If that endpoint is overloaded, it walks forward in the hash ring looking for another endpoint below the load threshold.

Before this change, if the walk reached a filtered endpoint, the loop continued without advancing the ring index. This could repeatedly check the same filtered endpoint and eventually return it.

Example case:

Route endpoints: [A, B, C]
Candidate endpoints: [A, C]    // B was filtered out

Hash ring walk:  A -> B -> C

- A is selected by consistent hash but is overloaded.
- The algorithm moves to B.
- B is not in the candidate list, so it should be skipped.
- Previously the ring index was not advanced when skipping B.

With this change, the algorithm advances to C.

Tests

go test ./loadbalancer -run TestConsistentHashBoundedLoadSearchSkipsFilteredEndpoints
go test ./loadbalancer

Suggested label: bug
Fixes: #4139

Signed-off-by: shrikant23codes <jiturishrikant@gmail.com>

@MustafaSaber MustafaSaber left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks, nice catch!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Bug fixes and patches

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix bounded consistent hash with filtered endpoints

2 participants