From ba7d572878f91de5589492f4eea00bd4749471e7 Mon Sep 17 00:00:00 2001 From: Roman Zavodskikh Date: Thu, 14 Mar 2024 10:28:48 +0100 Subject: [PATCH] Fix (*consistentHash).Apply Signed-off-by: Roman Zavodskikh --- loadbalancer/algorithm.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/loadbalancer/algorithm.go b/loadbalancer/algorithm.go index c98ceee40e..1c15520c85 100644 --- a/loadbalancer/algorithm.go +++ b/loadbalancer/algorithm.go @@ -199,8 +199,11 @@ func (ch *consistentHash) Apply(ctx *routing.LBContext) routing.LBEndpoint { return ctx.LBEndpoints[0] } + // The index returned from this call is taken from hash ring which is built from data about + // all endpoints, including fading in, unhealthy, etc. ones. The index stored in hash ring is + // the index of the endpoint in the original list of endpoints. choice := ch.chooseConsistentHashEndpoint(ctx) - return ctx.LBEndpoints[choice] + return ctx.Route.LBEndpoints[choice] } func (ch *consistentHash) chooseConsistentHashEndpoint(ctx *routing.LBContext) int {