Skip to content

Commit b811af4

Browse files
committed
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 <[email protected]>
1 parent 7ad1eaa commit b811af4

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)