From 6354f260e15db1a246a88bd36a1c824552cb98d8 Mon Sep 17 00:00:00 2001 From: benjamin <ben@elixxir.io> Date: Tue, 11 Oct 2022 08:19:02 -0700 Subject: [PATCH] minor clean up --- cmix/health/tracker.go | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/cmix/health/tracker.go b/cmix/health/tracker.go index bb4b5e341..1476b788c 100644 --- a/cmix/health/tracker.go +++ b/cmix/health/tracker.go @@ -164,10 +164,18 @@ func (t *tracker) StartProcesses() (stoppable.Stoppable, error) { // health. func (t *tracker) start(stop *stoppable.Single) { + // ensures wasHealthy is only set once hasSetWasHealthy := false + + // denotation of the previous state in order to catch state changes lastState := false + + // flag denoting required exit, allows final signaling quit := false + //ensured the timeout error is only printed once per timeout period + timedOut := true + for { /* wait for an event */ @@ -181,9 +189,14 @@ func (t *tracker) start(stop *stoppable.Single) { case heartbeat := <-t.heartbeat: t.updateHealth(heartbeat.HasWaitingRound, heartbeat.IsRoundComplete) + timedOut = false case <-time.After(t.timeout): - jww.ERROR.Printf("Network health tracker timed out, network " + - "is no longer healthy, follower likely has stopped...") + if !timedOut { + jww.ERROR.Printf("Network health tracker timed out, network " + + "is no longer healthy, follower likely has stopped...") + } + timedOut = true + // note: no need to force to unhealthy because by definition the // timestamps will be stale } -- GitLab