Skip to content

Commit

Permalink
Merge pull request #429 from hqhq/hq_use_FindCgroupMountRoot
Browse files Browse the repository at this point in the history
fix apply error when we not mount cpu subsystem
  • Loading branch information
rjnagal committed Mar 6, 2015
2 parents dd3cb88 + 07db66a commit 074441b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
4 changes: 1 addition & 3 deletions cgroups/fs/apply_raw.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions cgroups/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 074441b

Please sign in to comment.