Skip to content

Commit 359b9ba

Browse files
authored
Merge pull request kubernetes#127325 from iholder101/swap/fix-swap-on-log
Swap: Fix misleading log about swap being on, even if it's actually off
2 parents a7702cb + b811af4 commit 359b9ba

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

pkg/kubelet/util/swap/swap_util.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,12 @@ func isSwapOnAccordingToProcSwaps(procSwapsContent []byte) bool {
110110
procSwapsLines := strings.Split(procSwapsStr, "\n")
111111

112112
// If there is more than one line (table headers) in /proc/swaps then swap is enabled
113-
klog.InfoS("Swap is on", "/proc/swaps contents", procSwapsStr)
114-
return len(procSwapsLines) > 1
113+
isSwapOn := len(procSwapsLines) > 1
114+
if isSwapOn {
115+
klog.InfoS("Swap is on", "/proc/swaps contents", procSwapsStr)
116+
}
117+
118+
return isSwapOn
115119
}
116120

117121
// IsSwapOn detects whether swap in enabled on the system by inspecting

0 commit comments

Comments
 (0)