| 433 | } |
| 434 | |
| 435 | func (n *Node) reportStatus() { |
| 436 | for { |
| 437 | var err error |
| 438 | failover := false |
| 439 | failures := 0 |
| 440 | for { |
| 441 | failover, err = n.engine.HAUpdate(n.status()) |
| 442 | if err == nil { |
| 443 | break |
| 444 | } |
| 445 | failures++ |
| 446 | log.Errorf("reportStatus: %v", err) |
| 447 | if failures > n.StatusReportMaxFailures { |
| 448 | n.errChannel <- fmt.Errorf("reportStatus: %d errors, giving up", failures) |
| 449 | return |
| 450 | } |
| 451 | time.Sleep(n.StatusReportRetryDelay) |
| 452 | } |
| 453 | if failover && n.state() == spb.HaState_LEADER { |
| 454 | log.Info("Received failover request, initiating shutdown...") |
| 455 | n.Shutdown() |
| 456 | } |
| 457 | time.Sleep(n.StatusReportInterval) |
| 458 | } |
| 459 | } |
| 460 | |
| 461 | func (n *Node) checkConfig() { |
| 462 | for { |