diff options
author | Vincent Demeester <vincent.demeester@docker.com> | 2018-04-21 11:03:54 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-21 11:03:54 +0200 |
commit | 53982e3fc1642f2605189cea48bc6de7b9318611 (patch) | |
tree | 384eef152501c0e1e426400baa9d13c49ea99025 /volume | |
parent | cf9c48bb3ecf47ed56a4b7b466eda577913f838e (diff) | |
parent | ce468f0ad0d075c5d0c44c78bd61c489e6d7d70c (diff) | |
download | docker-53982e3fc1642f2605189cea48bc6de7b9318611.tar.gz |
Merge pull request #36091 from kolyshkin/mount
pkg/mount improvements
Diffstat (limited to 'volume')
-rw-r--r-- | volume/local/local.go | 13 | ||||
-rw-r--r-- | volume/local/local_test.go | 42 |
2 files changed, 21 insertions, 34 deletions
diff --git a/volume/local/local.go b/volume/local/local.go index df1299d668..226a5dd4fb 100644 --- a/volume/local/local.go +++ b/volume/local/local.go @@ -19,7 +19,6 @@ import ( "github.com/docker/docker/pkg/mount" "github.com/docker/docker/volume" "github.com/pkg/errors" - "github.com/sirupsen/logrus" ) // VolumeDataPathName is the name of the directory where the volume data is stored. @@ -66,11 +65,6 @@ func New(scope string, rootIDs idtools.IDPair) (*Root, error) { return nil, err } - mountInfos, err := mount.GetMounts() - if err != nil { - logrus.Debugf("error looking up mounts for local volume cleanup: %v", err) - } - for _, d := range dirs { if !d.IsDir() { continue @@ -96,12 +90,7 @@ func New(scope string, rootIDs idtools.IDPair) (*Root, error) { } // unmount anything that may still be mounted (for example, from an unclean shutdown) - for _, info := range mountInfos { - if info.Mountpoint == v.path { - mount.Unmount(v.path) - break - } - } + mount.Unmount(v.path) } } diff --git a/volume/local/local_test.go b/volume/local/local_test.go index e26fdd6386..d6f6e29171 100644 --- a/volume/local/local_test.go +++ b/volume/local/local_test.go @@ -184,6 +184,10 @@ func TestCreateWithOpts(t *testing.T) { if runtime.GOOS == "windows" { t.Skip() } + if os.Getuid() != 0 { + t.Skip("root required") + } + rootDir, err := ioutil.TempDir("", "local-volume-test") if err != nil { t.Fatal(err) @@ -215,33 +219,27 @@ func TestCreateWithOpts(t *testing.T) { } }() - mountInfos, err := mount.GetMounts() + mountInfos, err := mount.GetMounts(mount.SingleEntryFilter(dir)) if err != nil { t.Fatal(err) } - - var found bool - for _, info := range mountInfos { - if info.Mountpoint == dir { - found = true - if info.Fstype != "tmpfs" { - t.Fatalf("expected tmpfs mount, got %q", info.Fstype) - } - if info.Source != "tmpfs" { - t.Fatalf("expected tmpfs mount, got %q", info.Source) - } - if !strings.Contains(info.VfsOpts, "uid=1000") { - t.Fatalf("expected mount info to have uid=1000: %q", info.VfsOpts) - } - if !strings.Contains(info.VfsOpts, "size=1024k") { - t.Fatalf("expected mount info to have size=1024k: %q", info.VfsOpts) - } - break - } + if len(mountInfos) != 1 { + t.Fatalf("expected 1 mount, found %d: %+v", len(mountInfos), mountInfos) } - if !found { - t.Fatal("mount not found") + info := mountInfos[0] + t.Logf("%+v", info) + if info.Fstype != "tmpfs" { + t.Fatalf("expected tmpfs mount, got %q", info.Fstype) + } + if info.Source != "tmpfs" { + t.Fatalf("expected tmpfs mount, got %q", info.Source) + } + if !strings.Contains(info.VfsOpts, "uid=1000") { + t.Fatalf("expected mount info to have uid=1000: %q", info.VfsOpts) + } + if !strings.Contains(info.VfsOpts, "size=1024k") { + t.Fatalf("expected mount info to have size=1024k: %q", info.VfsOpts) } if v.active.count != 1 { |