Skip to content

Commit

Permalink
set node status with backoff retry (#85)
Browse files Browse the repository at this point in the history
DuodenumL authored Dec 23, 2021
1 parent 8028bc8 commit c2f18f7
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions manager/node/heartbeat.go
Original file line number Diff line number Diff line change
@@ -44,10 +44,18 @@ func (m *Manager) nodeStatusReport(ctx context.Context) {
return
}

utils.WithTimeout(ctx, time.Duration(m.config.HealthCheck.Timeout)*time.Second, func(ctx context.Context) {
ttl := int64(m.config.HeartbeatInterval * 2)
if err := m.store.SetNodeStatus(ctx, ttl); err != nil {
log.Errorf("[nodeStatusReport] error when set node status: %v", err)
}
ttl := int64(m.config.HeartbeatInterval * 3)

err := utils.BackoffRetry(ctx, 3, func() (err error) {
utils.WithTimeout(ctx, time.Duration(m.config.HealthCheck.Timeout)*time.Second, func(ctx context.Context) {
if err = m.store.SetNodeStatus(ctx, ttl); err != nil {
log.Errorf("[nodeStatusReport] failed to set node status of %v, err %v", m.config.HostName, err)
}
})
return err
})

if err != nil {
log.Errorf("[nodeStatusReport] failed to set node status of %v for 3 times", m.config.HostName)
}
}

0 comments on commit c2f18f7

Please sign in to comment.