fix: 503 service unavailable

This commit is contained in:
yangk 2024-11-10 21:42:44 +08:00
parent ee9c127591
commit 0cd1814feb
2 changed files with 4 additions and 1 deletions

View File

@ -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)

View File

@ -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)
}
}()