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 <iholder@redhat.com>
This commit is contained in:
Itamar Holder 2024-09-12 18:23:25 +03:00
parent 7ad1eaa66b
commit b811af496c

View File

@ -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