Treat 501 responses as non-fatal in cluster failover (#449)
This commit is contained in:
parent
13e2577c57
commit
f8b6aa6c97
1 changed files with 29 additions and 0 deletions
|
|
@ -515,6 +515,16 @@ func (cc *ClusterClient) executeWithFailover(ctx context.Context, fn func(*Clien
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if isNotImplementedError(errStr) {
|
||||||
|
// Endpoint not implemented on this node/version; bubble up without marking it unhealthy
|
||||||
|
log.Debug().
|
||||||
|
Str("cluster", cc.name).
|
||||||
|
Str("endpoint", clientEndpoint).
|
||||||
|
Err(err).
|
||||||
|
Msg("Endpoint not implemented, not marking cluster node unhealthy")
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
if isRateLimited, statusCode := isTransientRateLimitError(err); isRateLimited {
|
if isRateLimited, statusCode := isTransientRateLimitError(err); isRateLimited {
|
||||||
backoff := calculateRateLimitBackoff(i)
|
backoff := calculateRateLimitBackoff(i)
|
||||||
cc.applyRateLimitCooldown(clientEndpoint, backoff)
|
cc.applyRateLimitCooldown(clientEndpoint, backoff)
|
||||||
|
|
@ -628,6 +638,25 @@ func extractStatusCode(errStr string) int {
|
||||||
return code
|
return code
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func isNotImplementedError(errStr string) bool {
|
||||||
|
lower := strings.ToLower(errStr)
|
||||||
|
if !strings.Contains(lower, "not implemented") {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// Common formatting: "status 501", "error 501", "api error 501"
|
||||||
|
if strings.Contains(lower, " 501") || strings.Contains(lower, "status 501") || strings.Contains(lower, "error 501") {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fallback to explicit HTTP status detection
|
||||||
|
if extractStatusCode(errStr) == 501 {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
// GetHealthStatus returns the health status of all nodes
|
// GetHealthStatus returns the health status of all nodes
|
||||||
func (cc *ClusterClient) GetHealthStatus() map[string]bool {
|
func (cc *ClusterClient) GetHealthStatus() map[string]bool {
|
||||||
cc.mu.RLock()
|
cc.mu.RLock()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue