Remove aufs snapshotter (deprecated since v1.5)

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
This commit is contained in:
Akihiro Suda
2023-03-14 14:32:42 +09:00
parent 689cd12ee6
commit 86fc1ccab4
20 changed files with 7 additions and 891 deletions

View File

@@ -51,22 +51,6 @@ func apply(ctx context.Context, mounts []mount.Mount, r io.Reader) error {
}
_, err = archive.Apply(ctx, path, r, opts...)
return err
case len(mounts) == 1 && mounts[0].Type == "aufs":
path, parents, err := getAufsPath(mounts[0].Options)
if err != nil {
if errdefs.IsInvalidArgument(err) {
break
}
return err
}
opts := []archive.ApplyOpt{
archive.WithConvertWhiteout(archive.AufsConvertWhiteout),
}
if len(parents) > 0 {
opts = append(opts, archive.WithParents(parents))
}
_, err = archive.Apply(ctx, path, r, opts...)
return err
}
return mount.WithTempMount(ctx, mounts, func(root string) error {
_, err := archive.Apply(ctx, root, r)
@@ -91,42 +75,3 @@ func getOverlayPath(options []string) (upper string, lower []string, err error)
return
}
// getAufsPath handles options as given by the containerd aufs package only,
// formatted as "br:<upper>=rw[:<lower>=ro+wh]*"
func getAufsPath(options []string) (upper string, lower []string, err error) {
const (
sep = ":"
brPrefix = "br:"
rwSuffix = "=rw"
roSuffix = "=ro+wh"
)
for _, o := range options {
if strings.HasPrefix(o, brPrefix) {
o = strings.TrimPrefix(o, brPrefix)
} else {
continue
}
for _, b := range strings.Split(o, sep) {
if strings.HasSuffix(b, rwSuffix) {
if upper != "" {
return "", nil, fmt.Errorf("multiple rw branch found: %w", errdefs.ErrInvalidArgument)
}
upper = strings.TrimSuffix(b, rwSuffix)
} else if strings.HasSuffix(b, roSuffix) {
if upper == "" {
return "", nil, fmt.Errorf("rw branch be first: %w", errdefs.ErrInvalidArgument)
}
lower = append(lower, strings.TrimSuffix(b, roSuffix))
} else {
return "", nil, fmt.Errorf("unhandled aufs suffix: %w", errdefs.ErrInvalidArgument)
}
}
}
if upper == "" {
return "", nil, fmt.Errorf("rw branch not found: %w", errdefs.ErrInvalidArgument)
}
return
}

View File

@@ -39,41 +39,3 @@ func TestGetOverlayPath(t *testing.T) {
t.Fatalf("An error is expected")
}
}
func TestGetAufsPath(t *testing.T) {
for _, test := range []struct {
options []string
expectErr bool
}{
{
options: []string{"random:option", "br:/test/rw=rw:/test/ro=ro+wh"},
expectErr: false,
},
{
options: []string{"random:option"},
expectErr: true,
},
{
options: []string{"br:/test/ro=ro+wh"},
expectErr: true,
},
} {
path, parents, err := getAufsPath(test.options)
if test.expectErr {
if err == nil {
t.Fatalf("An error is expected")
}
continue
}
if err != nil {
t.Fatalf("Get aufs path failed: %v", err)
}
if path != "/test/rw" {
t.Fatalf("Unexpected rw dir: %q", path)
}
if len(parents) != 1 || parents[0] != "/test/ro" {
t.Fatalf("Unexpected parents: %v", parents)
}
}
}