Skip to content

c8d/integration-cli: Adjust DockerRegistryAuthTokenSuite#46865

Merged
thaJeztah merged 1 commit intomoby:masterfrom
vvoland:c8d-fix-DockerRegistryAuthTokenSuite
Nov 30, 2023
Merged

c8d/integration-cli: Adjust DockerRegistryAuthTokenSuite#46865
thaJeztah merged 1 commit intomoby:masterfrom
vvoland:c8d-fix-DockerRegistryAuthTokenSuite

Conversation

@vvoland
Copy link
Contributor

@vvoland vvoland commented Nov 29, 2023

The auth service error response is not a part of the spec and containerd doesn't parse it like the Docker's distribution does.

Check for containerd specific errors instead.

- What I did

- How I did it

- How to verify it
See DockerRegistryAuthTokenSuite suite in CI.

- Description for the changelog

- A picture of a cute animal (not mandatory but encouraged)

@vvoland vvoland added status/2-code-review area/testing containerd-integration Issues and PRs related to containerd integration labels Nov 29, 2023
@vvoland vvoland added this to the 25.0.0 milestone Nov 29, 2023
@vvoland vvoland self-assigned this Nov 29, 2023
The auth service error response is not a part of the spec and containerd
doesn't parse it like the Docker's distribution does.

Check for containerd specific errors instead.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
@vvoland vvoland force-pushed the c8d-fix-DockerRegistryAuthTokenSuite branch from 3c32515 to e262cd3 Compare November 29, 2023 13:28
// Auth service errors are not part of the spec and containerd doesn't parse them.
if testEnv.UsingSnapshotter() {
assert.Check(c, is.Contains(out, "failed to authorize: failed to fetch anonymous token"))
assert.Check(c, is.Contains(out, "503 Service Unavailable"))
Copy link
Member

Choose a reason for hiding this comment

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

Still curious; is 503 the correct response for this? If this is docker hub returning it, I wonder if that should've been a 4XX (e.g. 429 https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429)

Copy link
Member

Choose a reason for hiding this comment

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

We're using our test server for this, but curious if it reflects what docker hub returns;

func getTestTokenService(status int, body string, retries int) *httptest.Server {
var mu sync.Mutex
return httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
mu.Lock()
if retries > 0 {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusServiceUnavailable)
w.Write([]byte(`{"errors":[{"code":"UNAVAILABLE","message":"cannot create token at this time"}]}`))
retries--

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, because that test server returns TOOMANYREQUESTS after the 3 tries (which give UNAVAILABLE).
Containerd doesn't do the retry and it fails fast with the UNAVAILABLE and doesn't reach the TOOMANYREQUESTS.

Copy link
Member

Choose a reason for hiding this comment

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

Wondering now if the retry was added to account for "cron-jobs" (I recall some threads about some hours being notable for cron-jobs hammering Docker Hub, which may cause brief moments where services can return a 503).

Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

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

LGTM

let's not block this, because this matches current reality (but we can continue discussing if we want to make improvements / changes in containerd's handling of these auth requests, to match the old implementation)

@thaJeztah thaJeztah merged commit 75546e1 into moby:master Nov 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/testing containerd-integration Issues and PRs related to containerd integration status/2-code-review

Projects

Development

Successfully merging this pull request may close these issues.

4 participants