enhance:add some log when create client and get component states (#28160)

/kind improvement

Signed-off-by: lixinguo <xinguo.li@zilliz.com>
Co-authored-by: lixinguo <xinguo.li@zilliz.com>
This commit is contained in:
smellthemoon 2023-11-22 09:12:22 +08:00 committed by GitHub
parent 2fc743992a
commit 73f2bab454
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 21 additions and 3 deletions

View File

@ -619,6 +619,7 @@ func (s *Server) GetStateCode() commonpb.StateCode {
// GetComponentStates returns DataCoord's current state
func (s *Server) GetComponentStates(ctx context.Context, req *milvuspb.GetComponentStatesRequest) (*milvuspb.ComponentStates, error) {
code := s.GetStateCode()
log.Debug("DataCoord current state", zap.String("StateCode", code.String()))
nodeID := common.NotRegisteredID
if s.session != nil && s.session.Registered() {
nodeID = s.session.GetServerID() // or Params.NodeID

View File

@ -67,8 +67,9 @@ func (node *DataNode) WatchDmChannels(ctx context.Context, in *datapb.WatchDmCha
// GetComponentStates will return current state of DataNode
func (node *DataNode) GetComponentStates(ctx context.Context, req *milvuspb.GetComponentStatesRequest) (*milvuspb.ComponentStates, error) {
log.Debug("DataNode current state", zap.Any("State", node.stateCode.Load()))
nodeID := common.NotRegisteredID
state := node.stateCode.Load().(commonpb.StateCode)
log.Debug("DataNode current state", zap.String("State", state.String()))
if node.GetSession() != nil && node.session.Registered() {
nodeID = node.GetSession().ServerID
}

View File

@ -87,7 +87,10 @@ func (c *Client) getDataCoordAddr() (string, error) {
log.Debug("DataCoordClient, not existed in msess ", zap.Any("key", key), zap.Any("len of msess", len(msess)))
return "", fmt.Errorf("find no available datacoord, check datacoord state")
}
log.Debug("DataCoordClient GetSessions success",
zap.String("address", ms.Address),
zap.Int64("serverID", ms.ServerID),
)
c.grpcClient.SetNodeID(ms.ServerID)
return ms.Address, nil
}

View File

@ -77,6 +77,11 @@ func (c *Client) getQueryCoordAddr() (string, error) {
log.Debug("QueryCoordClient msess key not existed", zap.Any("key", key))
return "", fmt.Errorf("find no available querycoord, check querycoord state")
}
log.Debug("QueryCoordClient GetSessions success",
zap.String("address", ms.Address),
zap.Int64("serverID", ms.ServerID),
)
c.grpcClient.SetNodeID(ms.ServerID)
return ms.Address, nil
}

View File

@ -69,6 +69,7 @@ func (node *Proxy) GetComponentStates(ctx context.Context, req *milvuspb.GetComp
Status: merr.Success(),
}
code := node.GetStateCode()
log.Debug("Proxy current state", zap.String("StateCode", code.String()))
nodeID := common.NotRegisteredID
if node.session != nil && node.session.Registered() {
nodeID = node.session.ServerID

View File

@ -531,6 +531,7 @@ func (s *Server) State() commonpb.StateCode {
}
func (s *Server) GetComponentStates(ctx context.Context, req *milvuspb.GetComponentStatesRequest) (*milvuspb.ComponentStates, error) {
log.Debug("QueryCoord current state", zap.String("StateCode", s.State().String()))
nodeID := common.NotRegisteredID
if s.session != nil && s.session.Registered() {
nodeID = s.session.GetServerID()

View File

@ -64,6 +64,8 @@ func (node *QueryNode) GetComponentStates(ctx context.Context, req *milvuspb.Get
code := node.lifetime.GetState()
nodeID := common.NotRegisteredID
log.Debug("QueryNode current state", zap.Int64("NodeID", nodeID), zap.String("StateCode", code.String()))
if node.session != nil && node.session.Registered() {
nodeID = paramtable.GetNodeID()
}

View File

@ -759,6 +759,7 @@ func (c *Core) Stop() error {
// GetComponentStates get states of components
func (c *Core) GetComponentStates(ctx context.Context, req *milvuspb.GetComponentStatesRequest) (*milvuspb.ComponentStates, error) {
code := c.GetStateCode()
log.Debug("RootCoord current state", zap.String("StateCode", code.String()))
nodeID := common.NotRegisteredID
if c.session != nil && c.session.Registered() {

View File

@ -21,10 +21,12 @@ import (
"fmt"
"time"
"go.uber.org/zap"
"google.golang.org/grpc"
"github.com/milvus-io/milvus-proto/go-api/v2/commonpb"
"github.com/milvus-io/milvus-proto/go-api/v2/milvuspb"
"github.com/milvus-io/milvus/pkg/log"
"github.com/milvus-io/milvus/pkg/util/merr"
"github.com/milvus-io/milvus/pkg/util/retry"
)
@ -56,6 +58,7 @@ func WaitForComponentStates[T interface {
serviceName,
resp.State.StateCode.String())
}
log.Info("WaitForComponentStates success", zap.String("current state", resp.State.StateCode.String()))
return nil
}
return retry.Do(ctx, checkFunc, retry.Attempts(attempts), retry.Sleep(sleep))

View File

@ -46,7 +46,7 @@ func CloseEtcdClient() {
func getEtcdAndPath() (*clientv3.Client, string) {
clientCreator.mu.Lock()
defer clientCreator.mu.Unlock()
// If client/path doesnt exist, create a new one
// If client/path doesnt exist, create a new one
if clientCreator.client == nil {
var err error
clientCreator.client, err = createEtcdClient()