mirror of
https://gitee.com/milvus-io/milvus.git
synced 2026-01-07 19:31:51 +08:00
issue: #38608 Signed-off-by: jaime <yun.zhang@zilliz.com>
This commit is contained in:
parent
984a605d47
commit
5afd0c0a2b
@ -1093,7 +1093,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.CheckHealthyStandby(s.GetStateCode()); err != nil {
|
||||
if err := merr.CheckHealthy(s.GetStateCode()); err != nil {
|
||||
msg := "failed to get metrics"
|
||||
log.Warn(msg, zap.Error(err))
|
||||
return &milvuspb.GetMetricsResponse{
|
||||
|
||||
@ -832,7 +832,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.CheckHealthyStandby(s.State()); err != nil {
|
||||
if err := merr.CheckHealthy(s.State()); err != nil {
|
||||
msg := "failed to get metrics"
|
||||
log.Warn(msg, zap.Error(err))
|
||||
return &milvuspb.GetMetricsResponse{
|
||||
|
||||
@ -1866,7 +1866,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.CheckHealthyStandby(c.GetStateCode()); err != nil {
|
||||
if err := merr.CheckHealthy(c.GetStateCode()); err != nil {
|
||||
return &milvuspb.GetMetricsResponse{
|
||||
Status: merr.Status(err),
|
||||
Response: "",
|
||||
|
||||
@ -273,18 +273,6 @@ 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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user