Merge pull request #429 from hqhq/hq_use_FindCgroupMountRoot

fix apply error when we not mount cpu subsystem
This commit is contained in:
Rohit Jnagal
2015-03-06 10:11:16 -08:00
2 changed files with 16 additions and 3 deletions
+1 -3
View File
@@ -54,12 +54,10 @@ func getCgroupRoot() (string, error) {
return cgroupRoot, nil
}
// we can pick any subsystem to find the root
cpuRoot, err := cgroups.FindCgroupMountpoint("cpu")
root, err := cgroups.FindCgroupMountpointDir()
if err != nil {
return "", err
}
root := filepath.Dir(cpuRoot)
if _, err := os.Stat(root); err != nil {
return "", err
+15
View File
@@ -34,6 +34,21 @@ func FindCgroupMountpoint(subsystem string) (string, error) {
return "", NewNotFoundError(subsystem)
}
func FindCgroupMountpointDir() (string, error) {
mounts, err := mount.GetMounts()
if err != nil {
return "", err
}
for _, mount := range mounts {
if mount.Fstype == "cgroup" {
return filepath.Dir(mount.Mountpoint), nil
}
}
return "", NewNotFoundError("cgroup")
}
type Mount struct {
Mountpoint string
Subsystems []string