From 0cd1814feb9764e284670b2e209d90d0984742b1 Mon Sep 17 00:00:00 2001 From: yangk Date: Sun, 10 Nov 2024 21:42:44 +0800 Subject: [PATCH] fix: 503 service unavailable --- api/handler/service_check.go | 3 ++- pkg/interceptors/http.go | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/api/handler/service_check.go b/api/handler/service_check.go index 95c7c9df2..3f7dabc2f 100644 --- a/api/handler/service_check.go +++ b/api/handler/service_check.go @@ -21,6 +21,7 @@ package handler import ( "context" "fmt" + "github.com/goodrain/rainbond/pkg/component/etcd" "strings" "time" @@ -82,7 +83,7 @@ func (s *ServiceAction) GetServiceCheckInfo(uuid string) (*exector.ServiceCheckR var si exector.ServiceCheckResult ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second) defer cancel() - resp, err := s.EtcdCli.Get(ctx, k) + resp, err := etcd.Default().EtcdClient.Get(ctx, k) if err != nil { logrus.Errorf("get etcd k %s error, %v", k, err) return nil, util.CreateAPIHandleError(503, err) diff --git a/pkg/interceptors/http.go b/pkg/interceptors/http.go index ff994c2dd..92ab973d3 100644 --- a/pkg/interceptors/http.go +++ b/pkg/interceptors/http.go @@ -27,6 +27,7 @@ import ( "github.com/goodrain/rainbond/pkg/component/mq" "github.com/goodrain/rainbond/pkg/component/prom" "net/http" + "runtime/debug" "strings" ) @@ -35,6 +36,7 @@ func Recoverer(next http.Handler) http.Handler { fn := func(w http.ResponseWriter, r *http.Request) { defer func() { if rvr := recover(); rvr != nil && rvr != http.ErrAbortHandler { + debug.PrintStack() handleServiceUnavailable(w, r) } }()