Skip to content

Commit 1fe7a95

Browse files
committed
testutil/daemon: daemon.Cleanup(): unmount daemon root-dir as part of cleanup
test-daemons remove their docker.pid when stopped, so the `.integration-daemon-stop` script did not find the mounts for those daemons, and therefore was not unmounting them. As a result, cleaning up the bundles directory on consecutive runs of the tests would fail; rm: cannot remove 'bundles/test-integration/TestDockerSwarmSuite/TestSwarmInit/d1f188f3f5472/root': Device or resource busy This patch unmounts the root directory of the daemon as part of the cleanup step. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 parent 9407a57 commit 1fe7a95

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

testutil/daemon/daemon.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"github.com/docker/docker/client"
2020
"github.com/docker/docker/opts"
2121
"github.com/docker/docker/pkg/ioutils"
22+
"github.com/docker/docker/pkg/mount"
2223
"github.com/docker/docker/pkg/stringid"
2324
"github.com/docker/docker/testutil/request"
2425
"github.com/docker/go-connections/sockets"
@@ -213,6 +214,7 @@ func (d *Daemon) NewClient(extraOpts ...client.Opt) (*client.Client, error) {
213214
// Cleanup cleans the daemon files : exec root (network namespaces, ...), swarmkit files
214215
func (d *Daemon) Cleanup(t testing.TB) {
215216
t.Helper()
217+
cleanupMount(t, d)
216218
// Cleanup swarmkit wal files if present
217219
cleanupRaftDir(t, d.Root)
218220
cleanupNetworkNamespace(t, d.execRoot)
@@ -710,6 +712,15 @@ func (d *Daemon) Info(t testing.TB) types.Info {
710712
return info
711713
}
712714

715+
// cleanupMount unmounts the daemon root directory, or logs a message if
716+
// unmounting failed.
717+
func cleanupMount(t testing.TB, d *Daemon) {
718+
t.Helper()
719+
if err := mount.Unmount(d.Root); err != nil {
720+
d.log.Logf("[%s] unable to unmount daemon root (%s): %v", d.id, d.Root, err)
721+
}
722+
}
723+
713724
func cleanupRaftDir(t testing.TB, rootPath string) {
714725
t.Helper()
715726
for _, p := range []string{"wal", "wal-v3-encrypted", "snap-v3-encrypted"} {

0 commit comments

Comments
 (0)