Skip to content

Commit

Permalink
snapshots: emit deprecation warning for aufs
Browse files Browse the repository at this point in the history
Signed-off-by: Samuel Karp <samuelkarp@google.com>
(cherry picked from commit 625b35e)
Signed-off-by: Samuel Karp <samuelkarp@google.com>
  • Loading branch information
samuelkarp committed Dec 1, 2023
1 parent d8f198a commit 7cfe705
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
5 changes: 4 additions & 1 deletion pkg/deprecation/deprecation.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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
Expand Down
24 changes: 22 additions & 2 deletions services/snapshots/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ import (
"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/services"
"github.com/containerd/containerd/services/warning"
"github.com/containerd/containerd/snapshots"
ptypes "github.com/gogo/protobuf/types"
"google.golang.org/grpc"
Expand All @@ -38,6 +40,7 @@ func init() {
ID: "snapshots",
Requires: []plugin.Type{
plugin.ServicePlugin,
plugin.WarningPlugin,
},
InitFn: newService,
})
Expand All @@ -46,7 +49,8 @@ func init() {
var empty = &ptypes.Empty{}

type service struct {
ss map[string]snapshots.Snapshotter
ss map[string]snapshots.Snapshotter
warnings warning.Service
}

func newService(ic *plugin.InitContext) (interface{}, error) {
Expand All @@ -63,7 +67,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) {
Expand Down Expand Up @@ -145,6 +156,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 {
Expand Down Expand Up @@ -274,6 +286,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.KindActive
Expand Down

0 comments on commit 7cfe705

Please sign in to comment.