Sim health check reports WARNING for "just restarted", pageing on every deploy — give Unknown its own tag and a startup grace window

Aperta
#2,020 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
72/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Tranquilla
Stack tecnologico
java

Direzione di ricerca

Start in vcell-api/src/main/java/org/vcell/rest/health/HealthService.java: read the NagiosStatus factory methods around :85-95, the healthEvents deque at :103, the loop timing constants at :36-40, and getRunsimStatus at :283-310 to see where Unknown() is returned. Then track service start time and introduce a distinct startup/starting state for now-startTime < SIMULATION_LOOP_START_DELAY + SIMULATION_TIMEOUT, keeping Unknown alertable after that window; the dispatch path is HealthRestlet.java:93. Done when a fresh pod's response body contains no WARNING keyword while a wedged loop still does — note the Better Stack monitor greps the response, so its tag config must change together, and run the vcell-api tests covering health responses.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Error Reporting

Summary

GET /api/v0/health?check=sim reports the same WARNING tag for two conditions that mean opposite
things:

  • "simulations are degraded" — a real signal
  • "this pod started less than ~2 minutes ago and hasn't finished its first test simulation" —
    not a signal at all

Better Stack alerts on the literal keyword WARNING in the response body, so a freshly started
api pod pages the on-call. Any deploy, node drain, eviction or reschedule can trigger it.

Mechanism

HealthService keeps its event history in an in-memory deque
(HealthService.java:103):

final ConcurrentLinkedDeque<HealthEvent> healthEvents = new ConcurrentLinkedDeque<>();

A restart empties it. The monitor loop then sleeps before doing anything
(HealthService.java:173, SIMULATION_LOOP_START_DELAY = 60s), submits a test simulation, and
only records RUNSIM_SUCCESS/RUNSIM_FAILED when it finishes. Until then getRunsimStatus
finds nothing in its 15-minute lookback and returns (HealthService.java:309):

if (loginCompleteEvent==null) {
    return NagiosStatus.Unknown();   // no completed simulation attempts
}

and Unknown() carries the alerting keyword (HealthService.java:94):

static NagiosStatus Unknown() {
    return new NagiosStatus("Unknown", 3, null, null, "WARNING");
}

So the wire response is

{"nagiosStatusName":"Unknown","nagiosStatusCode":3,"tags":"WARNING"}

which is byte-identical whether the pod just booted or the simulation subsystem is broken.

How this showed up

The VCell Release Health - Sim - Warning monitor fired on 2026-08-18 at 2:00:15 PM —
fifteen seconds after the top of the hour. restart-api-cron in prod ran
kubectl -n prod rollout restart deployment/api every hour, so a fresh pod was always
available to be hit just after :00.

It paged only intermittently because the rolling restart leaves older pods (which still have event
history) serving alongside new ones — the check has to land on a fresh pod inside its first ~1–2
minutes.

That cron has since been suspended
(vcell-fluxcd#51) now that
#1899 fixed the memory growth it was mitigating. That removes the frequency, not the defect.
Every deploy still carries the same false-alarm window.

Why Unknown is the wrong tag

The other three statuses are all measurements (HealthService.java:85-95):

status code tags means
OK 0 UP sim completed under 45 s
Warning 1 UP WARNING sim completed, but slower than SIMULATION_TIME_WARNING
Critical 2 DOWN sim failed, or exceeded SIMULATION_TIMEOUT
Unknown 3 WARNING no measurement exists yet

Unknown is the only one that is an absence of information, and it is the only one whose tag
does not describe an observed state. Nagios convention agrees: exit code 3 is "cannot determine",
deliberately distinct from 1 "warning".

Proposed fix

Distinguish "not yet known" from "known bad". Two parts, either useful alone:

  1. Give Unknown its own tag — e.g. tags: "UNKNOWN" rather than "WARNING" — so a keyword
    monitor can choose. This alone fixes the paging, and is a one-line change.
  2. Add a startup grace window. Track service start time; while
    now - startTime < SIMULATION_LOOP_START_DELAY + SIMULATION_TIMEOUT, report a distinct
    starting state rather than an indeterminate one. After the grace window with still no
    completed simulation, Unknown is genuinely worth alerting on — the loop thread may have died,
    which today is indistinguishable from a normal boot.

The second point matters and is easy to miss: a permanently wedged monitor thread and a
healthy fresh pod currently produce the same output forever. Fixing (1) without (2) would make
a dead health loop silent.

Also worth considering: persist or seed the event history so a restart does not lose the
picture entirely, though this is a bigger change and may not be worth it for a 3-replica
deployment.

Acceptance

  • A pod restart does not produce a response that a WARNING keyword monitor matches.
  • A health loop that dies, or simulations that stop completing, does still alert after the grace
    window.
  • Better Stack config updated to match whatever tags are chosen — the monitor greps the body, so
    the two have to be changed together.

Files

  • vcell-api/src/main/java/org/vcell/rest/health/HealthService.java — :94 Unknown(),
    :103 event store, :283-310 getRunsimStatus, :36-40 timing constants
  • vcell-api/src/main/java/org/vcell/rest/health/HealthRestlet.java:93 — the check=sim dispatch

Refs #1899, virtualcell/vcell-fluxcd#51

Lingua principale
Java
Stelle
140
Fork
35
Merge medio
22h 6m
PR unite (30g)
14

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di virtualcell/vcell

Tutte le issue di virtualcell/vcell

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.