@@ -19,6 +19,10 @@ package images
1919import (
2020 "context"
2121
22+ "google.golang.org/grpc"
23+ "google.golang.org/grpc/codes"
24+ "google.golang.org/grpc/status"
25+
2226 eventstypes "github.com/containerd/containerd/api/events"
2327 imagesapi "github.com/containerd/containerd/api/services/images/v1"
2428 "github.com/containerd/containerd/errdefs"
@@ -27,13 +31,12 @@ import (
2731 "github.com/containerd/containerd/images"
2832 "github.com/containerd/containerd/log"
2933 "github.com/containerd/containerd/metadata"
34+ "github.com/containerd/containerd/pkg/deprecation"
3035 "github.com/containerd/containerd/pkg/epoch"
3136 "github.com/containerd/containerd/plugin"
3237 ptypes "github.com/containerd/containerd/protobuf/types"
3338 "github.com/containerd/containerd/services"
34- "google.golang.org/grpc"
35- "google.golang.org/grpc/codes"
36- "google.golang.org/grpc/status"
39+ "github.com/containerd/containerd/services/warning"
3740)
3841
3942func init () {
@@ -43,6 +46,7 @@ func init() {
4346 Requires : []plugin.Type {
4447 plugin .MetadataPlugin ,
4548 plugin .GCPlugin ,
49+ plugin .WarningPlugin ,
4650 },
4751 InitFn : func (ic * plugin.InitContext ) (interface {}, error ) {
4852 m , err := ic .Get (plugin .MetadataPlugin )
@@ -53,11 +57,16 @@ func init() {
5357 if err != nil {
5458 return nil , err
5559 }
60+ w , err := ic .Get (plugin .WarningPlugin )
61+ if err != nil {
62+ return nil , err
63+ }
5664
5765 return & local {
5866 store : metadata .NewImageStore (m .(* metadata.DB )),
5967 publisher : ic .Events ,
6068 gc : g .(gcScheduler ),
69+ warnings : w .(warning.Service ),
6170 }, nil
6271 },
6372 })
@@ -71,6 +80,7 @@ type local struct {
7180 store images.Store
7281 gc gcScheduler
7382 publisher events.Publisher
83+ warnings warning.Service
7484}
7585
7686var _ imagesapi.ImagesClient = & local {}
@@ -126,6 +136,7 @@ func (l *local) Create(ctx context.Context, req *imagesapi.CreateImageRequest, _
126136 return nil , err
127137 }
128138
139+ l .emitSchema1DeprecationWarning (ctx , & image )
129140 return & resp , nil
130141
131142}
@@ -164,6 +175,7 @@ func (l *local) Update(ctx context.Context, req *imagesapi.UpdateImageRequest, _
164175 return nil , err
165176 }
166177
178+ l .emitSchema1DeprecationWarning (ctx , & image )
167179 return & resp , nil
168180}
169181
@@ -188,3 +200,15 @@ func (l *local) Delete(ctx context.Context, req *imagesapi.DeleteImageRequest, _
188200
189201 return & ptypes.Empty {}, nil
190202}
203+
204+ func (l * local ) emitSchema1DeprecationWarning (ctx context.Context , image * images.Image ) {
205+ if image == nil {
206+ return
207+ }
208+ dgst , ok := image .Labels [images .ConvertedDockerSchema1LabelKey ]
209+ if ! ok {
210+ return
211+ }
212+ log .G (ctx ).WithField ("name" , image .Name ).WithField ("schema1digest" , dgst ).Warn ("conversion from schema 1 images is deprecated" )
213+ l .warnings .Emit (ctx , deprecation .PullSchema1Image )
214+ }
0 commit comments