From 5aa60054985f53ef4aceba12c86a96c2e3686b29 Mon Sep 17 00:00:00 2001 From: Alexander Morozov Date: Tue, 11 Aug 2015 17:57:01 -0700 Subject: [PATCH 1/2] Revert "Fix cgroup parent searching" This reverts commit 2f9052ca29d0e148554088c72c40c95d3236fe04. Signed-off-by: Alexander Morozov --- libcontainer/cgroups/fs/apply_raw.go | 2 +- libcontainer/cgroups/fs/apply_raw_test.go | 29 ----------------------- 2 files changed, 1 insertion(+), 30 deletions(-) delete mode 100644 libcontainer/cgroups/fs/apply_raw_test.go diff --git a/libcontainer/cgroups/fs/apply_raw.go b/libcontainer/cgroups/fs/apply_raw.go index cd6c0a889..f75dab1be 100644 --- a/libcontainer/cgroups/fs/apply_raw.go +++ b/libcontainer/cgroups/fs/apply_raw.go @@ -240,7 +240,7 @@ func (raw *data) parent(subsystem, mountpoint, src string) (string, error) { if err != nil { return "", err } - relDir, err := filepath.Rel(initPath, src) + relDir, err := filepath.Rel(src, initPath) if err != nil { return "", err } diff --git a/libcontainer/cgroups/fs/apply_raw_test.go b/libcontainer/cgroups/fs/apply_raw_test.go deleted file mode 100644 index 50aff5912..000000000 --- a/libcontainer/cgroups/fs/apply_raw_test.go +++ /dev/null @@ -1,29 +0,0 @@ -package fs - -import ( - "path/filepath" - "testing" - - "github.com/opencontainers/runc/libcontainer/cgroups" -) - -func TestCgroupParent(t *testing.T) { - raw := &data{ - cgroup: "", - } - subsystem := "memory" - subPath := "/docker/874e38c82a6c630dc95f3f1f2c8d8f43efb531d35a9f46154ab2fde1531b7bb6" - initPath, err := cgroups.GetInitCgroupDir(subsystem) - if err != nil { - t.Fatal(err) - } - srcPath := filepath.Join(initPath, subPath) - cgPath := "/sys/fs/cgroup/memory" - path, err := raw.parent(subsystem, cgPath, srcPath) - if err != nil { - t.Fatal(err) - } - if path != filepath.Join(cgPath, subPath) { - t.Fatalf("Unexpected path: %s, should be %s", path, filepath.Join(cgPath, subPath)) - } -} From 2b28b3c2769c4b0519889bfad1ebb2db37b13469 Mon Sep 17 00:00:00 2001 From: Alexander Morozov Date: Tue, 11 Aug 2015 17:58:12 -0700 Subject: [PATCH 2/2] Always use cgroup root of current process Because for host PID namespace /proc/1/cgroup can point to whole other world of cgroups. Signed-off-by: Alexander Morozov --- libcontainer/cgroups/fs/apply_raw.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libcontainer/cgroups/fs/apply_raw.go b/libcontainer/cgroups/fs/apply_raw.go index f75dab1be..9f50d84b4 100644 --- a/libcontainer/cgroups/fs/apply_raw.go +++ b/libcontainer/cgroups/fs/apply_raw.go @@ -236,7 +236,7 @@ func getCgroupData(c *configs.Cgroup, pid int) (*data, error) { } func (raw *data) parent(subsystem, mountpoint, src string) (string, error) { - initPath, err := cgroups.GetInitCgroupDir(subsystem) + initPath, err := cgroups.GetThisCgroupDir(subsystem) if err != nil { return "", err }