()
| 1815 | } |
| 1816 | |
| 1817 | func (h *heartbeats) sendBeat() { |
| 1818 | _, err := h.store.UpsertTailnetCoordinator(h.ctx, h.self) |
| 1819 | if database.IsQueryCanceledError(err) { |
| 1820 | return |
| 1821 | } |
| 1822 | if err != nil { |
| 1823 | h.logger.Error(h.ctx, "failed to send heartbeat", slog.Error(err)) |
| 1824 | h.failedHeartbeats++ |
| 1825 | if h.failedHeartbeats == 3 { |
| 1826 | h.logger.Error(h.ctx, "coordinator failed 3 heartbeats and is unhealthy") |
| 1827 | _ = agpl.SendCtx(h.ctx, h.update, hbUpdate{health: healthUpdateUnhealthy}) |
| 1828 | } |
| 1829 | return |
| 1830 | } |
| 1831 | publishCoordinatorHeartbeat(h.ctx, h.pubsub, h.logger, h.self) |
| 1832 | if h.failedHeartbeats >= 3 { |
| 1833 | h.logger.Info(h.ctx, "coordinator sent heartbeat and is healthy") |
| 1834 | _ = agpl.SendCtx(h.ctx, h.update, hbUpdate{health: healthUpdateHealthy}) |
| 1835 | } |
| 1836 | h.failedHeartbeats = 0 |
| 1837 | } |
| 1838 | |
| 1839 | func (h *heartbeats) cleanupLoop() { |
| 1840 | defer h.wg.Done() |
no test coverage detected