fix(monitoring): let alertmanager read its smtp and ntfy secrets #593

Sammanfogat
supernaut sammanfogade 3 incheckningar från fix/alertmanager-secret-perms in i main 2026-10-08 17:11:09 +00:00
Ägare

Closes #565.

Cause

Alertmanager runs as nobody (65534). It read its SMTP password and ntfy token from bind-mounted files owned by the service user with mode 0600. Inside the container both reads fail:

could not read /etc/alertmanager/smtp_password: open /etc/alertmanager/smtp_password: permission denied
unable to read file /etc/alertmanager/ntfy_token: open /etc/alertmanager/ntfy_token: permission denied

So every email and ntfy notification has failed since the files were added. The credentials themselves were fine.

Change

  • Both secrets become podman secrets with type=mount, uid=65534,gid=65534,mode=0400, at the same paths. alertmanager.yml is unchanged.
  • Secret names carry a hash of the value, as the Forgejo secrets do, so a vault rotation changes the unit and restarts Alertmanager.
  • The old plaintext files on the monitoring VM are removed.
  • New alert AlertmanagerDeliveryFailing fires per integration on alertmanager_notification_requests_failed_total. If every integration fails it reaches no one, but it shows on the dashboard. An outside dead-man's switch is a separate task.
  • .ua/ (local code-analysis output) is git-ignored, so prettier -cu . passes in clones that have it.

Verified

  • On the monitoring VM (podman 5.4.2), the Alertmanager image running as 65534 reads a mount secret at /etc/alertmanager/smtp_password with these options. The throwaway secret was removed afterwards.
  • check-alert-rules.py: 54 rules render and parse. Pre-push hooks pass, including ansible-lint.

After merge

Apply the monitoring role, then send a test alert and confirm both email and ntfy arrive.

Closes #565. ## Cause Alertmanager runs as `nobody` (65534). It read its SMTP password and ntfy token from bind-mounted files owned by the service user with mode `0600`. Inside the container both reads fail: ``` could not read /etc/alertmanager/smtp_password: open /etc/alertmanager/smtp_password: permission denied unable to read file /etc/alertmanager/ntfy_token: open /etc/alertmanager/ntfy_token: permission denied ``` So every email and ntfy notification has failed since the files were added. The credentials themselves were fine. ## Change - Both secrets become podman secrets with `type=mount`, `uid=65534,gid=65534,mode=0400`, at the same paths. `alertmanager.yml` is unchanged. - Secret names carry a hash of the value, as the Forgejo secrets do, so a vault rotation changes the unit and restarts Alertmanager. - The old plaintext files on the monitoring VM are removed. - New alert `AlertmanagerDeliveryFailing` fires per integration on `alertmanager_notification_requests_failed_total`. If every integration fails it reaches no one, but it shows on the dashboard. An outside dead-man's switch is a separate task. - `.ua/` (local code-analysis output) is git-ignored, so `prettier -cu .` passes in clones that have it. ## Verified - On the monitoring VM (podman 5.4.2), the Alertmanager image running as 65534 reads a mount secret at `/etc/alertmanager/smtp_password` with these options. The throwaway secret was removed afterwards. - `check-alert-rules.py`: 54 rules render and parse. Pre-push hooks pass, including `ansible-lint`. ## After merge Apply the monitoring role, then send a test alert and confirm both email and ntfy arrive.
supernaut lade till 3 incheckningar 2026-10-08 17:08:31 +00:00
Alertmanager runs as nobody (65534). The secrets were bind-mounted files owned by the service user with mode 0600, so every email and ntfy notification failed with permission denied since the files were added.

Mount them as podman secrets owned by 65534, mode 0400, named by a hash of the value like the Forgejo secrets. Remove the old plaintext files. Add AlertmanagerDeliveryFailing on alertmanager_notification_requests_failed_total per integration.

Closes #565.
chore: ignore local analysis output in git and prettier
Alla kontroller lyckades
ci / ci (pull_request) Successful in 2m3s
d6eda49a5f
supernaut schemalade den här ändringsförfrågan för automatisk sammanfogning när alla kontroller lyckas 2026-10-08 17:09:18 +00:00
supernaut sammanfogade incheckning d3c18a60a7 till main 2026-10-08 17:11:09 +00:00
supernaut tog bort grenen fix/alertmanager-secret-perms 2026-10-08 17:11:09 +00:00
Logga in för att delta i denna konversation.
Inga granskare
Ingen milstolpe
Inget projekt
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!593
Ingen beskrivning angiven.