Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release/1.7] snapshots: emit deprecation warning for aufs #9436

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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