From 8d212251079a5364e43493b1d8be77daa7242f11 Mon Sep 17 00:00:00 2001 From: skiffer-git <72860476+skiffer-git@users.noreply.github.com> Date: Fri, 8 Mar 2024 23:19:47 +0800 Subject: [PATCH] Bug: component check (#2053) * delete * add context deadline exceeded * Error not handled * Error not handled * Error not handled * Error not handled * configGetEnv failed,err:string to int failed: strconv.Atoi: parsing "openim_v3": invalid syntaxr * test Signed-off-by: unknown <44203734@qq.com> * fix bug: component check * fix bug: component check * fix bug: component check * fix bug: component check --------- Signed-off-by: unknown <44203734@qq.com> --- tools/component/component.go | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/tools/component/component.go b/tools/component/component.go index 6893ebf2ca..256f87038d 100644 --- a/tools/component/component.go +++ b/tools/component/component.go @@ -31,7 +31,6 @@ import ( "github.com/OpenIMSDK/tools/errs" "github.com/openimsdk/open-im-server/v3/pkg/common/config" - "gopkg.in/yaml.v3" ) @@ -94,7 +93,7 @@ func main() { if i != 0 { time.Sleep(1 * time.Second) } - fmt.Printf("Checking components Round %v...\n", i+1) + fmt.Printf("Checking components round %v...\n", i+1) var err error allSuccess := true @@ -103,28 +102,20 @@ func main() { err = check.function(check.config) if err != nil { if check.name == "Minio" { - if errors.Is(err, errMinioNotEnabled) { - fmt.Println(err.Error(), " check ", check.name) - checks[index].flag = true - } - if errors.Is(err, errSignEndPoint) { + if errors.Is(err, errMinioNotEnabled) || + errors.Is(err, errSignEndPoint) || + errors.Is(err, errApiURL) { fmt.Fprintf(os.Stderr, err.Error(), " check ", check.name) checks[index].flag = true + continue } } - - component.ErrorPrint(fmt.Sprintf("Starting %s failed:%v.", check.name, errs.Unwrap(err).Error())) - if strings.Contains(errs.Unwrap(err).Error(), "connection refused") || - strings.Contains(errs.Unwrap(err).Error(), "timeout") || - strings.Contains(errs.Unwrap(err).Error(), "context deadline exceeded") { - component.ErrorPrint(fmt.Sprintf("try check connection %s", check.name)) - allSuccess = false - break - } - } else { - checks[index].flag = true - component.SuccessPrint(fmt.Sprintf("%s connected successfully", check.name)) + allSuccess = false + component.ErrorPrint(fmt.Sprintf("Check component: %s failed:%v.", check.name, err.Error())) + break } + checks[index].flag = true + component.SuccessPrint(fmt.Sprintf("%s connected successfully", check.name)) } } @@ -133,7 +124,7 @@ func main() { return } } - component.ErrorPrint("Some components started failed!") + component.ErrorPrint("Some components checked failed!") os.Exit(-1) }