cd-infra kills Prometheus when it enters the deploy stopped (SIGHUP branch misreads stopped-container ID as 'was running') #23
Labels
No labels
dependencies
major
security-pin
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
trails-cool/trails#23
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
cd-infrarun #94 (the first infra deploy onmainsince the Forgejo cutover) failed at the Prometheus readiness gate, and left Prometheus down for ~16 minutes — no metrics, no alert evaluation. Restarted manually; the stack is healthy again.The readiness gate did its job: it refused to report success. The bug is upstream of it.
Mechanism — confirmed from the run log
The deploy started Prometheus and killed it one second later. The culprit is the config-reload branch:
The intent is sound: "if compose did not recreate Prometheus, it hasn't picked up the new config, so SIGHUP it to reload in place."
The flaw is that
docker inspectreturns an ID for a stopped container too. So when Prometheus enters the deploy already stopped:BEFORE_ID= the stopped container's ID (non-empty)up -dstarts that same container — same IDAFTER_ID==BEFORE_ID→ the branch firesSo the one case where the reload is entirely unnecessary — Prometheus just started, already holding the new config — is the case where it is fatal. ID equality was standing in for "was already running", and those differ precisely when the container was stopped.
This is why it has never fired before: normally Prometheus is either running (SIGHUP reloads correctly) or recreated (IDs differ, branch skipped). It needs Prometheus to be stopped but present going in.
Proposed fix
Guard on running state, not just identity:
A container compose just started needs no reload, so skipping the SIGHUP there is correct on both counts.
Worth considering alongside:
--web.enable-lifecycle+POST /-/reloadfails loudly and only when Prometheus is actually up, rather than firing a signal at a process that may not be ready to receive it.Open question
Prometheus took a SIGTERM at 11:55:07 and several containers (caddy, cadvisor, grafana, postgres, postgres-exporter) were recreated around 11:53 — both before run #94's SSH step began at 12:04:27. So something stopped Prometheus in an earlier partial execution, which is what set up the stopped-but-present state. That earlier activity is unexplained;
concurrency: cancel-in-progress: trueondeploy-infracancelling a first execution mid-flight is the obvious suspect. A cancelled deploy leaving the stack half-recreated is worth understanding on its own.Re-running should now be safe
Prometheus is running again, so a re-run takes the intended path:
BEFORE_RUNNING=true, IDs match, SIGHUP reaches a long-settled process and reloads config normally.Found while verifying #22. That PR's changes deployed correctly and are verified end-to-end (host
.prom→ node_exporter → Prometheus,node_textfile_scrape_error 0).