From 43710a91a713717327167624960d79b8ea321203 Mon Sep 17 00:00:00 2001 From: Jon Johnson Date: Mon, 1 May 2023 09:48:00 -0700 Subject: [PATCH] Retry without mount if auth fails (#1681) DockerHub fails to auth if you ask for an invalid repository. Docs say this should not happen, but here we are. --- pkg/v1/remote/write.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/v1/remote/write.go b/pkg/v1/remote/write.go index 55abae950..65d4cc9b9 100644 --- a/pkg/v1/remote/write.go +++ b/pkg/v1/remote/write.go @@ -210,6 +210,11 @@ func (w *writer) initiateUpload(ctx context.Context, from, mount, origin string) req.Header.Set("Content-Type", "application/json") resp, err := w.client.Do(req.WithContext(ctx)) if err != nil { + if origin != "" && origin != w.repo.RegistryStr() { + // https://github.com/google/go-containerregistry/issues/1679 + logs.Warn.Printf("retrying without mount: %v", err) + return w.initiateUpload(ctx, "", "", "") + } return "", false, err } defer resp.Body.Close()