returnnil,fmt.Errorf("failed to get mounted cgroup subsystems: %v",err)
}
// Check whether swap is enabled. The Kubelet does not support running with swap enabled.
swapData,err:=ioutil.ReadFile("/proc/swaps")
iferr!=nil{
returnnil,err
}
swapData=bytes.TrimSpace(swapData)// extra trailing \n
swapLines:=strings.Split(string(swapData),"\n")
iffailSwapOn{
// Check whether swap is enabled. The Kubelet does not support running with swap enabled.
swapData,err:=ioutil.ReadFile("/proc/swaps")
iferr!=nil{
returnnil,err
}
swapData=bytes.TrimSpace(swapData)// extra trailing \n
swapLines:=strings.Split(string(swapData),"\n")
// If there is more than one line (table headers) in /proc/swaps, swap is enabled and we should
// error out unless --fail-swap-on is set to false.
iffailSwapOn&&len(swapLines)>1{
returnnil,fmt.Errorf("Running with swap on is not supported, please disable swap! or set --fail-swap-on flag to false. /proc/swaps contained: %v",swapLines)
// If there is more than one line (table headers) in /proc/swaps, swap is enabled and we should
// error out unless --fail-swap-on is set to false.
iflen(swapLines)>1{
returnnil,fmt.Errorf("Running with swap on is not supported, please disable swap! or set --fail-swap-on flag to false. /proc/swaps contained: %v",swapLines)
}
}
varcapacity=v1.ResourceList{}
// It is safe to invoke `MachineInfo` on cAdvisor before logically initializing cAdvisor here because
// machine info is computed and cached once as part of cAdvisor object creation.