diff --git a/pkg/kubelet/util/swap/swap_util.go b/pkg/kubelet/util/swap/swap_util.go index c12f65b4d27..112e7647caf 100644 --- a/pkg/kubelet/util/swap/swap_util.go +++ b/pkg/kubelet/util/swap/swap_util.go @@ -110,8 +110,12 @@ func isSwapOnAccordingToProcSwaps(procSwapsContent []byte) bool { procSwapsLines := strings.Split(procSwapsStr, "\n") // If there is more than one line (table headers) in /proc/swaps then swap is enabled - klog.InfoS("Swap is on", "/proc/swaps contents", procSwapsStr) - return len(procSwapsLines) > 1 + isSwapOn := len(procSwapsLines) > 1 + if isSwapOn { + klog.InfoS("Swap is on", "/proc/swaps contents", procSwapsStr) + } + + return isSwapOn } // IsSwapOn detects whether swap in enabled on the system by inspecting