From 0de52d5be82b43eb2cc03980015167abce39a013 Mon Sep 17 00:00:00 2001 From: SIGSEGV Date: Thu, 24 Dec 2020 16:19:43 +0800 Subject: [PATCH] Fix tail newline on thp check (#1005) Introduced by https://github.com/pingcap/tiup/pull/964 There is a newline at the end of output of cat command, so the '[never]' check will fail on the empty newline. --- pkg/cluster/operation/check.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/cluster/operation/check.go b/pkg/cluster/operation/check.go index 1bb62a435a..26f6280e7f 100644 --- a/pkg/cluster/operation/check.go +++ b/pkg/cluster/operation/check.go @@ -669,7 +669,7 @@ func CheckTHP(e executor.Executor) *CheckResult { return result } - for _, line := range strings.Split(string(stdout), "\n") { + for _, line := range strings.Split(strings.Trim(string(stdout), "\n"), "\n") { if !strings.Contains(line, "[never]") { result.Err = fmt.Errorf("THP is enabled, please disable it for best performance") return result