Merge pull request #194 from LK4D4/fix_cgroups_again

Fix cgroups again
This commit is contained in:
Michael Crosby 2015-08-18 13:49:31 -07:00
commit b0ca535f75
2 changed files with 2 additions and 31 deletions

View File

@ -236,11 +236,11 @@ 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
}
relDir, err := filepath.Rel(initPath, src)
relDir, err := filepath.Rel(src, initPath)
if err != nil {
return "", err
}

View File

@ -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))
}
}