File tree 1 file changed +18
-1
lines changed
1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -156,7 +156,24 @@ func CreateContainerNode(p CreateParams) error {
156
156
runArgs = append (runArgs , "--security-opt" , "apparmor=unconfined" )
157
157
}
158
158
159
- runArgs = append (runArgs , fmt .Sprintf ("--cpus=%s" , p .CPUs ))
159
+ cpuCfsPeriod := true
160
+ cpuCfsQuota := true
161
+ if runtime .GOOS == "linux" {
162
+ if _ , err := os .Stat ("/sys/fs/cgroup/cpu/cpu.cfs_period_us" ); os .IsNotExist (err ) {
163
+ cpuCfsPeriod = false
164
+ }
165
+ if _ , err := os .Stat ("/sys/fs/cgroup/cpu/cpu.cfs_quota_us" ); os .IsNotExist (err ) {
166
+ cpuCfsQuota = false
167
+ }
168
+ if ! cpuCfsPeriod || ! cpuCfsQuota {
169
+ // requires CONFIG_CFS_BANDWIDTH
170
+ glog .Warning ("Your kernel does not support CPU cfs period/quota or the cgroup is not mounted." )
171
+ }
172
+ }
173
+
174
+ if cpuCfsPeriod && cpuCfsQuota {
175
+ runArgs = append (runArgs , fmt .Sprintf ("--cpus=%s" , p .CPUs ))
176
+ }
160
177
161
178
memcgSwap := true
162
179
if runtime .GOOS == "linux" {
You can’t perform that action at this time.
0 commit comments