@@ -19,6 +19,11 @@ package images
1919import (
2020 "context"
2121
22+ ptypes "github.com/gogo/protobuf/types"
23+ "google.golang.org/grpc"
24+ "google.golang.org/grpc/codes"
25+ "google.golang.org/grpc/status"
26+
2227 eventstypes "github.com/containerd/containerd/api/events"
2328 imagesapi "github.com/containerd/containerd/api/services/images/v1"
2429 "github.com/containerd/containerd/errdefs"
@@ -27,12 +32,10 @@ import (
2732 "github.com/containerd/containerd/images"
2833 "github.com/containerd/containerd/log"
2934 "github.com/containerd/containerd/metadata"
35+ "github.com/containerd/containerd/pkg/deprecation"
3036 "github.com/containerd/containerd/plugin"
3137 "github.com/containerd/containerd/services"
32- ptypes "github.com/gogo/protobuf/types"
33- "google.golang.org/grpc"
34- "google.golang.org/grpc/codes"
35- "google.golang.org/grpc/status"
38+ "github.com/containerd/containerd/services/warning"
3639)
3740
3841func init () {
@@ -42,6 +45,7 @@ func init() {
4245 Requires : []plugin.Type {
4346 plugin .MetadataPlugin ,
4447 plugin .GCPlugin ,
48+ plugin .WarningPlugin ,
4549 },
4650 InitFn : func (ic * plugin.InitContext ) (interface {}, error ) {
4751 m , err := ic .Get (plugin .MetadataPlugin )
@@ -52,11 +56,16 @@ func init() {
5256 if err != nil {
5357 return nil , err
5458 }
59+ w , err := ic .Get (plugin .WarningPlugin )
60+ if err != nil {
61+ return nil , err
62+ }
5563
5664 return & local {
5765 store : metadata .NewImageStore (m .(* metadata.DB )),
5866 publisher : ic .Events ,
5967 gc : g .(gcScheduler ),
68+ warnings : w .(warning.Service ),
6069 }, nil
6170 },
6271 })
@@ -70,6 +79,7 @@ type local struct {
7079 store images.Store
7180 gc gcScheduler
7281 publisher events.Publisher
82+ warnings warning.Service
7383}
7484
7585var _ imagesapi.ImagesClient = & local {}
@@ -121,6 +131,7 @@ func (l *local) Create(ctx context.Context, req *imagesapi.CreateImageRequest, _
121131 return nil , err
122132 }
123133
134+ l .emitSchema1DeprecationWarning (ctx , & image )
124135 return & resp , nil
125136
126137}
@@ -154,6 +165,7 @@ func (l *local) Update(ctx context.Context, req *imagesapi.UpdateImageRequest, _
154165 return nil , err
155166 }
156167
168+ l .emitSchema1DeprecationWarning (ctx , & image )
157169 return & resp , nil
158170}
159171
@@ -178,3 +190,15 @@ func (l *local) Delete(ctx context.Context, req *imagesapi.DeleteImageRequest, _
178190
179191 return & ptypes.Empty {}, nil
180192}
193+
194+ func (l * local ) emitSchema1DeprecationWarning (ctx context.Context , image * images.Image ) {
195+ if image == nil {
196+ return
197+ }
198+ dgst , ok := image .Labels [images .ConvertedDockerSchema1LabelKey ]
199+ if ! ok {
200+ return
201+ }
202+ log .G (ctx ).WithField ("name" , image .Name ).WithField ("schema1digest" , dgst ).Warn ("conversion from schema 1 images is deprecated" )
203+ l .warnings .Emit (ctx , deprecation .PullSchema1Image )
204+ }
0 commit comments