Skip to content

Commit

Permalink
add check for cpu cfs bandwidth in validate endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
andyxning committed Mar 23, 2018
1 parent 189f5b9 commit 5e1b44b
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions validate/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"io/ioutil"
"log"
"net/http"
"os"
"path"
"strings"

Expand Down Expand Up @@ -133,6 +134,23 @@ func areCgroupsPresent(available map[string]int, desired []string) (bool, string
return true, ""
}

func validateCpuCfsBandwidth(available_cgroups map[string]int) string {
ok, _ := areCgroupsPresent(available_cgroups, []string{"cpu"})
if !ok {
return "\tCpu cfs bandwidth status unknown: cpu cgroup not enabled.\n"
}
mnt, err := cgroups.FindCgroupMountpoint("cpu")
if err != nil {
return "\tCpu cfs bandwidth status unknown: cpu cgroup not mounted.\n"
}
_, err = os.Stat(path.Join(mnt, "cpu.cfs_period_us"))
if os.IsNotExist(err) {
return "\tCpu cfs bandwidth is disabled. Recompile kernel with \"CONFIG_CFS_BANDWIDTH\" enabled.\n"
}

return "\tCpu cfs bandwidth is enabled.\n"
}

func validateMemoryAccounting(available_cgroups map[string]int) string {
ok, _ := areCgroupsPresent(available_cgroups, []string{"memory"})
if !ok {
Expand Down Expand Up @@ -181,6 +199,7 @@ func validateCgroups() (string, string) {
out = fmt.Sprintf("Available cgroups: %v\n", available_cgroups)
out += desc
out += validateMemoryAccounting(available_cgroups)
out += validateCpuCfsBandwidth(available_cgroups)
return Recommended, out
}

Expand Down

0 comments on commit 5e1b44b

Please sign in to comment.