mirror of https://github.com/milvus-io/milvus.git
Standalone healthz check include proxy and coordinator state check (#12812)
Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>pull/12868/head
parent
83c06e4327
commit
d68f7602e5
|
@ -51,3 +51,7 @@ func dataCoordNotServingHandler(w http.ResponseWriter, r *http.Request) {
|
|||
func indexCoordNotServingHandler(w http.ResponseWriter, r *http.Request) {
|
||||
componentsNotServingHandler(w, r, milvuserrors.MsgIndexCoordNotServing)
|
||||
}
|
||||
|
||||
func proxyNotServingHandler(w http.ResponseWriter, r *http.Request) {
|
||||
componentsNotServingHandler(w, r, milvuserrors.MsgProxyNotServing)
|
||||
}
|
||||
|
|
|
@ -26,7 +26,9 @@ import (
|
|||
"strings"
|
||||
"sync"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/milvus-io/milvus/internal/proto/internalpb"
|
||||
"github.com/milvus-io/milvus/internal/util/healthz"
|
||||
"github.com/milvus-io/milvus/internal/util/rocksmq/server/rocksmq"
|
||||
|
||||
|
@ -417,22 +419,34 @@ func (mr *MilvusRoles) Run(localMsg bool, alias string) {
|
|||
|
||||
if localMsg {
|
||||
standaloneHealthzHandler := func(w http.ResponseWriter, r *http.Request) {
|
||||
if rc == nil {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
|
||||
defer cancel()
|
||||
req := &internalpb.GetComponentStatesRequest{}
|
||||
validateResp := func(resp *internalpb.ComponentStates, err error) bool {
|
||||
return err == nil && resp != nil && resp.GetState().GetStateCode() == internalpb.StateCode_Healthy
|
||||
}
|
||||
if rc == nil || !validateResp(rc.GetComponentStates(ctx, req)) {
|
||||
rootCoordNotServingHandler(w, r)
|
||||
return
|
||||
}
|
||||
if qs == nil {
|
||||
if qs == nil || !validateResp(qs.GetComponentStates(ctx, req)) {
|
||||
queryCoordNotServingHandler(w, r)
|
||||
return
|
||||
}
|
||||
if ds == nil {
|
||||
|
||||
if ds == nil || !validateResp(ds.GetComponentStates(ctx, req)) {
|
||||
dataCoordNotServingHandler(w, r)
|
||||
return
|
||||
}
|
||||
if is == nil {
|
||||
if is == nil || !validateResp(is.GetComponentStates(ctx, req)) {
|
||||
indexCoordNotServingHandler(w, r)
|
||||
return
|
||||
}
|
||||
|
||||
if pn == nil || !validateResp(pn.GetComponentStates(ctx, req)) {
|
||||
proxyNotServingHandler(w, r)
|
||||
return
|
||||
}
|
||||
// TODO(dragondriver): need to check node state?
|
||||
|
||||
w.WriteHeader(http.StatusOK)
|
||||
|
|
|
@ -25,6 +25,8 @@ const (
|
|||
MsgDataCoordNotServing = "data coordinator is not serving"
|
||||
// MsgIndexCoordNotServing means that index coordinator not serving
|
||||
MsgIndexCoordNotServing = "index coordinator is not serving"
|
||||
// MsgProxyNotServing means that proxy node not serving
|
||||
MsgProxyNotServing = "proxy node is not serving"
|
||||
)
|
||||
|
||||
// MsgCollectionAlreadyExist is used to construct an error message of collection already exist
|
||||
|
|
Loading…
Reference in New Issue