Skip to content

Commit d35f8f4

Browse files
author
Tibor Vass
committed
Add deprecation message for schema1
This will add a warning log in the daemon, and will send the message to be displayed by the CLI. Signed-off-by: Tibor Vass <[email protected]>
1 parent f923321 commit d35f8f4

3 files changed

Lines changed: 17 additions & 1 deletion

File tree

distribution/pull_v2.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import (
2323
"github.com/docker/docker/distribution/metadata"
2424
"github.com/docker/docker/distribution/xfer"
2525
"github.com/docker/docker/image"
26-
"github.com/docker/docker/image/v1"
26+
v1 "github.com/docker/docker/image/v1"
2727
"github.com/docker/docker/layer"
2828
"github.com/docker/docker/pkg/ioutils"
2929
"github.com/docker/docker/pkg/progress"
@@ -392,6 +392,10 @@ func (p *v2Puller) pullV2Tag(ctx context.Context, ref reference.Named, platform
392392
if p.config.RequireSchema2 {
393393
return false, fmt.Errorf("invalid manifest: not schema2")
394394
}
395+
msg := schema1DeprecationMessage(ref)
396+
logrus.Warn(msg)
397+
progress.Message(p.config.ProgressOutput, "", msg)
398+
395399
id, manifestDigest, err = p.pullSchema1(ctx, ref, v, platform)
396400
if err != nil {
397401
return false, err
@@ -787,6 +791,10 @@ func (p *v2Puller) pullManifestList(ctx context.Context, ref reference.Named, mf
787791

788792
switch v := manifest.(type) {
789793
case *schema1.SignedManifest:
794+
msg := schema1DeprecationMessage(ref)
795+
logrus.Warn(msg)
796+
progress.Message(p.config.ProgressOutput, "", msg)
797+
790798
platform := toOCIPlatform(manifestMatches[0].Platform)
791799
id, _, err = p.pullSchema1(ctx, manifestRef, v, &platform)
792800
if err != nil {

distribution/push_v2.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,10 @@ func (p *v2Pusher) pushV2Tag(ctx context.Context, ref reference.NamedTagged, id
188188

189189
logrus.Warnf("failed to upload schema2 manifest: %v - falling back to schema1", err)
190190

191+
msg := schema1DeprecationMessage(ref)
192+
logrus.Warn(msg)
193+
progress.Message(p.config.ProgressOutput, "", msg)
194+
191195
manifestRef, err := reference.WithTag(p.repo.Named(), ref.Tag())
192196
if err != nil {
193197
return err

distribution/registry.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,3 +156,7 @@ func (th *existingTokenHandler) AuthorizeRequest(req *http.Request, params map[s
156156
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", th.token))
157157
return nil
158158
}
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+
}

0 commit comments

Comments
 (0)