Skip to content

Commit 834edad

Browse files
authored
Merge pull request #1913 from andyxning/add_check_for_cpu_cfs_bandwidth
add check for cpu cfs bandwidth in validate endpoint
2 parents 189f5b9 + 5e1b44b commit 834edad

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

validate/validate.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"io/ioutil"
2323
"log"
2424
"net/http"
25+
"os"
2526
"path"
2627
"strings"
2728

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

137+
func validateCpuCfsBandwidth(available_cgroups map[string]int) string {
138+
ok, _ := areCgroupsPresent(available_cgroups, []string{"cpu"})
139+
if !ok {
140+
return "\tCpu cfs bandwidth status unknown: cpu cgroup not enabled.\n"
141+
}
142+
mnt, err := cgroups.FindCgroupMountpoint("cpu")
143+
if err != nil {
144+
return "\tCpu cfs bandwidth status unknown: cpu cgroup not mounted.\n"
145+
}
146+
_, err = os.Stat(path.Join(mnt, "cpu.cfs_period_us"))
147+
if os.IsNotExist(err) {
148+
return "\tCpu cfs bandwidth is disabled. Recompile kernel with \"CONFIG_CFS_BANDWIDTH\" enabled.\n"
149+
}
150+
151+
return "\tCpu cfs bandwidth is enabled.\n"
152+
}
153+
136154
func validateMemoryAccounting(available_cgroups map[string]int) string {
137155
ok, _ := areCgroupsPresent(available_cgroups, []string{"memory"})
138156
if !ok {
@@ -181,6 +199,7 @@ func validateCgroups() (string, string) {
181199
out = fmt.Sprintf("Available cgroups: %v\n", available_cgroups)
182200
out += desc
183201
out += validateMemoryAccounting(available_cgroups)
202+
out += validateCpuCfsBandwidth(available_cgroups)
184203
return Recommended, out
185204
}
186205

0 commit comments

Comments
 (0)