From fc2b41c4885900ec5a6b7ed7d85116b79f0c21b4 Mon Sep 17 00:00:00 2001 From: Allen Zhong Date: Wed, 28 Apr 2021 12:18:08 +0800 Subject: [PATCH 1/2] cluster: fix and optimize os version check --- pkg/cluster/operation/check.go | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/pkg/cluster/operation/check.go b/pkg/cluster/operation/check.go index 6462ca9ce7..257de21b88 100644 --- a/pkg/cluster/operation/check.go +++ b/pkg/cluster/operation/check.go @@ -150,15 +150,33 @@ func checkOSInfo(opt *CheckOptions, osInfo *sysinfo.OS) *CheckResult { // check OS vendor switch osInfo.Vendor { - case "centos", "redhat": + case "centos", "redhat", "rhel": // check version if ver, _ := strconv.Atoi(osInfo.Version); ver < 7 { result.Err = fmt.Errorf("%s %s not supported, use version 7 or higher", osInfo.Name, osInfo.Release) return result } - case "debian", "ubuntu": - // check version + case "debian": + // debian support is not fully tested, but we suppose it should work + result.Err = fmt.Errorf("debian support is not fully tested, be careful") + result.Warn = true + if ver, _ := strconv.Atoi(osInfo.Version); ver < 9 { + result.Err = fmt.Errorf("%s %s not supported, use version 9 or higher (%s)", + osInfo.Name, osInfo.Release, result.Err) + result.Warn = false + return result + } + case "ubuntu": + // ubuntu support is not fully tested, but we suppose it should work + result.Err = fmt.Errorf("ubuntu support is not fully tested, be careful") + result.Warn = true + if ver, _ := strconv.ParseFloat(osInfo.Version, 64); ver < 18.04 { + result.Err = fmt.Errorf("%s %s not supported, use version 18.04 or higher (%s)", + osInfo.Name, osInfo.Release, result.Err) + result.Warn = false + return result + } default: result.Err = fmt.Errorf("os vendor %s not supported", osInfo.Vendor) return result From 5fd4a488de5f22ce60cbf33979e11107efc0250f Mon Sep 17 00:00:00 2001 From: Allen Zhong Date: Wed, 28 Apr 2021 12:31:31 +0800 Subject: [PATCH 2/2] cluster: adjust check warning message --- pkg/cluster/operation/check.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/pkg/cluster/operation/check.go b/pkg/cluster/operation/check.go index 257de21b88..001c336c32 100644 --- a/pkg/cluster/operation/check.go +++ b/pkg/cluster/operation/check.go @@ -159,21 +159,23 @@ func checkOSInfo(opt *CheckOptions, osInfo *sysinfo.OS) *CheckResult { } case "debian": // debian support is not fully tested, but we suppose it should work - result.Err = fmt.Errorf("debian support is not fully tested, be careful") + msg := "debian support is not fully tested, be careful" + result.Err = fmt.Errorf("%s (%s)", result.Msg, msg) result.Warn = true if ver, _ := strconv.Atoi(osInfo.Version); ver < 9 { result.Err = fmt.Errorf("%s %s not supported, use version 9 or higher (%s)", - osInfo.Name, osInfo.Release, result.Err) + osInfo.Name, osInfo.Release, msg) result.Warn = false return result } case "ubuntu": // ubuntu support is not fully tested, but we suppose it should work - result.Err = fmt.Errorf("ubuntu support is not fully tested, be careful") + msg := "ubuntu support is not fully tested, be careful" + result.Err = fmt.Errorf("%s (%s)", result.Msg, msg) result.Warn = true if ver, _ := strconv.ParseFloat(osInfo.Version, 64); ver < 18.04 { result.Err = fmt.Errorf("%s %s not supported, use version 18.04 or higher (%s)", - osInfo.Name, osInfo.Release, result.Err) + osInfo.Name, osInfo.Release, msg) result.Warn = false return result }