From d91ae42874d6f9f45d1e0f7a006842c734f004aa Mon Sep 17 00:00:00 2001 From: Jorge Creixell Date: Wed, 20 Sep 2023 10:05:52 +0200 Subject: [PATCH] Agent Management: Honor 503 ServiceUnavailable Retry-After header (#5249) * Agent Management: Honor 503 ServiceUnavailable Retry-After header - In addition to 429 TooManyRequests, remote servers may return 503 ServiceUnavailable with a `Retry-After` header. This allows overloaded servers to apply backpressure for a quick recovery. * Update CHANGELOG --- CHANGELOG.md | 2 ++ pkg/config/remote_config.go | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d42b1f485b2f..63ffba2d61b8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -85,6 +85,8 @@ Main (unreleased) `otelcol.exporter.otlp` and `otelcol.processor.batch`. There may also be metrics from other components which are not documented yet. (@ptodev) +- Agent Management: Honor 503 ServiceUnavailable `Retry-After` header. (@jcreixell) + ### Other changes - Use Go 1.21.1 for builds. (@rfratto) diff --git a/pkg/config/remote_config.go b/pkg/config/remote_config.go index 6d8637939487..aec0d9abe3df 100644 --- a/pkg/config/remote_config.go +++ b/pkg/config/remote_config.go @@ -112,7 +112,7 @@ func (p httpProvider) retrieve() ([]byte, error) { instrumentation.InstrumentRemoteConfigFetch(response.StatusCode) - if response.StatusCode == http.StatusTooManyRequests { + if response.StatusCode == http.StatusTooManyRequests || response.StatusCode == http.StatusServiceUnavailable { retryAfter := response.Header.Get("Retry-After") if retryAfter == "" { return nil, fmt.Errorf("server indicated to retry, but no Retry-After header was provided")