Skip to content

Commit

Permalink
cluster: try to disable swap when check --apply (#1803)
Browse files Browse the repository at this point in the history
  • Loading branch information
AstroProfundis committed Mar 28, 2022
1 parent 70dc546 commit 392f0ae
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pkg/cluster/manager/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,15 @@ func fixFailedChecks(host string, res *operator.CheckResult, t *task.Builder) (s
"",
true)
msg = fmt.Sprintf("will try to %s, please check again after reboot", color.HiBlueString("disable THP"))
case operator.CheckNameSwap:
// not applying swappiness setting here, it should be fixed
// in the sysctl check
// t.Sysctl(host, "vm.swappiness", "0")
t.Shell(host,
"swapoff -a || exit 0", // ignore failure
"", true,
)
msg = "will try to disable swap, please also check /etc/fstab manually"
default:
msg = fmt.Sprintf("%s, auto fixing not supported", res)
}
Expand Down
1 change: 1 addition & 0 deletions pkg/cluster/operation/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ func checkMem(opt *CheckOptions, memInfo *sysinfo.Memory) []*CheckResult {
if memInfo.Swap > 0 {
results = append(results, &CheckResult{
Name: CheckNameSwap,
Warn: true,
Err: fmt.Errorf("swap is enabled, please disable it for best performance"),
})
}
Expand Down

0 comments on commit 392f0ae

Please sign in to comment.