Files
traefikoidc/cmd
lukaszraczyloandGitHub f7b96344e4 fix(metadata): retry discovery HTTP errors and recover in the background (#169)
A provider behind the same Traefik answers 404 while its router is not
loaded, and 502 or 503 while it restarts. GetProviderMetadata returned
these statuses as a plain error, so the startup retries stopped at the
first attempt. After that, nothing retried until a request arrived, and
that request got the 503 page (#147).

- GetProviderMetadata returns a non-200 status as *HTTPError, so the
  startup retries apply to 429 and 5xx.
- RetryConfig gets RetryableStatusCodes. MetadataFetchRetryConfig sets
  it to 404, so only discovery retries a 404.
- If startup discovery fails, the init goroutine retries in the
  background (5 s, doubling up to 60 s, with jitter). It stops when
  metadata is adopted or when Close cancels the instance context.
- GetMetadataWithRecovery takes a context, so Close also ends the
  startup retries.
- Background attempts log at ERROR for the first three and every tenth,
  at DEBUG otherwise. A document with no usable issuer does not end
  recovery. A Close during the startup retries logs at DEBUG only.
- The 503 served while metadata is unavailable or initialization times
  out carries Retry-After: 10, and the startup error log names the
  middleware.

TestMetadataRecoveryOnProviderFailure and the issue152 cold-start test
now serve 400 for a failed discovery, because startup retries 500 and
503 and these tests need init to fail at once.
2026-11-21 04:42:32 +00:00
..