Skip checking when failSwapOn=false

This commit is contained in:
linyouchong 2018-03-14 14:36:30 +08:00
parent 34001d8c6a
commit 32c265f60c

View File

@ -200,6 +200,7 @@ func NewContainerManager(mountUtil mount.Interface, cadvisorInterface cadvisor.I
return nil, fmt.Errorf("failed to get mounted cgroup subsystems: %v", err) return nil, fmt.Errorf("failed to get mounted cgroup subsystems: %v", err)
} }
if failSwapOn {
// Check whether swap is enabled. The Kubelet does not support running with swap enabled. // Check whether swap is enabled. The Kubelet does not support running with swap enabled.
swapData, err := ioutil.ReadFile("/proc/swaps") swapData, err := ioutil.ReadFile("/proc/swaps")
if err != nil { if err != nil {
@ -210,9 +211,11 @@ func NewContainerManager(mountUtil mount.Interface, cadvisorInterface cadvisor.I
// If there is more than one line (table headers) in /proc/swaps, swap is enabled and we should // 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. // error out unless --fail-swap-on is set to false.
if failSwapOn && len(swapLines) > 1 { if len(swapLines) > 1 {
return nil, 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) return nil, 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)
} }
}
var capacity = v1.ResourceList{} var capacity = v1.ResourceList{}
// It is safe to invoke `MachineInfo` on cAdvisor before logically initializing cAdvisor here because // 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. // machine info is computed and cached once as part of cAdvisor object creation.