Merge pull request #1913 from andyxning/add_check_for_cpu_cfs_bandwidth
add check for cpu cfs bandwidth in validate endpoint
This commit is contained in:
commit
834edaddc4
@ -22,6 +22,7 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@ -133,6 +134,23 @@ func areCgroupsPresent(available map[string]int, desired []string) (bool, string
|
|||||||
return true, ""
|
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 {
|
func validateMemoryAccounting(available_cgroups map[string]int) string {
|
||||||
ok, _ := areCgroupsPresent(available_cgroups, []string{"memory"})
|
ok, _ := areCgroupsPresent(available_cgroups, []string{"memory"})
|
||||||
if !ok {
|
if !ok {
|
||||||
@ -181,6 +199,7 @@ func validateCgroups() (string, string) {
|
|||||||
out = fmt.Sprintf("Available cgroups: %v\n", available_cgroups)
|
out = fmt.Sprintf("Available cgroups: %v\n", available_cgroups)
|
||||||
out += desc
|
out += desc
|
||||||
out += validateMemoryAccounting(available_cgroups)
|
out += validateMemoryAccounting(available_cgroups)
|
||||||
|
out += validateCpuCfsBandwidth(available_cgroups)
|
||||||
return Recommended, out
|
return Recommended, out
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user