Skip to content

Commit

Permalink
Merge pull request #9255 from afbjorklund/cpus-cfs
Browse files Browse the repository at this point in the history
Make sure CFS_BANDWIDTH is available for --cpus
  • Loading branch information
medyagh authored Sep 15, 2020
2 parents b9f3638 + f718e39 commit 44c6f36
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion pkg/drivers/kic/oci/oci.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,24 @@ func CreateContainerNode(p CreateParams) error {
runArgs = append(runArgs, "--security-opt", "apparmor=unconfined")
}

runArgs = append(runArgs, fmt.Sprintf("--cpus=%s", p.CPUs))
cpuCfsPeriod := true
cpuCfsQuota := true
if runtime.GOOS == "linux" {
if _, err := os.Stat("/sys/fs/cgroup/cpu/cpu.cfs_period_us"); os.IsNotExist(err) {
cpuCfsPeriod = false
}
if _, err := os.Stat("/sys/fs/cgroup/cpu/cpu.cfs_quota_us"); os.IsNotExist(err) {
cpuCfsQuota = false
}
if !cpuCfsPeriod || !cpuCfsQuota {
// requires CONFIG_CFS_BANDWIDTH
glog.Warning("Your kernel does not support CPU cfs period/quota or the cgroup is not mounted.")
}
}

if cpuCfsPeriod && cpuCfsQuota {
runArgs = append(runArgs, fmt.Sprintf("--cpus=%s", p.CPUs))
}

memcgSwap := true
if runtime.GOOS == "linux" {
Expand Down

0 comments on commit 44c6f36

Please sign in to comment.