diff --git a/distribution/push_v2.go b/distribution/push_v2.go index 582fb26680..b64230fa9c 100644 --- a/distribution/push_v2.go +++ b/distribution/push_v2.go @@ -2,9 +2,9 @@ package distribution // import "github.com/docker/docker/distribution" import ( "context" - "errors" "fmt" "io" + "os" "runtime" "sort" "strings" @@ -25,6 +25,7 @@ import ( "github.com/docker/docker/pkg/stringid" "github.com/docker/docker/registry" digest "github.com/opencontainers/go-digest" + "github.com/pkg/errors" "github.com/sirupsen/logrus" ) @@ -186,6 +187,18 @@ func (p *v2Pusher) pushV2Tag(ctx context.Context, ref reference.NamedTagged, id return err } + // This is a temporary environment variables used in CI to allow pushing + // manifest v2 schema 1 images to test-registries used for testing *pulling* + // these images. + if os.Getenv("DOCKER_ALLOW_SCHEMA1_PUSH_DONOTUSE") == "" { + if err.Error() == "tag invalid" { + msg := "[DEPRECATED] support for pushing manifest v2 schema1 images has been removed. More information at https://docs.docker.com/registry/spec/deprecated-schema-v1/" + logrus.WithError(err).Error(msg) + return errors.Wrap(err, msg) + } + return err + } + logrus.Warnf("failed to upload schema2 manifest: %v - falling back to schema1", err) // Note: this fallback is deprecated, see log messages below @@ -204,7 +217,7 @@ func (p *v2Pusher) pushV2Tag(ctx context.Context, ref reference.NamedTagged, id } // schema2 failed but schema1 succeeded - 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)) + msg := fmt.Sprintf("[DEPRECATION NOTICE] support for pushing manifest v2 schema1 images 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/hack/make/.integration-daemon-start b/hack/make/.integration-daemon-start index df7bd1edb3..af1a68796a 100644 --- a/hack/make/.integration-daemon-start +++ b/hack/make/.integration-daemon-start @@ -38,6 +38,9 @@ fi # intentionally open a couple bogus file descriptors to help test that they get scrubbed in containers exec 41>&1 42>&2 +# Allow pushing manifest v2 schema 1 images, as they're used to push +# images to our test-registries for testing _pulling_ schema 2v1 images. +export DOCKER_ALLOW_SCHEMA1_PUSH_DONOTUSE=1 export DOCKER_GRAPHDRIVER=${DOCKER_GRAPHDRIVER:-vfs} export DOCKER_USERLANDPROXY=${DOCKER_USERLANDPROXY:-true}