Skip to content

Commit

Permalink
Merge pull request #9436 from samuelkarp/deprecation-warning-aufs-1.7
Browse files Browse the repository at this point in the history
[release/1.7] snapshots: emit deprecation warning for aufs
  • Loading branch information
estesp committed Nov 30, 2023
2 parents 4e1fe74 + 625b35e commit 181449d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
5 changes: 4 additions & 1 deletion pkg/deprecation/deprecation.go
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
27 changes: 24 additions & 3 deletions services/snapshots/service.go
Expand Up @@ -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() {
Expand All @@ -39,6 +42,7 @@ func init() {
ID: "snapshots",
Requires: []plugin.Type{
plugin.ServicePlugin,
plugin.WarningPlugin,
},
InitFn: newService,
})
Expand All @@ -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
}

Expand All @@ -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) {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 181449d

Please sign in to comment.