Skip to content

Commit 5e742ea

Browse files
committed
Fix different registry hosts referencing the same auth config.
Signed-off-by: Lantao Liu <[email protected]> (cherry picked from commit 81402e4) Signed-off-by: Lantao Liu <[email protected]>
1 parent b60331a commit 5e742ea

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

pkg/cri/server/image_pull.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -375,21 +375,25 @@ func (c *criService) registryHosts(ctx context.Context, auth *runtime.AuthConfig
375375
}
376376
}
377377

378+
// Make a copy of `auth`, so that different authorizers would not reference
379+
// the same auth variable.
380+
auth := auth
378381
if auth == nil && config.Auth != nil {
379382
auth = toRuntimeAuthConfig(*config.Auth)
380383
}
384+
authorizer := docker.NewDockerAuthorizer(
385+
docker.WithAuthClient(client),
386+
docker.WithAuthCreds(func(host string) (string, string, error) {
387+
return ParseAuth(auth, host)
388+
}))
381389

382390
if u.Path == "" {
383391
u.Path = "/v2"
384392
}
385393

386394
registries = append(registries, docker.RegistryHost{
387-
Client: client,
388-
Authorizer: docker.NewDockerAuthorizer(
389-
docker.WithAuthClient(client),
390-
docker.WithAuthCreds(func(host string) (string, string, error) {
391-
return ParseAuth(auth, host)
392-
})),
395+
Client: client,
396+
Authorizer: authorizer,
393397
Host: u.Host,
394398
Scheme: u.Scheme,
395399
Path: u.Path,

0 commit comments

Comments
 (0)