mirror of
https://gitee.com/milvus-io/milvus.git
synced 2025-12-07 17:48:29 +08:00
Fix mixture (#17332)
Signed-off-by: shaoyue.chen <shaoyue.chen@zilliz.com>
This commit is contained in:
parent
e0cbacba59
commit
7527285ec4
@ -284,6 +284,7 @@ func RunMilvus(args []string) {
|
|||||||
case typeutil.IndexNodeRole:
|
case typeutil.IndexNodeRole:
|
||||||
role.EnableIndexNode = true
|
role.EnableIndexNode = true
|
||||||
case typeutil.StandaloneRole, typeutil.EmbeddedRole:
|
case typeutil.StandaloneRole, typeutil.EmbeddedRole:
|
||||||
|
role.HasMultipleRoles = true
|
||||||
role.EnableRootCoord = true
|
role.EnableRootCoord = true
|
||||||
role.EnableProxy = true
|
role.EnableProxy = true
|
||||||
role.EnableQueryCoord = true
|
role.EnableQueryCoord = true
|
||||||
@ -294,6 +295,7 @@ func RunMilvus(args []string) {
|
|||||||
role.EnableIndexNode = true
|
role.EnableIndexNode = true
|
||||||
local = true
|
local = true
|
||||||
case roleMixture:
|
case roleMixture:
|
||||||
|
role.HasMultipleRoles = true
|
||||||
role.EnableRootCoord = enableRootCoord
|
role.EnableRootCoord = enableRootCoord
|
||||||
role.EnableQueryCoord = enableQueryCoord
|
role.EnableQueryCoord = enableQueryCoord
|
||||||
role.EnableDataCoord = enableDataCoord
|
role.EnableDataCoord = enableDataCoord
|
||||||
|
|||||||
@ -72,6 +72,7 @@ func stopRocksmq() {
|
|||||||
|
|
||||||
// MilvusRoles decides which components are brought up with Milvus.
|
// MilvusRoles decides which components are brought up with Milvus.
|
||||||
type MilvusRoles struct {
|
type MilvusRoles struct {
|
||||||
|
HasMultipleRoles bool
|
||||||
EnableRootCoord bool `env:"ENABLE_ROOT_COORD"`
|
EnableRootCoord bool `env:"ENABLE_ROOT_COORD"`
|
||||||
EnableProxy bool `env:"ENABLE_PROXY"`
|
EnableProxy bool `env:"ENABLE_PROXY"`
|
||||||
EnableQueryCoord bool `env:"ENABLE_QUERY_COORD"`
|
EnableQueryCoord bool `env:"ENABLE_QUERY_COORD"`
|
||||||
@ -107,7 +108,7 @@ func (mr *MilvusRoles) runRootCoord(ctx context.Context, localMsg bool) *compone
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
if !localMsg {
|
if !mr.HasMultipleRoles {
|
||||||
http.Handle(healthz.HealthzRouterPath, &componentsHealthzHandler{component: rc})
|
http.Handle(healthz.HealthzRouterPath, &componentsHealthzHandler{component: rc})
|
||||||
}
|
}
|
||||||
wg.Done()
|
wg.Done()
|
||||||
@ -139,7 +140,7 @@ func (mr *MilvusRoles) runProxy(ctx context.Context, localMsg bool, alias string
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
if !localMsg {
|
if !mr.HasMultipleRoles {
|
||||||
http.Handle(healthz.HealthzRouterPath, &componentsHealthzHandler{component: pn})
|
http.Handle(healthz.HealthzRouterPath, &componentsHealthzHandler{component: pn})
|
||||||
}
|
}
|
||||||
wg.Done()
|
wg.Done()
|
||||||
@ -170,7 +171,7 @@ func (mr *MilvusRoles) runQueryCoord(ctx context.Context, localMsg bool) *compon
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
if !localMsg {
|
if !mr.HasMultipleRoles {
|
||||||
http.Handle(healthz.HealthzRouterPath, &componentsHealthzHandler{component: qs})
|
http.Handle(healthz.HealthzRouterPath, &componentsHealthzHandler{component: qs})
|
||||||
}
|
}
|
||||||
wg.Done()
|
wg.Done()
|
||||||
@ -202,7 +203,7 @@ func (mr *MilvusRoles) runQueryNode(ctx context.Context, localMsg bool, alias st
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
if !localMsg {
|
if !mr.HasMultipleRoles {
|
||||||
http.Handle(healthz.HealthzRouterPath, &componentsHealthzHandler{component: qn})
|
http.Handle(healthz.HealthzRouterPath, &componentsHealthzHandler{component: qn})
|
||||||
}
|
}
|
||||||
wg.Done()
|
wg.Done()
|
||||||
@ -235,7 +236,7 @@ func (mr *MilvusRoles) runDataCoord(ctx context.Context, localMsg bool) *compone
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
if !localMsg {
|
if !mr.HasMultipleRoles {
|
||||||
http.Handle(healthz.HealthzRouterPath, &componentsHealthzHandler{component: ds})
|
http.Handle(healthz.HealthzRouterPath, &componentsHealthzHandler{component: ds})
|
||||||
}
|
}
|
||||||
wg.Done()
|
wg.Done()
|
||||||
@ -267,7 +268,7 @@ func (mr *MilvusRoles) runDataNode(ctx context.Context, localMsg bool, alias str
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
if !localMsg {
|
if !mr.HasMultipleRoles {
|
||||||
http.Handle(healthz.HealthzRouterPath, &componentsHealthzHandler{component: dn})
|
http.Handle(healthz.HealthzRouterPath, &componentsHealthzHandler{component: dn})
|
||||||
}
|
}
|
||||||
wg.Done()
|
wg.Done()
|
||||||
@ -299,7 +300,7 @@ func (mr *MilvusRoles) runIndexCoord(ctx context.Context, localMsg bool) *compon
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
if !localMsg {
|
if !mr.HasMultipleRoles {
|
||||||
http.Handle(healthz.HealthzRouterPath, &componentsHealthzHandler{component: is})
|
http.Handle(healthz.HealthzRouterPath, &componentsHealthzHandler{component: is})
|
||||||
}
|
}
|
||||||
wg.Done()
|
wg.Done()
|
||||||
@ -332,7 +333,7 @@ func (mr *MilvusRoles) runIndexNode(ctx context.Context, localMsg bool, alias st
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
if !localMsg {
|
if !mr.HasMultipleRoles {
|
||||||
http.Handle(healthz.HealthzRouterPath, &componentsHealthzHandler{component: in})
|
http.Handle(healthz.HealthzRouterPath, &componentsHealthzHandler{component: in})
|
||||||
}
|
}
|
||||||
wg.Done()
|
wg.Done()
|
||||||
@ -448,35 +449,45 @@ func (mr *MilvusRoles) Run(local bool, alias string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if local {
|
if mr.HasMultipleRoles {
|
||||||
standaloneHealthzHandler := func(w http.ResponseWriter, r *http.Request) {
|
multiRoleHealthzHandler := func(w http.ResponseWriter, r *http.Request) {
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
|
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
req := &internalpb.GetComponentStatesRequest{}
|
req := &internalpb.GetComponentStatesRequest{}
|
||||||
validateResp := func(resp *internalpb.ComponentStates, err error) bool {
|
validateResp := func(resp *internalpb.ComponentStates, err error) bool {
|
||||||
return err == nil && resp != nil && resp.GetState().GetStateCode() == internalpb.StateCode_Healthy
|
return err == nil && resp != nil && resp.GetState().GetStateCode() == internalpb.StateCode_Healthy
|
||||||
}
|
}
|
||||||
if rc == nil || !validateResp(rc.GetComponentStates(ctx, req)) {
|
if mr.EnableRootCoord {
|
||||||
rootCoordNotServingHandler(w, r)
|
if rc == nil || !validateResp(rc.GetComponentStates(ctx, req)) {
|
||||||
return
|
rootCoordNotServingHandler(w, r)
|
||||||
}
|
return
|
||||||
if qs == nil || !validateResp(qs.GetComponentStates(ctx, req)) {
|
}
|
||||||
queryCoordNotServingHandler(w, r)
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ds == nil || !validateResp(ds.GetComponentStates(ctx, req)) {
|
if mr.EnableQueryCoord {
|
||||||
dataCoordNotServingHandler(w, r)
|
if qs == nil || !validateResp(qs.GetComponentStates(ctx, req)) {
|
||||||
return
|
queryCoordNotServingHandler(w, r)
|
||||||
}
|
return
|
||||||
if is == nil || !validateResp(is.GetComponentStates(ctx, req)) {
|
}
|
||||||
indexCoordNotServingHandler(w, r)
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if pn == nil || !validateResp(pn.GetComponentStates(ctx, req)) {
|
if mr.EnableDataCoord {
|
||||||
proxyNotServingHandler(w, r)
|
if ds == nil || !validateResp(ds.GetComponentStates(ctx, req)) {
|
||||||
return
|
dataCoordNotServingHandler(w, r)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if mr.EnableIndexCoord {
|
||||||
|
if is == nil || !validateResp(is.GetComponentStates(ctx, req)) {
|
||||||
|
indexCoordNotServingHandler(w, r)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if mr.EnableProxy {
|
||||||
|
if pn == nil || !validateResp(pn.GetComponentStates(ctx, req)) {
|
||||||
|
proxyNotServingHandler(w, r)
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// TODO(dragondriver): need to check node state?
|
// TODO(dragondriver): need to check node state?
|
||||||
|
|
||||||
@ -490,7 +501,7 @@ func (mr *MilvusRoles) Run(local bool, alias string) {
|
|||||||
|
|
||||||
// TODO(dragondriver): handle component states
|
// TODO(dragondriver): handle component states
|
||||||
}
|
}
|
||||||
http.HandleFunc(healthz.HealthzRouterPath, standaloneHealthzHandler)
|
http.HandleFunc(healthz.HealthzRouterPath, multiRoleHealthzHandler)
|
||||||
}
|
}
|
||||||
|
|
||||||
metrics.ServeHTTP(Registry)
|
metrics.ServeHTTP(Registry)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user