Skip to content

Commit

Permalink
Agent Management: Honor 503 ServiceUnavailable Retry-After header (#5249
Browse files Browse the repository at this point in the history
)

* 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
  • Loading branch information
jcreixell authored Sep 20, 2023
1 parent 4c083e0 commit d91ae42
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion pkg/config/remote_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit d91ae42

Please sign in to comment.