monitoring: cross-probe dead-man email must retry after a failed send #609

Stängd
öppnade 2026-10-08 21:12:22 +00:00 av supernaut · 0 kommentarer
Ägare

What

The services host probes the monitoring VM (bitborg-monitoring-probe.sh.j2) and emails when it is down. send_mail returns 0 when SMTP is unset (:31) and swallows a curl failure with || echo "[probe] mail send failed" (:48). The callers write the state file right after the call (:77, :88, :101, :114).

Related to #389, which is about detecting provider-side failures. This is a separate defect in the probe.

Why

This email is the only signal when the monitoring VM is dead, because Alertmanager and ntfy live on that VM.

Failing case

The monitoring VM goes down while the SMTP relay is also failing, or the mailer credential was rotated. send_mail fails. The script writes down to the state file. The next run sees prev=down and never retries. The recovery email is lost the same way.

Fix

Make send_mail return curl's exit status, and return non-zero when SMTP is unset. Write the state only on success at all four call sites, for example send_mail ... && echo down > "$STATE_FILE".

Done when

  • A failing SMTP send leaves the state file unchanged, so the next run retries.
  • A shell test stubs curl to fail and shows no state change.
  • The unset-SMTP case is logged and does not mark the state.
## What The services host probes the monitoring VM (`bitborg-monitoring-probe.sh.j2`) and emails when it is down. `send_mail` returns 0 when SMTP is unset (`:31`) and swallows a curl failure with `|| echo "[probe] mail send failed"` (`:48`). The callers write the state file right after the call (`:77`, `:88`, `:101`, `:114`). Related to #389, which is about detecting provider-side failures. This is a separate defect in the probe. ## Why This email is the only signal when the monitoring VM is dead, because Alertmanager and ntfy live on that VM. ## Failing case The monitoring VM goes down while the SMTP relay is also failing, or the mailer credential was rotated. `send_mail` fails. The script writes `down` to the state file. The next run sees `prev=down` and never retries. The recovery email is lost the same way. ## Fix Make `send_mail` return curl's exit status, and return non-zero when SMTP is unset. Write the state only on success at all four call sites, for example `send_mail ... && echo down > "$STATE_FILE"`. ## Done when - [ ] A failing SMTP send leaves the state file unchanged, so the next run retries. - [ ] A shell test stubs `curl` to fail and shows no state change. - [ ] The unset-SMTP case is logged and does not mark the state.
Logga in för att delta i denna konversation.
Ingen milstolpe
Inga tilldelade
1 deltagare
Notiser
Förfallodatum
Förfallodatumet är ogiltigt eller utanför gränserna. Använd formatet "åååå-mm-dd".

Inget förfallodatum satt.

Beroenden

Inga beroenden satta

Referens
bitborg/bitborg-infra#609
Ingen beskrivning angiven.