Skip to content

fix(oci): retry transient token requests - #281

Open
abhinavgautam01 wants to merge 2 commits into
git-pkgs:mainfrom
abhinavgautam01:fix/docker-hub-auth-retry-266
Open

fix(oci): retry transient token requests#281
abhinavgautam01 wants to merge 2 commits into
git-pkgs:mainfrom
abhinavgautam01:fix/docker-hub-auth-retry-266

Conversation

@abhinavgautam01

Copy link
Copy Markdown
Contributor

Summary

Fixes #266.

  • Retry OCI Bearer-token requests after transient network and DNS failures.
  • Retry rate-limited (429) and server-error (5xx) token responses.
  • Use bounded exponential backoff: 500ms, 1s and 2s.
  • Respect request cancellation and deadlines while waiting to retry.
  • Avoid retrying permanent token failures such as invalid credentials (401).
  • Add regression coverage for temporary DNS failures and permanent authentication failures.

Validation

  • gofmt
  • go tool golangci-lint run ./...
  • go vet ./...
  • go test -race ./...
  • git diff --check

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves OCI/Docker registry authentication robustness by adding retry logic around bearer-token acquisition, aiming to mitigate transient network/DNS failures and certain retryable HTTP responses, with accompanying regression tests.

Changes:

  • Add bounded exponential backoff retries for token fetch on transient request failures and on 429 / 5xx responses.
  • Refactor token response handling into helpers (decodeTokenResponse, tokenResponseError) and add retry decision helpers.
  • Add tests covering temporary DNS failures (retry) and permanent auth failures (no retry).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
internal/httpclient/transport.go Implements token-request retry loop with backoff, plus helper functions for decoding/errors and retry decisions.
internal/httpclient/transport_test.go Adds regression tests verifying retries on temporary DNS failures and no retries on 401 responses.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread internal/httpclient/transport.go
Comment thread internal/httpclient/transport_test.go Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a Docker Hub authentication retry loop for Docker

2 participants