Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| ... | ... |
@@ -467,6 +467,10 @@ func (daemon *Daemon) cleanupMounts() error {
|
| 467 | 467 |
return nil |
| 468 | 468 |
} |
| 469 | 469 |
|
| 470 |
+func recursiveUnmount(_ string) error {
|
|
| 471 |
+ return nil |
|
| 472 |
+} |
|
| 473 |
+ |
|
| 470 | 474 |
func setupRemappedRoot(config *config.Config) (*idtools.IdentityMapping, error) {
|
| 471 | 475 |
return &idtools.IdentityMapping{}, nil
|
| 472 | 476 |
} |
| ... | ... |
@@ -12,7 +12,6 @@ import ( |
| 12 | 12 |
containertypes "github.com/docker/docker/api/types/container" |
| 13 | 13 |
"github.com/docker/docker/container" |
| 14 | 14 |
"github.com/docker/docker/errdefs" |
| 15 |
- "github.com/moby/sys/mount" |
|
| 16 | 15 |
"github.com/pkg/errors" |
| 17 | 16 |
"github.com/sirupsen/logrus" |
| 18 | 17 |
) |
| ... | ... |
@@ -253,7 +252,7 @@ func (daemon *Daemon) Cleanup(container *container.Container) {
|
| 253 | 253 |
logrus.Warnf("%s cleanup: failed to unmount secrets: %s", container.ID, err)
|
| 254 | 254 |
} |
| 255 | 255 |
|
| 256 |
- if err := mount.RecursiveUnmount(container.Root); err != nil {
|
|
| 256 |
+ if err := recursiveUnmount(container.Root); err != nil {
|
|
| 257 | 257 |
logrus.WithError(err).WithField("container", container.ID).Warn("Error while cleaning up container resource mounts.")
|
| 258 | 258 |
} |
| 259 | 259 |
|
| ... | ... |
@@ -23,7 +23,6 @@ import ( |
| 23 | 23 |
"github.com/docker/docker/pkg/system" |
| 24 | 24 |
v2 "github.com/docker/docker/plugin/v2" |
| 25 | 25 |
"github.com/docker/docker/registry" |
| 26 |
- "github.com/moby/sys/mount" |
|
| 27 | 26 |
digest "github.com/opencontainers/go-digest" |
| 28 | 27 |
specs "github.com/opencontainers/runtime-spec/specs-go" |
| 29 | 28 |
"github.com/pkg/errors" |
| ... | ... |
@@ -159,10 +158,8 @@ func (pm *Manager) HandleExitEvent(id string) error {
|
| 159 | 159 |
|
| 160 | 160 |
if restart {
|
| 161 | 161 |
pm.enable(p, c, true) |
| 162 |
- } else {
|
|
| 163 |
- if err := mount.RecursiveUnmount(filepath.Join(pm.config.Root, id)); err != nil {
|
|
| 164 |
- return errors.Wrap(err, "error cleaning up plugin mounts") |
|
| 165 |
- } |
|
| 162 |
+ } else if err := recursiveUnmount(filepath.Join(pm.config.Root, id)); err != nil {
|
|
| 163 |
+ return errors.Wrap(err, "error cleaning up plugin mounts") |
|
| 166 | 164 |
} |
| 167 | 165 |
return nil |
| 168 | 166 |
} |
| ... | ... |
@@ -24,7 +24,6 @@ import ( |
| 24 | 24 |
"github.com/docker/docker/testutil/request" |
| 25 | 25 |
"github.com/docker/go-connections/sockets" |
| 26 | 26 |
"github.com/docker/go-connections/tlsconfig" |
| 27 |
- "github.com/moby/sys/mount" |
|
| 28 | 27 |
"github.com/pkg/errors" |
| 29 | 28 |
"gotest.tools/v3/assert" |
| 30 | 29 |
) |
| ... | ... |
@@ -812,15 +811,6 @@ func (d *Daemon) Info(t testing.TB) types.Info {
|
| 812 | 812 |
return info |
| 813 | 813 |
} |
| 814 | 814 |
|
| 815 |
-// cleanupMount unmounts the daemon root directory, or logs a message if |
|
| 816 |
-// unmounting failed. |
|
| 817 |
-func cleanupMount(t testing.TB, d *Daemon) {
|
|
| 818 |
- t.Helper() |
|
| 819 |
- if err := mount.Unmount(d.Root); err != nil {
|
|
| 820 |
- d.log.Logf("[%s] unable to unmount daemon root (%s): %v", d.id, d.Root, err)
|
|
| 821 |
- } |
|
| 822 |
-} |
|
| 823 |
- |
|
| 824 | 815 |
// cleanupRaftDir removes swarmkit wal files if present |
| 825 | 816 |
func cleanupRaftDir(t testing.TB, d *Daemon) {
|
| 826 | 817 |
t.Helper() |
| ... | ... |
@@ -11,10 +11,20 @@ import ( |
| 11 | 11 |
"syscall" |
| 12 | 12 |
"testing" |
| 13 | 13 |
|
| 14 |
+ "github.com/docker/docker/pkg/mount" |
|
| 14 | 15 |
"golang.org/x/sys/unix" |
| 15 | 16 |
"gotest.tools/v3/assert" |
| 16 | 17 |
) |
| 17 | 18 |
|
| 19 |
+// cleanupMount unmounts the daemon root directory, or logs a message if |
|
| 20 |
+// unmounting failed. |
|
| 21 |
+func cleanupMount(t testing.TB, d *Daemon) {
|
|
| 22 |
+ t.Helper() |
|
| 23 |
+ if err := mount.Unmount(d.Root); err != nil {
|
|
| 24 |
+ d.log.Logf("[%s] unable to unmount daemon root (%s): %v", d.id, d.Root, err)
|
|
| 25 |
+ } |
|
| 26 |
+} |
|
| 27 |
+ |
|
| 18 | 28 |
func cleanupNetworkNamespace(t testing.TB, d *Daemon) {
|
| 19 | 29 |
t.Helper() |
| 20 | 30 |
// Cleanup network namespaces in the exec root of this |
| ... | ... |
@@ -24,6 +24,8 @@ func signalDaemonReload(pid int) error {
|
| 24 | 24 |
return fmt.Errorf("daemon reload not supported")
|
| 25 | 25 |
} |
| 26 | 26 |
|
| 27 |
+func cleanupMount(_ testing.TB, _ *Daemon) {}
|
|
| 28 |
+ |
|
| 27 | 29 |
func cleanupNetworkNamespace(_ testing.TB, _ *Daemon) {}
|
| 28 | 30 |
|
| 29 | 31 |
// CgroupNamespace returns the cgroup namespace the daemon is running in |
| ... | ... |
@@ -18,8 +18,6 @@ import ( |
| 18 | 18 |
"github.com/docker/docker/pkg/idtools" |
| 19 | 19 |
"github.com/docker/docker/quota" |
| 20 | 20 |
"github.com/docker/docker/volume" |
| 21 |
- "github.com/moby/sys/mount" |
|
| 22 |
- "github.com/moby/sys/mountinfo" |
|
| 23 | 21 |
"github.com/pkg/errors" |
| 24 | 22 |
"github.com/sirupsen/logrus" |
| 25 | 23 |
) |
| ... | ... |
@@ -96,9 +94,9 @@ func New(scope string, rootIdentity idtools.Identity) (*Root, error) {
|
| 96 | 96 |
if !reflect.DeepEqual(opts, optsConfig{}) {
|
| 97 | 97 |
v.opts = &opts |
| 98 | 98 |
} |
| 99 |
- |
|
| 100 |
- // unmount anything that may still be mounted (for example, from an unclean shutdown) |
|
| 101 |
- mount.Unmount(v.path) |
|
| 99 |
+ // unmount anything that may still be mounted (for example, from an |
|
| 100 |
+ // unclean shutdown). This is a no-op on windows |
|
| 101 |
+ unmount(v.path) |
|
| 102 | 102 |
} |
| 103 | 103 |
} |
| 104 | 104 |
|
| ... | ... |
@@ -347,18 +345,6 @@ func (v *localVolume) Unmount(id string) error {
|
| 347 | 347 |
return v.unmount() |
| 348 | 348 |
} |
| 349 | 349 |
|
| 350 |
-func (v *localVolume) unmount() error {
|
|
| 351 |
- if v.needsMount() {
|
|
| 352 |
- if err := mount.Unmount(v.path); err != nil {
|
|
| 353 |
- if mounted, mErr := mountinfo.Mounted(v.path); mounted || mErr != nil {
|
|
| 354 |
- return errdefs.System(err) |
|
| 355 |
- } |
|
| 356 |
- } |
|
| 357 |
- v.active.mounted = false |
|
| 358 |
- } |
|
| 359 |
- return nil |
|
| 360 |
-} |
|
| 361 |
- |
|
| 362 | 350 |
func (v *localVolume) Status() map[string]interface{} {
|
| 363 | 351 |
return nil |
| 364 | 352 |
} |
| ... | ... |
@@ -18,6 +18,7 @@ import ( |
| 18 | 18 |
"github.com/docker/docker/quota" |
| 19 | 19 |
units "github.com/docker/go-units" |
| 20 | 20 |
"github.com/moby/sys/mount" |
| 21 |
+ "github.com/moby/sys/mountinfo" |
|
| 21 | 22 |
"github.com/pkg/errors" |
| 22 | 23 |
) |
| 23 | 24 |
|
| ... | ... |
@@ -111,6 +112,10 @@ func validateOpts(opts map[string]string) error {
|
| 111 | 111 |
return nil |
| 112 | 112 |
} |
| 113 | 113 |
|
| 114 |
+func unmount(path string) {
|
|
| 115 |
+ _ = mount.Unmount(path) |
|
| 116 |
+} |
|
| 117 |
+ |
|
| 114 | 118 |
func (v *localVolume) needsMount() bool {
|
| 115 | 119 |
if v.opts == nil {
|
| 116 | 120 |
return false |
| ... | ... |
@@ -157,6 +162,18 @@ func (v *localVolume) postMount() error {
|
| 157 | 157 |
return nil |
| 158 | 158 |
} |
| 159 | 159 |
|
| 160 |
+func (v *localVolume) unmount() error {
|
|
| 161 |
+ if v.needsMount() {
|
|
| 162 |
+ if err := mount.Unmount(v.path); err != nil {
|
|
| 163 |
+ if mounted, mErr := mountinfo.Mounted(v.path); mounted || mErr != nil {
|
|
| 164 |
+ return errdefs.System(err) |
|
| 165 |
+ } |
|
| 166 |
+ } |
|
| 167 |
+ v.active.mounted = false |
|
| 168 |
+ } |
|
| 169 |
+ return nil |
|
| 170 |
+} |
|
| 171 |
+ |
|
| 160 | 172 |
func (v *localVolume) CreatedAt() (time.Time, error) {
|
| 161 | 173 |
fileInfo, err := os.Stat(v.path) |
| 162 | 174 |
if err != nil {
|
| ... | ... |
@@ -39,6 +39,11 @@ func (v *localVolume) needsMount() bool {
|
| 39 | 39 |
func (v *localVolume) mount() error {
|
| 40 | 40 |
return nil |
| 41 | 41 |
} |
| 42 |
+func (v *localVolume) unmount() error {
|
|
| 43 |
+ return nil |
|
| 44 |
+} |
|
| 45 |
+ |
|
| 46 |
+func unmount(_ string) {}
|
|
| 42 | 47 |
|
| 43 | 48 |
func (v *localVolume) postMount() error {
|
| 44 | 49 |
return nil |