Skip to content

Commit

Permalink
don't call GetNode in checkNodeStatus (#644)
Browse files Browse the repository at this point in the history
  • Loading branch information
yuyang0 committed Aug 20, 2024
1 parent baae21a commit b9632e7
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions engine/factory/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,14 @@ func (e *EngineCache) checkNodeStatus(ctx context.Context) {
ch := e.stor.NodeStatusStream(ctx)

for ns := range ch {
// GetNode will call GetEngine, so GetNode updates the engine cache automatically
if _, err := e.stor.GetNode(ctx, ns.Nodename); err != nil {
if errors.Is(err, types.ErrInvaildCount) {
logger.Infof(ctx, "remove metrics for invalid node %s", ns.Nodename)
metrics.Client.RemoveInvalidNodes(ns.Nodename)
}
logger.Warnf(ctx, "failed to get node %s: %s", ns.Nodename, err)
// don't need to add new entry to engine cache for alive node here,
// because NodeStatusStream calls GetNode, and GetNode will call GetEngine,
// so NodeStatusStream will update the engine cache for alive node automatically.
if errors.Is(ns.Error, types.ErrInvaildCount) {
// ns.Error is the error returned by GetNode which is called by NodeStatusStream
// so here is a good place to update metrics cache
logger.Infof(ctx, "remove metrics for invalid node %s", ns.Nodename)
metrics.Client.RemoveInvalidNodes(ns.Nodename)
}

if !ns.Alive {
Expand Down

0 comments on commit b9632e7

Please sign in to comment.