Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

don't call GetNode in checkNodeStatus #644

Merged
merged 1 commit into from
Aug 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading