From 647dfe99a50badd27f0508c67eddc4b4923fcef7 Mon Sep 17 00:00:00 2001 From: Tibor Vass Date: Tue, 13 Aug 2019 18:13:14 +0000 Subject: distribution: modify warning logic when pulling v2 schema1 manifests The warning on pull was incorrectly asking to contact registry admins. It is kept on push however. Pulling manifest lists with v2 schema1 manifests will not be supported thus there is a warning for those, but wording changed to suggest repository author to upgrade. Finally, a milder warning on regular pull is kept ONLY for DockerHub users in order to incite moving away from schema1. Signed-off-by: Tibor Vass --- distribution/pull_v2.go | 13 +++++++++---- distribution/push_v2.go | 2 +- distribution/registry.go | 4 ---- 3 files changed, 10 insertions(+), 9 deletions(-) (limited to 'distribution') diff --git a/distribution/pull_v2.go b/distribution/pull_v2.go index dd91ff2157..77c5f645a0 100644 --- a/distribution/pull_v2.go +++ b/distribution/pull_v2.go @@ -392,9 +392,14 @@ func (p *v2Puller) pullV2Tag(ctx context.Context, ref reference.Named, platform if p.config.RequireSchema2 { return false, fmt.Errorf("invalid manifest: not schema2") } - msg := schema1DeprecationMessage(ref) - logrus.Warn(msg) - progress.Message(p.config.ProgressOutput, "", msg) + + // give registries time to upgrade to schema2 and only warn if we know a registry has been upgraded long time ago + // TODO: condition to be removed + if reference.Domain(ref) == "docker.io" { + msg := fmt.Sprintf("Image %s uses outdated schema1 manifest format. Please upgrade to a schema2 image for better future compatibility. More information at https://docs.docker.com/registry/spec/deprecated-schema-v1/", ref) + logrus.Warn(msg) + progress.Message(p.config.ProgressOutput, "", msg) + } id, manifestDigest, err = p.pullSchema1(ctx, ref, v, platform) if err != nil { @@ -791,7 +796,7 @@ func (p *v2Puller) pullManifestList(ctx context.Context, ref reference.Named, mf switch v := manifest.(type) { case *schema1.SignedManifest: - msg := schema1DeprecationMessage(ref) + msg := fmt.Sprintf("[DEPRECATION NOTICE] v2 schema1 manifests in manifest lists are not supported and will break in a future release. Suggest author of %s to upgrade to v2 schema2. More information at https://docs.docker.com/registry/spec/deprecated-schema-v1/", ref) logrus.Warn(msg) progress.Message(p.config.ProgressOutput, "", msg) diff --git a/distribution/push_v2.go b/distribution/push_v2.go index e15384eba7..06863ad0d7 100644 --- a/distribution/push_v2.go +++ b/distribution/push_v2.go @@ -188,7 +188,7 @@ func (p *v2Pusher) pushV2Tag(ctx context.Context, ref reference.NamedTagged, id logrus.Warnf("failed to upload schema2 manifest: %v - falling back to schema1", err) - msg := schema1DeprecationMessage(ref) + msg := fmt.Sprintf("[DEPRECATION NOTICE] registry v2 schema1 support will be removed in an upcoming release. Please contact admins of the %s registry NOW to avoid future disruption. More information at https://docs.docker.com/registry/spec/deprecated-schema-v1/", reference.Domain(ref)) logrus.Warn(msg) progress.Message(p.config.ProgressOutput, "", msg) diff --git a/distribution/registry.go b/distribution/registry.go index c474d14473..d81530b75c 100644 --- a/distribution/registry.go +++ b/distribution/registry.go @@ -156,7 +156,3 @@ func (th *existingTokenHandler) AuthorizeRequest(req *http.Request, params map[s req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", th.token)) return nil } - -func schema1DeprecationMessage(ref reference.Named) string { - return fmt.Sprintf("[DEPRECATION NOTICE] registry v2 schema1 support will be removed in an upcoming release. Please contact admins of the %s registry NOW to avoid future disruption.", reference.Domain(ref)) -} -- cgit v1.2.1