distribution: remove v2 schema1 push

Manifest v2 schema1 was deprecated in 4866f5139a1 and this commit
removes the push code for v2 schema1.

This reverts commit f695e98cb7,
adjusted for changes that were made since

daemon: do not mkdir trust directory

Remove push tests and move UUID tests to integration

Partial revert of f23a51a860.

Only the schema1 push tests are removed but the schema1 pull tests
are still desired.

The UUID test is moved from integration-cli to integration.

Signed-off-by: Tibor Vass <tibor@docker.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Tibor Vass 2019-06-19 00:57:01 +00:00 committed by Sebastiaan van Stijn
parent 4c8adbee26
commit ab547691c0
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C

View file

@ -4,8 +4,6 @@ import (
"context"
"fmt"
"io"
"os"
"runtime"
"sort"
"strings"
"sync"
@ -13,7 +11,6 @@ import (
"github.com/containerd/log"
"github.com/distribution/reference"
"github.com/docker/distribution"
"github.com/docker/distribution/manifest/schema1"
"github.com/docker/distribution/manifest/schema2"
"github.com/docker/distribution/registry/api/errcode"
"github.com/docker/distribution/registry/client"
@ -25,7 +22,6 @@ import (
"github.com/docker/docker/pkg/progress"
"github.com/docker/docker/pkg/stringid"
"github.com/docker/docker/registry"
"github.com/docker/libtrust"
"github.com/opencontainers/go-digest"
"github.com/pkg/errors"
)
@ -188,60 +184,24 @@ func (p *pusher) pushTag(ctx context.Context, ref reference.NamedTagged, id dige
putOptions := []distribution.ManifestServiceOption{distribution.WithTag(ref.Tag())}
if _, err = manSvc.Put(ctx, manifest, putOptions...); err != nil {
if runtime.GOOS == "windows" {
log.G(ctx).Warnf("failed to upload schema2 manifest: %v", err)
return err
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/"
log.G(ctx).WithError(err).Error(msg)
err = errors.Wrap(err, msg)
}
// 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/"
log.G(ctx).WithError(err).Error(msg)
return errors.Wrap(err, msg)
}
return err
}
log.G(ctx).Warnf("failed to upload schema2 manifest: %v - falling back to schema1", err)
// Note: this fallback is deprecated, see log messages below
manifestRef, err := reference.WithTag(p.repo.Named(), ref.Tag())
if err != nil {
return err
}
pk, err := libtrust.GenerateECP256PrivateKey()
if err != nil {
return errors.Wrap(err, "unexpected error generating private key")
}
builder = schema1.NewConfigManifestBuilder(p.repo.Blobs(ctx), pk, manifestRef, imgConfig)
manifest, err = manifestFromBuilder(ctx, builder, descriptors)
if err != nil {
return err
}
if _, err = manSvc.Put(ctx, manifest, putOptions...); err != nil {
return err
}
// schema2 failed but schema1 succeeded
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))
log.G(ctx).Warn(msg)
progress.Message(p.config.ProgressOutput, "", msg)
return err
}
var canonicalManifest []byte
switch v := manifest.(type) {
case *schema1.SignedManifest:
canonicalManifest = v.Canonical
case *schema2.DeserializedManifest:
_, canonicalManifest, err = v.Payload()
if err != nil {
return err
}
default:
return fmt.Errorf("unknown manifest type %T", v)
}
manifestDigest := digest.FromBytes(canonicalManifest)