pull: record deprecation warning for schema 1
Signed-off-by: Samuel Karp <samuelkarp@google.com>
This commit is contained in:
parent
9aab446733
commit
bc861b66f9
21
images/labels.go
Normal file
21
images/labels.go
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
/*
|
||||||
|
Copyright The containerd Authors.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package images
|
||||||
|
|
||||||
|
const (
|
||||||
|
ConvertedDockerSchema1LabelKey = "io.containerd.image/converted-docker-schema1"
|
||||||
|
)
|
10
pull.go
10
pull.go
@ -21,6 +21,9 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||||
|
"golang.org/x/sync/semaphore"
|
||||||
|
|
||||||
"github.com/containerd/containerd/errdefs"
|
"github.com/containerd/containerd/errdefs"
|
||||||
"github.com/containerd/containerd/images"
|
"github.com/containerd/containerd/images"
|
||||||
"github.com/containerd/containerd/pkg/unpack"
|
"github.com/containerd/containerd/pkg/unpack"
|
||||||
@ -29,13 +32,10 @@ import (
|
|||||||
"github.com/containerd/containerd/remotes/docker"
|
"github.com/containerd/containerd/remotes/docker"
|
||||||
"github.com/containerd/containerd/remotes/docker/schema1" //nolint:staticcheck // Ignore SA1019. Need to keep deprecated package for compatibility.
|
"github.com/containerd/containerd/remotes/docker/schema1" //nolint:staticcheck // Ignore SA1019. Need to keep deprecated package for compatibility.
|
||||||
"github.com/containerd/containerd/tracing"
|
"github.com/containerd/containerd/tracing"
|
||||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
|
||||||
"golang.org/x/sync/semaphore"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
pullSpanPrefix = "pull"
|
pullSpanPrefix = "pull"
|
||||||
convertedDockerSchema1LabelKey = "io.containerd.image/converted-docker-schema1"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Pull downloads the provided content into containerd's content store
|
// Pull downloads the provided content into containerd's content store
|
||||||
@ -278,7 +278,7 @@ func (c *Client) fetch(ctx context.Context, rCtx *RemoteContext, ref string, lim
|
|||||||
if rCtx.Labels == nil {
|
if rCtx.Labels == nil {
|
||||||
rCtx.Labels = make(map[string]string)
|
rCtx.Labels = make(map[string]string)
|
||||||
}
|
}
|
||||||
rCtx.Labels[convertedDockerSchema1LabelKey] = originalSchema1Digest
|
rCtx.Labels[images.ConvertedDockerSchema1LabelKey] = originalSchema1Digest
|
||||||
}
|
}
|
||||||
|
|
||||||
return images.Image{
|
return images.Image{
|
||||||
|
@ -19,6 +19,11 @@ package images
|
|||||||
import (
|
import (
|
||||||
"context"
|
"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"
|
eventstypes "github.com/containerd/containerd/api/events"
|
||||||
imagesapi "github.com/containerd/containerd/api/services/images/v1"
|
imagesapi "github.com/containerd/containerd/api/services/images/v1"
|
||||||
"github.com/containerd/containerd/errdefs"
|
"github.com/containerd/containerd/errdefs"
|
||||||
@ -26,16 +31,14 @@ import (
|
|||||||
"github.com/containerd/containerd/gc"
|
"github.com/containerd/containerd/gc"
|
||||||
"github.com/containerd/containerd/images"
|
"github.com/containerd/containerd/images"
|
||||||
"github.com/containerd/containerd/metadata"
|
"github.com/containerd/containerd/metadata"
|
||||||
|
"github.com/containerd/containerd/pkg/deprecation"
|
||||||
"github.com/containerd/containerd/pkg/epoch"
|
"github.com/containerd/containerd/pkg/epoch"
|
||||||
"github.com/containerd/containerd/plugin"
|
"github.com/containerd/containerd/plugin"
|
||||||
"github.com/containerd/containerd/plugin/registry"
|
"github.com/containerd/containerd/plugin/registry"
|
||||||
"github.com/containerd/containerd/plugins"
|
"github.com/containerd/containerd/plugins"
|
||||||
ptypes "github.com/containerd/containerd/protobuf/types"
|
ptypes "github.com/containerd/containerd/protobuf/types"
|
||||||
"github.com/containerd/containerd/services"
|
"github.com/containerd/containerd/services"
|
||||||
"github.com/containerd/log"
|
"github.com/containerd/containerd/services/warning"
|
||||||
"google.golang.org/grpc"
|
|
||||||
"google.golang.org/grpc/codes"
|
|
||||||
"google.golang.org/grpc/status"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@ -46,6 +49,7 @@ func init() {
|
|||||||
plugins.EventPlugin,
|
plugins.EventPlugin,
|
||||||
plugins.MetadataPlugin,
|
plugins.MetadataPlugin,
|
||||||
plugins.GCPlugin,
|
plugins.GCPlugin,
|
||||||
|
plugins.WarningPlugin,
|
||||||
},
|
},
|
||||||
InitFn: func(ic *plugin.InitContext) (interface{}, error) {
|
InitFn: func(ic *plugin.InitContext) (interface{}, error) {
|
||||||
m, err := ic.Get(plugins.MetadataPlugin)
|
m, err := ic.Get(plugins.MetadataPlugin)
|
||||||
@ -56,16 +60,20 @@ func init() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
ep, err := ic.Get(plugins.EventPlugin)
|
ep, err := ic.Get(plugins.EventPlugin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
w, err := ic.Get(plugins.WarningPlugin)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
return &local{
|
return &local{
|
||||||
store: metadata.NewImageStore(m.(*metadata.DB)),
|
store: metadata.NewImageStore(m.(*metadata.DB)),
|
||||||
publisher: ep.(events.Publisher),
|
publisher: ep.(events.Publisher),
|
||||||
gc: g.(gcScheduler),
|
gc: g.(gcScheduler),
|
||||||
|
warnings: w.(warning.Service),
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@ -79,6 +87,7 @@ type local struct {
|
|||||||
store images.Store
|
store images.Store
|
||||||
gc gcScheduler
|
gc gcScheduler
|
||||||
publisher events.Publisher
|
publisher events.Publisher
|
||||||
|
warnings warning.Service
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ imagesapi.ImagesClient = &local{}
|
var _ imagesapi.ImagesClient = &local{}
|
||||||
@ -134,6 +143,7 @@ func (l *local) Create(ctx context.Context, req *imagesapi.CreateImageRequest, _
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
l.emitSchema1DeprecationWarning(ctx, &image)
|
||||||
return &resp, nil
|
return &resp, nil
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -172,6 +182,7 @@ func (l *local) Update(ctx context.Context, req *imagesapi.UpdateImageRequest, _
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
l.emitSchema1DeprecationWarning(ctx, &image)
|
||||||
return &resp, nil
|
return &resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -203,3 +214,15 @@ func (l *local) Delete(ctx context.Context, req *imagesapi.DeleteImageRequest, _
|
|||||||
|
|
||||||
return &ptypes.Empty{}, nil
|
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)
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user