Skip to content

Commit 625b35e

Browse files
committed
snapshots: emit deprecation warning for aufs
Signed-off-by: Samuel Karp <[email protected]>
1 parent 21b85e9 commit 625b35e

2 files changed

Lines changed: 28 additions & 4 deletions

File tree

pkg/deprecation/deprecation.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ const (
3333
CRIRegistryConfigs Warning = Prefix + "cri-registry-configs"
3434
// CRIAPIV1Alpha2 is a warning for the use of CRI-API v1alpha2
3535
CRIAPIV1Alpha2 Warning = Prefix + "cri-api-v1alpha2"
36+
// AUFSSnapshotter is a warning for the use of the aufs snapshotter
37+
AUFSSnapshotter Warning = Prefix + "aufs-snapshotter"
3638
)
3739

3840
var messages = map[Warning]string{
@@ -45,7 +47,8 @@ var messages = map[Warning]string{
4547
"Use `ImagePullSecrets` instead.",
4648
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." +
4749
"Use `config_path` instead.",
48-
CRIAPIV1Alpha2: "CRI API v1alpha2 is deprecated since containerd v1.7 and removed in containerd v2.0. Use CRI API v1 instead.",
50+
CRIAPIV1Alpha2: "CRI API v1alpha2 is deprecated since containerd v1.7 and removed in containerd v2.0. Use CRI API v1 instead.",
51+
AUFSSnapshotter: "The aufs snapshotter is deprecated since containerd v1.5 and removed in containerd v2.0. Use the overlay snapshotter instead.",
4952
}
5053

5154
// Valid checks whether a given Warning is valid

services/snapshots/service.go

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,20 @@ import (
2020
"context"
2121
"errors"
2222

23+
"google.golang.org/grpc"
24+
2325
snapshotsapi "github.com/containerd/containerd/api/services/snapshots/v1"
2426
"github.com/containerd/containerd/api/types"
2527
"github.com/containerd/containerd/errdefs"
2628
"github.com/containerd/containerd/log"
2729
"github.com/containerd/containerd/mount"
30+
"github.com/containerd/containerd/pkg/deprecation"
2831
"github.com/containerd/containerd/plugin"
2932
"github.com/containerd/containerd/protobuf"
3033
ptypes "github.com/containerd/containerd/protobuf/types"
3134
"github.com/containerd/containerd/services"
35+
"github.com/containerd/containerd/services/warning"
3236
"github.com/containerd/containerd/snapshots"
33-
"google.golang.org/grpc"
3437
)
3538

3639
func init() {
@@ -39,6 +42,7 @@ func init() {
3942
ID: "snapshots",
4043
Requires: []plugin.Type{
4144
plugin.ServicePlugin,
45+
plugin.WarningPlugin,
4246
},
4347
InitFn: newService,
4448
})
@@ -47,7 +51,8 @@ func init() {
4751
var empty = &ptypes.Empty{}
4852

4953
type service struct {
50-
ss map[string]snapshots.Snapshotter
54+
ss map[string]snapshots.Snapshotter
55+
warnings warning.Service
5156
snapshotsapi.UnimplementedSnapshotsServer
5257
}
5358

@@ -65,7 +70,14 @@ func newService(ic *plugin.InitContext) (interface{}, error) {
6570
return nil, err
6671
}
6772
ss := i.(map[string]snapshots.Snapshotter)
68-
return &service{ss: ss}, nil
73+
w, err := ic.Get(plugin.WarningPlugin)
74+
if err != nil {
75+
return nil, err
76+
}
77+
return &service{
78+
ss: ss,
79+
warnings: w.(warning.Service),
80+
}, nil
6981
}
7082

7183
func (s *service) getSnapshotter(name string) (snapshots.Snapshotter, error) {
@@ -147,6 +159,7 @@ func (s *service) Commit(ctx context.Context, cr *snapshotsapi.CommitSnapshotReq
147159
if err != nil {
148160
return nil, err
149161
}
162+
s.emitSnapshotterWarning(ctx, cr.Snapshotter)
150163

151164
var opts []snapshots.Opt
152165
if cr.Labels != nil {
@@ -276,6 +289,14 @@ func (s *service) Cleanup(ctx context.Context, cr *snapshotsapi.CleanupRequest)
276289
return empty, nil
277290
}
278291

292+
func (s *service) emitSnapshotterWarning(ctx context.Context, sn string) {
293+
switch sn {
294+
case "aufs":
295+
log.G(ctx).Warn("aufs snapshotter is deprecated")
296+
s.warnings.Emit(ctx, deprecation.AUFSSnapshotter)
297+
}
298+
}
299+
279300
func fromKind(kind snapshots.Kind) snapshotsapi.Kind {
280301
if kind == snapshots.KindActive {
281302
return snapshotsapi.Kind_ACTIVE

0 commit comments

Comments
 (0)