From 81402e47583bfce47f4924968c7164a7d2392ba3 Mon Sep 17 00:00:00 2001 From: Lantao Liu Date: Mon, 3 May 2021 17:42:57 -0700 Subject: [PATCH] Fix different registry hosts referencing the same auth config. Signed-off-by: Lantao Liu --- pkg/cri/server/image_pull.go | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/pkg/cri/server/image_pull.go b/pkg/cri/server/image_pull.go index 5f4034d8f..8a6a8bf0f 100644 --- a/pkg/cri/server/image_pull.go +++ b/pkg/cri/server/image_pull.go @@ -375,21 +375,25 @@ func (c *criService) registryHosts(ctx context.Context, auth *runtime.AuthConfig } } + // Make a copy of `auth`, so that different authorizers would not reference + // the same auth variable. + auth := auth if auth == nil && config.Auth != nil { auth = toRuntimeAuthConfig(*config.Auth) } + authorizer := docker.NewDockerAuthorizer( + docker.WithAuthClient(client), + docker.WithAuthCreds(func(host string) (string, string, error) { + return ParseAuth(auth, host) + })) if u.Path == "" { u.Path = "/v2" } registries = append(registries, docker.RegistryHost{ - Client: client, - Authorizer: docker.NewDockerAuthorizer( - docker.WithAuthClient(client), - docker.WithAuthCreds(func(host string) (string, string, error) { - return ParseAuth(auth, host) - })), + Client: client, + Authorizer: authorizer, Host: u.Host, Scheme: u.Scheme, Path: u.Path,