From ab276b1c0914c475e9c900e80862e4b11ba21fe5 Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Sun, 19 Apr 2020 16:02:12 -0700 Subject: [PATCH] cgroups/fs2/Destroy: use Remove, ignore ENOENT 1. There is no need to try removing it recursively. 2. Do not treat ENOENT as an error (similar to fs and systemd v1 drivers). Signed-off-by: Kir Kolyshkin --- libcontainer/cgroups/fs2/fs2.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libcontainer/cgroups/fs2/fs2.go b/libcontainer/cgroups/fs2/fs2.go index d845a1b5ebe..93a2aa59d1a 100644 --- a/libcontainer/cgroups/fs2/fs2.go +++ b/libcontainer/cgroups/fs2/fs2.go @@ -142,7 +142,10 @@ func (m *manager) Freeze(state configs.FreezerState) error { } func (m *manager) Destroy() error { - return os.RemoveAll(m.dirPath) + if err := os.Remove(m.dirPath); err != nil && !os.IsNotExist(err) { + return err + } + return nil } // GetPaths is for compatibility purpose and should be removed in future