From 6f3d8d39085e7dc31f757c0221eca7ab5f220224 Mon Sep 17 00:00:00 2001 From: Peter Waller Date: Mon, 27 Jan 2014 18:07:30 +0000 Subject: [PATCH 1/2] Fix for #3674 Can't `rm` containers when disk full Rather than creating a new directory and moving it there before deleting that new directory, just move the directory we intend to delete. In the old way, the Mkdirall could fail, which meant that you couldn't delete containers when the disk was full. Tested. Docker-DCO-1.1-Signed-off-by: Peter Waller (github: pwaller) --- graphdriver/aufs/aufs.go | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/graphdriver/aufs/aufs.go b/graphdriver/aufs/aufs.go index 8ab544eeba..d1cf87d1a0 100644 --- a/graphdriver/aufs/aufs.go +++ b/graphdriver/aufs/aufs.go @@ -192,20 +192,17 @@ func (a *Driver) Remove(id string) error { "diff", } - // Remove the dirs atomically + // Atomically remove each directory in turn by first moving it out of the + // way (so that docker doesn't find it anymore) before doing removal of + // the whole tree. for _, p := range tmpDirs { - // We need to use a temp dir in the same dir as the driver so Rename - // does not fall back to the slow copy if /tmp and the driver dir - // are on different devices - tmp := path.Join(a.rootPath(), "tmp", p, id) - if err := os.MkdirAll(tmp, 0755); err != nil { - return err - } + realPath := path.Join(a.rootPath(), p, id) - if err := os.Rename(realPath, tmp); err != nil && !os.IsNotExist(err) { + tmpPath := path.Join(a.rootPath(), p, fmt.Sprintf("%s-removing", id)) + if err := os.Rename(realPath, tmpPath); err != nil && !os.IsNotExist(err) { return err } - defer os.RemoveAll(tmp) + defer os.RemoveAll(tmpPath) } // Remove the layers file for the id From c4c558d138c43c6e2a48fd3060c4b8c81ace989b Mon Sep 17 00:00:00 2001 From: Peter Waller Date: Mon, 27 Jan 2014 21:47:49 +0000 Subject: [PATCH 2/2] Add Peter Waller to AUTHORS Docker-DCO-1.1-Signed-off-by: Peter Waller (github: pwaller) --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index 0985fed915..c865b49ecd 100644 --- a/AUTHORS +++ b/AUTHORS @@ -231,6 +231,7 @@ Paul Morie Paul Nasrat Paul Peter Braden +Peter Waller Phil Spitler Pierre-Alain RIVIERE Piotr Bogdan