Skip to content

Commit fef6bb8

Browse files
authored
Merge pull request containerd#5204 from thaJeztah/overlayutils
move overlay-checks to an overlayutils package
2 parents 2755ead + ba8f984 commit fef6bb8

File tree

5 files changed

+13
-11
lines changed

5 files changed

+13
-11
lines changed

archive/tar_linux_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import (
3131
"github.com/containerd/containerd/log/logtest"
3232
"github.com/containerd/containerd/mount"
3333
"github.com/containerd/containerd/pkg/testutil"
34-
"github.com/containerd/containerd/snapshots/overlay"
34+
"github.com/containerd/containerd/snapshots/overlay/overlayutils"
3535
"github.com/containerd/continuity/fs"
3636
"github.com/containerd/continuity/fs/fstest"
3737
"github.com/pkg/errors"
@@ -46,7 +46,7 @@ func TestOverlayApply(t *testing.T) {
4646
}
4747
defer os.RemoveAll(base)
4848

49-
if err := overlay.Supported(base); err != nil {
49+
if err := overlayutils.Supported(base); err != nil {
5050
t.Skipf("skipping because overlay is not supported %v", err)
5151
}
5252
fstest.FSSuite(t, overlayDiffApplier{
@@ -65,7 +65,7 @@ func TestOverlayApplyNoParents(t *testing.T) {
6565
}
6666
defer os.RemoveAll(base)
6767

68-
if err := overlay.Supported(base); err != nil {
68+
if err := overlayutils.Supported(base); err != nil {
6969
t.Skipf("skipping because overlay is not supported %v", err)
7070
}
7171
fstest.FSSuite(t, overlayDiffApplier{

snapshots/overlay/overlay.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import (
3030
"github.com/containerd/containerd/log"
3131
"github.com/containerd/containerd/mount"
3232
"github.com/containerd/containerd/snapshots"
33+
"github.com/containerd/containerd/snapshots/overlay/overlayutils"
3334
"github.com/containerd/containerd/snapshots/storage"
3435
"github.com/containerd/continuity/fs"
3536
"github.com/pkg/errors"
@@ -98,7 +99,7 @@ func NewSnapshotter(root string, opts ...Opt) (snapshots.Snapshotter, error) {
9899
}
99100

100101
// figure out whether "userxattr" option is recognized by the kernel && needed
101-
userxattr, err := NeedsUserXAttr(root)
102+
userxattr, err := overlayutils.NeedsUserXAttr(root)
102103
if err != nil {
103104
logrus.WithError(err).Warnf("cannot detect whether \"userxattr\" option needs to be used, assuming to be %v", userxattr)
104105
}

snapshots/overlay/overlay_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import (
3030
"github.com/containerd/containerd/mount"
3131
"github.com/containerd/containerd/pkg/testutil"
3232
"github.com/containerd/containerd/snapshots"
33+
"github.com/containerd/containerd/snapshots/overlay/overlayutils"
3334
"github.com/containerd/containerd/snapshots/storage"
3435
"github.com/containerd/containerd/snapshots/testsuite"
3536
)
@@ -177,7 +178,7 @@ func testOverlayOverlayMount(t *testing.T, newSnapshotter testsuite.SnapshotterF
177178
expected := []string{
178179
"index=off",
179180
}
180-
if userxattr, err := NeedsUserXAttr(root); err != nil {
181+
if userxattr, err := overlayutils.NeedsUserXAttr(root); err != nil {
181182
t.Fatal(err)
182183
} else if userxattr {
183184
expected = append(expected, "userxattr")
@@ -346,7 +347,7 @@ func testOverlayView(t *testing.T, newSnapshotter testsuite.SnapshotterFunc) {
346347
}
347348

348349
expectedOptions := 2
349-
userxattr, err := NeedsUserXAttr(root)
350+
userxattr, err := overlayutils.NeedsUserXAttr(root)
350351
if err != nil {
351352
t.Fatal(err)
352353
}
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
limitations under the License.
1717
*/
1818

19-
package overlay
19+
package overlayutils
2020

2121
import (
2222
"fmt"
@@ -31,14 +31,14 @@ import (
3131
"github.com/pkg/errors"
3232
)
3333

34-
// supportsMultipleLowerDir checks if the system supports multiple lowerdirs,
34+
// SupportsMultipleLowerDir checks if the system supports multiple lowerdirs,
3535
// which is required for the overlay snapshotter. On 4.x kernels, multiple lowerdirs
3636
// are always available (so this check isn't needed), and backported to RHEL and
3737
// CentOS 3.x kernels (3.10.0-693.el7.x86_64 and up). This function is to detect
3838
// support on those kernels, without doing a kernel version compare.
3939
//
4040
// Ported from moby overlay2.
41-
func supportsMultipleLowerDir(d string) error {
41+
func SupportsMultipleLowerDir(d string) error {
4242
td, err := ioutil.TempDir(d, "multiple-lowerdir-check")
4343
if err != nil {
4444
return err
@@ -85,7 +85,7 @@ func Supported(root string) error {
8585
if !supportsDType {
8686
return fmt.Errorf("%s does not support d_type. If the backing filesystem is xfs, please reformat with ftype=1 to enable d_type support", root)
8787
}
88-
return supportsMultipleLowerDir(root)
88+
return SupportsMultipleLowerDir(root)
8989
}
9090

9191
// NeedsUserXAttr returns whether overlayfs should be mounted with the "userxattr" mount option.

snapshots/overlay/check_test.go renamed to snapshots/overlay/overlayutils/check_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
limitations under the License.
1717
*/
1818

19-
package overlay
19+
package overlayutils
2020

2121
import (
2222
"io/ioutil"

0 commit comments

Comments
 (0)