Merge pull request #127325 from iholder101/swap/fix-swap-on-log

Swap: Fix misleading log about swap being on, even if it's actually off
This commit is contained in:
Kubernetes Prow Robot 2024-09-13 00:47:14 +01:00 committed by GitHub
commit 359b9ba9bf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -110,8 +110,12 @@ func isSwapOnAccordingToProcSwaps(procSwapsContent []byte) bool {
procSwapsLines := strings.Split(procSwapsStr, "\n") procSwapsLines := strings.Split(procSwapsStr, "\n")
// If there is more than one line (table headers) in /proc/swaps then swap is enabled // 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) isSwapOn := len(procSwapsLines) > 1
return 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 // IsSwapOn detects whether swap in enabled on the system by inspecting