Skip to content

Measure server status age from the last observation - #341

Merged
athNdev merged 1 commit into
mainfrom
fix/health-observation-clock
Nov 4, 2026
Merged

athNdev merged 1 commit into
mainfrom
fix/health-observation-clock

Conversation

@athNdev

@athNdev athNdev commented Nov 4, 2026 •

Copy link
Copy Markdown
Owner

Problem

/health/detail on the dev instance reported the game layer unknown with 2 stale servers after two minutes of uptime, while both servers were running healthily.

A server row is only rewritten when its observed status changes. A server that stays running therefore keeps its original updated_at, and once that ages past the staleness window health.Compute correctly concludes no observation is recent — but the observation did happen, every sweep.

Fix

The reconciler's sweep is the observation. enqueueAll records when it finished observing every server, and the health snapshot receives that time as Input.ObservedAt:

  • sweep is recent → every stored status was re-read at that moment, so none are stale;
  • a row written recently is still trusted on its own (a write is evidence too);
  • no sweep at all → previous per-row behaviour, unchanged.

The unobserved layer still reports unknown, never ok — the state machine is untouched; only the observation clock is now honest.

Verification

  • go build ./..., go vet ./..., go test ./internal/health/... ./internal/reconciler/... green
  • New cases: fresh sweep keeps unchanged rows fresh; old sweep still trusts a freshly written row; old sweep + old rows is unknown; no sweep falls back to per-row age
  • TestLastSweepAtAdvancesWithASweep covers the reconciler clock

A server row is not rewritten when its status is unchanged, so its own
update time ages forever and a healthy server eventually looks stale. The
reconciler's sweep is the observation: pass its completion time into the
health snapshot and treat every stored status as fresh when the sweep is
recent. A row that was written recently is still trusted on its own, and
without a sweep the previous per-row behaviour is unchanged.
@athNdev
athNdev merged commit e8584e6 into main Nov 4, 2026
11 checks passed
@athNdev
athNdev deleted the fix/health-observation-clock branch November 4, 2026 04:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant