Skip to content

Commit

Permalink
simplify cgroup path lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
Mahmood Ali committed Dec 11, 2019
1 parent 596d0be commit c1ff6ec
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions drivers/shared/executor/executor_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
"github.com/hashicorp/nomad/plugins/drivers"
"github.com/opencontainers/runc/libcontainer"
"github.com/opencontainers/runc/libcontainer/cgroups"
cgroupFs "github.com/opencontainers/runc/libcontainer/cgroups/fs"
lconfigs "github.com/opencontainers/runc/libcontainer/configs"
ldevices "github.com/opencontainers/runc/libcontainer/devices"
lutils "github.com/opencontainers/runc/libcontainer/utils"
Expand Down Expand Up @@ -692,30 +691,21 @@ func configureBasicCgroups(cfg *lconfigs.Config) error {
id := uuid.Generate()

// Manually create freezer cgroup
cfg.Cgroups.Paths = map[string]string{}
root, err := cgroups.FindCgroupMountpointDir()
if err != nil {
return err
}

if _, err := os.Stat(root); err != nil {
return err
}
subsystem := "freezer"

freezer := cgroupFs.FreezerGroup{}
subsystem := freezer.Name()
path, err := cgroups.FindCgroupMountpoint("", subsystem)
path, err := getCgroupPathHelper(subsystem, filepath.Join(defaultCgroupParent, id))
if err != nil {
return fmt.Errorf("failed to find %s cgroup mountpoint: %v", subsystem, err)
}
// Sometimes subsystems can be mounted together as 'cpu,cpuacct'.
path = filepath.Join(root, filepath.Base(path), defaultCgroupParent, id)

if err = os.MkdirAll(path, 0755); err != nil {
return err
}

cfg.Cgroups.Paths[subsystem] = path
cfg.Cgroups.Paths = map[string]string{
subsystem: path,
}
return nil
}

Expand Down

0 comments on commit c1ff6ec

Please sign in to comment.