Skip to content

Commit

Permalink
fix: 503 service unavailable
Browse files Browse the repository at this point in the history
  • Loading branch information
yangkaa committed Nov 10, 2024
1 parent ee9c127 commit 0cd1814
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion api/handler/service_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ package handler
import (
"context"
"fmt"
"github.com/goodrain/rainbond/pkg/component/etcd"
"strings"
"time"

Expand Down Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions pkg/interceptors/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"github.com/goodrain/rainbond/pkg/component/mq"
"github.com/goodrain/rainbond/pkg/component/prom"
"net/http"
"runtime/debug"
"strings"
)

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

0 comments on commit 0cd1814

Please sign in to comment.