Browse code

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 <tibor@docker.com>

Tibor Vass authored on 2019/08/14 03:13:14
Showing 3 changed files
... ...
@@ -392,9 +392,14 @@ func (p *v2Puller) pullV2Tag(ctx context.Context, ref reference.Named, platform
392 392
 		if p.config.RequireSchema2 {
393 393
 			return false, fmt.Errorf("invalid manifest: not schema2")
394 394
 		}
395
-		msg := schema1DeprecationMessage(ref)
396
-		logrus.Warn(msg)
397
-		progress.Message(p.config.ProgressOutput, "", msg)
395
+
396
+		// give registries time to upgrade to schema2 and only warn if we know a registry has been upgraded long time ago
397
+		// TODO: condition to be removed
398
+		if reference.Domain(ref) == "docker.io" {
399
+			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)
400
+			logrus.Warn(msg)
401
+			progress.Message(p.config.ProgressOutput, "", msg)
402
+		}
398 403
 
399 404
 		id, manifestDigest, err = p.pullSchema1(ctx, ref, v, platform)
400 405
 		if err != nil {
... ...
@@ -791,7 +796,7 @@ func (p *v2Puller) pullManifestList(ctx context.Context, ref reference.Named, mf
791 791
 
792 792
 	switch v := manifest.(type) {
793 793
 	case *schema1.SignedManifest:
794
-		msg := schema1DeprecationMessage(ref)
794
+		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)
795 795
 		logrus.Warn(msg)
796 796
 		progress.Message(p.config.ProgressOutput, "", msg)
797 797
 
... ...
@@ -188,7 +188,7 @@ func (p *v2Pusher) pushV2Tag(ctx context.Context, ref reference.NamedTagged, id
188 188
 
189 189
 		logrus.Warnf("failed to upload schema2 manifest: %v - falling back to schema1", err)
190 190
 
191
-		msg := schema1DeprecationMessage(ref)
191
+		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))
192 192
 		logrus.Warn(msg)
193 193
 		progress.Message(p.config.ProgressOutput, "", msg)
194 194
 
... ...
@@ -156,7 +156,3 @@ func (th *existingTokenHandler) AuthorizeRequest(req *http.Request, params map[s
156 156
 	req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", th.token))
157 157
 	return nil
158 158
 }
159
-
160
-func schema1DeprecationMessage(ref reference.Named) string {
161
-	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))
162
-}