pull: record deprecation warning for schema 1
Signed-off-by: Samuel Karp <samuelkarp@google.com>
This commit is contained in:
@@ -19,6 +19,11 @@ package images
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/containerd/log"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
|
||||
eventstypes "github.com/containerd/containerd/api/events"
|
||||
imagesapi "github.com/containerd/containerd/api/services/images/v1"
|
||||
"github.com/containerd/containerd/errdefs"
|
||||
@@ -26,16 +31,14 @@ import (
|
||||
"github.com/containerd/containerd/gc"
|
||||
"github.com/containerd/containerd/images"
|
||||
"github.com/containerd/containerd/metadata"
|
||||
"github.com/containerd/containerd/pkg/deprecation"
|
||||
"github.com/containerd/containerd/pkg/epoch"
|
||||
"github.com/containerd/containerd/plugin"
|
||||
"github.com/containerd/containerd/plugin/registry"
|
||||
"github.com/containerd/containerd/plugins"
|
||||
ptypes "github.com/containerd/containerd/protobuf/types"
|
||||
"github.com/containerd/containerd/services"
|
||||
"github.com/containerd/log"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
"github.com/containerd/containerd/services/warning"
|
||||
)
|
||||
|
||||
func init() {
|
||||
@@ -46,6 +49,7 @@ func init() {
|
||||
plugins.EventPlugin,
|
||||
plugins.MetadataPlugin,
|
||||
plugins.GCPlugin,
|
||||
plugins.WarningPlugin,
|
||||
},
|
||||
InitFn: func(ic *plugin.InitContext) (interface{}, error) {
|
||||
m, err := ic.Get(plugins.MetadataPlugin)
|
||||
@@ -56,16 +60,20 @@ func init() {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ep, err := ic.Get(plugins.EventPlugin)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
w, err := ic.Get(plugins.WarningPlugin)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &local{
|
||||
store: metadata.NewImageStore(m.(*metadata.DB)),
|
||||
publisher: ep.(events.Publisher),
|
||||
gc: g.(gcScheduler),
|
||||
warnings: w.(warning.Service),
|
||||
}, nil
|
||||
},
|
||||
})
|
||||
@@ -79,6 +87,7 @@ type local struct {
|
||||
store images.Store
|
||||
gc gcScheduler
|
||||
publisher events.Publisher
|
||||
warnings warning.Service
|
||||
}
|
||||
|
||||
var _ imagesapi.ImagesClient = &local{}
|
||||
@@ -134,6 +143,7 @@ func (l *local) Create(ctx context.Context, req *imagesapi.CreateImageRequest, _
|
||||
return nil, err
|
||||
}
|
||||
|
||||
l.emitSchema1DeprecationWarning(ctx, &image)
|
||||
return &resp, nil
|
||||
|
||||
}
|
||||
@@ -172,6 +182,7 @@ func (l *local) Update(ctx context.Context, req *imagesapi.UpdateImageRequest, _
|
||||
return nil, err
|
||||
}
|
||||
|
||||
l.emitSchema1DeprecationWarning(ctx, &image)
|
||||
return &resp, nil
|
||||
}
|
||||
|
||||
@@ -203,3 +214,15 @@ func (l *local) Delete(ctx context.Context, req *imagesapi.DeleteImageRequest, _
|
||||
|
||||
return &ptypes.Empty{}, nil
|
||||
}
|
||||
|
||||
func (l *local) emitSchema1DeprecationWarning(ctx context.Context, image *images.Image) {
|
||||
if image == nil {
|
||||
return
|
||||
}
|
||||
dgst, ok := image.Labels[images.ConvertedDockerSchema1LabelKey]
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
log.G(ctx).WithField("name", image.Name).WithField("schema1digest", dgst).Warn("conversion from schema 1 images is deprecated")
|
||||
l.warnings.Emit(ctx, deprecation.PullSchema1Image)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user