2016-07-27 14:17:44 -04:00
|
|
|
// +build !windows
|
|
|
|
|
2018-04-10 16:29:48 +02:00
|
|
|
package daemon // import "github.com/docker/docker/internal/test/daemon"
|
2016-07-27 14:17:44 -04:00
|
|
|
|
2016-08-23 16:50:15 -07:00
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"path/filepath"
|
|
|
|
|
2018-04-18 17:16:55 +02:00
|
|
|
"github.com/docker/docker/internal/test"
|
2017-05-23 10:22:32 -04:00
|
|
|
"golang.org/x/sys/unix"
|
2016-08-23 16:50:15 -07:00
|
|
|
)
|
|
|
|
|
2018-04-18 16:45:55 +02:00
|
|
|
func cleanupNetworkNamespace(t testingT, execRoot string) {
|
2018-04-18 17:16:55 +02:00
|
|
|
if ht, ok := t.(test.HelperT); ok {
|
|
|
|
ht.Helper()
|
|
|
|
}
|
2016-08-23 16:50:15 -07:00
|
|
|
// Cleanup network namespaces in the exec root of this
|
|
|
|
// daemon because this exec root is specific to this
|
|
|
|
// daemon instance and has no chance of getting
|
|
|
|
// cleaned up when a new daemon is instantiated with a
|
|
|
|
// new exec root.
|
|
|
|
netnsPath := filepath.Join(execRoot, "netns")
|
|
|
|
filepath.Walk(netnsPath, func(path string, info os.FileInfo, err error) error {
|
2018-10-05 11:10:28 -07:00
|
|
|
if err := unix.Unmount(path, unix.MNT_DETACH); err != nil && err != unix.EINVAL && err != unix.ENOENT {
|
2018-04-10 16:29:48 +02:00
|
|
|
t.Logf("unmount of %s failed: %v", path, err)
|
2016-08-23 16:50:15 -07:00
|
|
|
}
|
|
|
|
os.Remove(path)
|
|
|
|
return nil
|
|
|
|
})
|
|
|
|
}
|
2016-07-27 14:17:44 -04:00
|
|
|
|
2016-12-09 10:17:53 +01:00
|
|
|
// SignalDaemonDump sends a signal to the daemon to write a dump file
|
|
|
|
func SignalDaemonDump(pid int) {
|
2017-05-23 10:22:32 -04:00
|
|
|
unix.Kill(pid, unix.SIGQUIT)
|
2016-07-27 14:17:44 -04:00
|
|
|
}
|
2016-07-28 11:58:06 -04:00
|
|
|
|
|
|
|
func signalDaemonReload(pid int) error {
|
2017-05-23 10:22:32 -04:00
|
|
|
return unix.Kill(pid, unix.SIGHUP)
|
2016-07-28 11:58:06 -04:00
|
|
|
}
|