From b811af496c1b05ce5a0cc8d26432eaea309a788f Mon Sep 17 00:00:00 2001 From: Itamar Holder Date: Thu, 12 Sep 2024 18:23:25 +0300 Subject: [PATCH] fix misleading log about swap being on Currently, a log is triggered about swap being on even if swap is off. After this commit, the log would be triggered only if swap is truly turned on. Signed-off-by: Itamar Holder --- pkg/kubelet/util/swap/swap_util.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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