mirror of https://github.com/docker/docs.git
Do not try to cleanupMounts if daemon.repository is empty
Signed-off-by: Chun Chen <ramichen@tencent.com>
This commit is contained in:
parent
d6e7350b96
commit
213a0f9d86
|
@ -24,6 +24,9 @@ func (daemon *Daemon) cleanupMounts() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (daemon *Daemon) cleanupMountsFromReader(reader io.Reader, unmount func(target string) error) error {
|
func (daemon *Daemon) cleanupMountsFromReader(reader io.Reader, unmount func(target string) error) error {
|
||||||
|
if daemon.repository == "" {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
sc := bufio.NewScanner(reader)
|
sc := bufio.NewScanner(reader)
|
||||||
var errors []string
|
var errors []string
|
||||||
for sc.Scan() {
|
for sc.Scan() {
|
||||||
|
|
|
@ -56,3 +56,19 @@ func TestCleanupMounts(t *testing.T) {
|
||||||
t.Fatalf("Expected to unmount the mqueue")
|
t.Fatalf("Expected to unmount the mqueue")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestNotCleanupMounts(t *testing.T) {
|
||||||
|
d := &Daemon{
|
||||||
|
repository: "",
|
||||||
|
}
|
||||||
|
var unmounted bool
|
||||||
|
unmount := func(target string) error {
|
||||||
|
unmounted = true
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
mountInfo := `234 232 0:59 / /dev/shm rw,nosuid,nodev,noexec,relatime - tmpfs shm rw,size=65536k`
|
||||||
|
d.cleanupMountsFromReader(strings.NewReader(mountInfo), unmount)
|
||||||
|
if unmounted {
|
||||||
|
t.Fatalf("Expected not to clean up /dev/shm")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue