Expose metrics of stanby coordinators (#27698)

Signed-off-by: wayblink <anyang.wang@zilliz.com>
pull/27728/head
wayblink 2023-10-16 15:04:09 +08:00 committed by GitHub
parent 43f2452f4b
commit e3f2122618
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 3 deletions

View File

@ -949,7 +949,7 @@ func (s *Server) ShowConfigurations(ctx context.Context, req *internalpb.ShowCon
// it may include SystemMetrics, Topology metrics, etc.
func (s *Server) GetMetrics(ctx context.Context, req *milvuspb.GetMetricsRequest) (*milvuspb.GetMetricsResponse, error) {
log := log.Ctx(ctx)
if err := merr.CheckHealthy(s.GetStateCode()); err != nil {
if err := merr.CheckHealthyStandby(s.GetStateCode()); err != nil {
return &milvuspb.GetMetricsResponse{
Status: merr.Status(err),
}, nil

View File

@ -735,7 +735,7 @@ func (s *Server) GetMetrics(ctx context.Context, req *milvuspb.GetMetricsRequest
log.RatedDebug(60, "get metrics request received",
zap.String("metricType", req.GetRequest()))
if err := merr.CheckHealthy(s.State()); err != nil {
if err := merr.CheckHealthyStandby(s.State()); err != nil {
msg := "failed to get metrics"
log.Warn(msg, zap.Error(err))
return &milvuspb.GetMetricsResponse{

View File

@ -1622,7 +1622,7 @@ func (c *Core) ShowConfigurations(ctx context.Context, req *internalpb.ShowConfi
// GetMetrics get metrics
func (c *Core) GetMetrics(ctx context.Context, in *milvuspb.GetMetricsRequest) (*milvuspb.GetMetricsResponse, error) {
if err := merr.CheckHealthy(c.GetStateCode()); err != nil {
if err := merr.CheckHealthyStandby(c.GetStateCode()); err != nil {
return &milvuspb.GetMetricsResponse{
Status: merr.Status(err),
Response: "",

View File

@ -228,6 +228,18 @@ func CheckHealthy(state commonpb.StateCode) error {
return nil
}
// CheckHealthyStandby checks whether the state is healthy or standby,
// returns nil if healthy or standby
// otherwise returns ErrServiceNotReady wrapped with current state
// this method only used in GetMetrics
func CheckHealthyStandby(state commonpb.StateCode) error {
if state != commonpb.StateCode_Healthy && state != commonpb.StateCode_StandBy {
return WrapErrServiceNotReady(paramtable.GetRole(), paramtable.GetNodeID(), state.String())
}
return nil
}
func IsHealthy(stateCode commonpb.StateCode) error {
if stateCode == commonpb.StateCode_Healthy {
return nil