From 625b35e4bb26ee021713f2692143bf37f9a98bdd Mon Sep 17 00:00:00 2001 From: Samuel Karp Date: Wed, 29 Nov 2023 00:49:29 -0800 Subject: [PATCH] snapshots: emit deprecation warning for aufs Signed-off-by: Samuel Karp --- pkg/deprecation/deprecation.go | 5 ++++- services/snapshots/service.go | 27 ++++++++++++++++++++++++--- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/pkg/deprecation/deprecation.go b/pkg/deprecation/deprecation.go index 7cdeacac5ce6..711ef19a3ed2 100644 --- a/pkg/deprecation/deprecation.go +++ b/pkg/deprecation/deprecation.go @@ -33,6 +33,8 @@ const ( CRIRegistryConfigs Warning = Prefix + "cri-registry-configs" // CRIAPIV1Alpha2 is a warning for the use of CRI-API v1alpha2 CRIAPIV1Alpha2 Warning = Prefix + "cri-api-v1alpha2" + // AUFSSnapshotter is a warning for the use of the aufs snapshotter + AUFSSnapshotter Warning = Prefix + "aufs-snapshotter" ) var messages = map[Warning]string{ @@ -45,7 +47,8 @@ var messages = map[Warning]string{ "Use `ImagePullSecrets` instead.", CRIRegistryConfigs: "The `configs` property of `[plugins.\"io.containerd.grpc.v1.cri\".registry]` is deprecated since containerd v1.5 and will be removed in containerd v2.0." + "Use `config_path` instead.", - CRIAPIV1Alpha2: "CRI API v1alpha2 is deprecated since containerd v1.7 and removed in containerd v2.0. Use CRI API v1 instead.", + CRIAPIV1Alpha2: "CRI API v1alpha2 is deprecated since containerd v1.7 and removed in containerd v2.0. Use CRI API v1 instead.", + AUFSSnapshotter: "The aufs snapshotter is deprecated since containerd v1.5 and removed in containerd v2.0. Use the overlay snapshotter instead.", } // Valid checks whether a given Warning is valid diff --git a/services/snapshots/service.go b/services/snapshots/service.go index 4249f02e9173..e4ab6b2477cc 100644 --- a/services/snapshots/service.go +++ b/services/snapshots/service.go @@ -20,17 +20,20 @@ import ( "context" "errors" + "google.golang.org/grpc" + snapshotsapi "github.com/containerd/containerd/api/services/snapshots/v1" "github.com/containerd/containerd/api/types" "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/log" "github.com/containerd/containerd/mount" + "github.com/containerd/containerd/pkg/deprecation" "github.com/containerd/containerd/plugin" "github.com/containerd/containerd/protobuf" ptypes "github.com/containerd/containerd/protobuf/types" "github.com/containerd/containerd/services" + "github.com/containerd/containerd/services/warning" "github.com/containerd/containerd/snapshots" - "google.golang.org/grpc" ) func init() { @@ -39,6 +42,7 @@ func init() { ID: "snapshots", Requires: []plugin.Type{ plugin.ServicePlugin, + plugin.WarningPlugin, }, InitFn: newService, }) @@ -47,7 +51,8 @@ func init() { var empty = &ptypes.Empty{} type service struct { - ss map[string]snapshots.Snapshotter + ss map[string]snapshots.Snapshotter + warnings warning.Service snapshotsapi.UnimplementedSnapshotsServer } @@ -65,7 +70,14 @@ func newService(ic *plugin.InitContext) (interface{}, error) { return nil, err } ss := i.(map[string]snapshots.Snapshotter) - return &service{ss: ss}, nil + w, err := ic.Get(plugin.WarningPlugin) + if err != nil { + return nil, err + } + return &service{ + ss: ss, + warnings: w.(warning.Service), + }, nil } func (s *service) getSnapshotter(name string) (snapshots.Snapshotter, error) { @@ -147,6 +159,7 @@ func (s *service) Commit(ctx context.Context, cr *snapshotsapi.CommitSnapshotReq if err != nil { return nil, err } + s.emitSnapshotterWarning(ctx, cr.Snapshotter) var opts []snapshots.Opt if cr.Labels != nil { @@ -276,6 +289,14 @@ func (s *service) Cleanup(ctx context.Context, cr *snapshotsapi.CleanupRequest) return empty, nil } +func (s *service) emitSnapshotterWarning(ctx context.Context, sn string) { + switch sn { + case "aufs": + log.G(ctx).Warn("aufs snapshotter is deprecated") + s.warnings.Emit(ctx, deprecation.AUFSSnapshotter) + } +} + func fromKind(kind snapshots.Kind) snapshotsapi.Kind { if kind == snapshots.KindActive { return snapshotsapi.Kind_ACTIVE