Repository navigation
Closed
Labels
effort/mediumEffort Mediumpriority/p2-mediumPriority P2: standard worksource/agentFiled by an agenttype/bugType bug: the code does not do what it mustvalue/mediumValue Medium
Description
Problem Description
A short outage of a cluster service ends a devops command with a Python traceback. The command does not try again. For example, Prometheus is not ready for some seconds after its pod restarts.
Evidence (2026-11-13):
devops prometheus query 'count(kubelet_pod_start_duration_seconds_count)'ran at 17:24:31Z.- It ended with
httpx2.HTTPStatusError: Server error '503 Service Unavailable'and a 70-line traceback, logged as ERROR (trace c5f610552fc9fc8c3bce3c14d621890b). - The Prometheus pod had started 12 s before, at 17:24:19Z, after a planned node drain (
devops infra apply). For those seconds the Service had no ready endpoint, so the tunnel answered 503. - One more attempt some seconds later would have passed.
Cause
devops_cli.http.entry.http_clienthas aretriesoption: a tenacity retry transport that tries again after 429, 5xx and connect failures.- Of about 30 call sites of
http_client, only the AI clients (ai/client/base.py) passretries. prometheus/client.py_get_jsoncallsresponse.raise_for_status()with no retry. TheHTTPStatusErrorthen reachesmain.py_delegate, which logs a traceback for an exception that is not aDevOpsCLIError.- The same pattern is in the Loki client (
k8s/logql.py, used bydevops roadmap eval grades), the Grafana client and the k8s service probes (k8s/service_http.py,k8s/service_probe.py). - The Prometheus client is also the client of the rollout and apply health gate. That gate queries Prometheus soon after a node drain, which is when Prometheus can be restarting.
Proposed Fix
- Give the read-only (idempotent GET) clients of cluster services one retry policy. Use the existing
retriesoption ofhttp_client, with backoff and jitter, a small attempt count (for example 4) and a total time bound below the command timeout. - Retry only 429, 502, 503, 504 and connect or read failures. Never retry a 4xx other than 429, a POST that is not idempotent, or an egress refusal.
- Map the last failure to a
DevOpsCLIErrorsubclass in one place. It prints one line with the service, the status or the network error, the attempts and the time, and a hint, for example "the server is not ready; try again or check its pod". Exit code 1, no traceback. - fix(prometheus): a query that Prometheus refuses ends in a traceback #5487 (a 4xx with the
errorfield of Prometheus) is the 4xx branch of the same mapping. - The health gate keeps its own wait loop. A retry inside one query must not hide a down Prometheus from the gate: the gate gets the mapped error and reports it.
Acceptance Criteria
- A test with a fake transport that answers 503 twice and then 200 gets the JSON answer from
PrometheusClient.query, after 3 attempts (devops ci fail-to-pass). - A test with 503 on every attempt gets one
DevOpsCLIErrorline fromdevops prometheus query, exit code 1 and no traceback. The line names the attempts. - A test proves that a 400 is not retried.
- The Loki client of
devops roadmap eval grades, the Grafana client and the k8s service probes use the same policy. A test for each proves that it retries a 503. - A test proves that the apply health gate reports a Prometheus that stays down as a gate failure with the mapped message.
Related
- fix(prometheus): a query that Prometheus refuses ends in a traceback #5487 (4xx branch)
- fix(argo): a token that Argo CD refuses ends each argo API command in a traceback, and devops never mints a new one #2576 (an Argo CD token refusal ended in a traceback)
Metadata
Metadata
Assignees
Labels
effort/mediumEffort Mediumpriority/p2-mediumPriority P2: standard worksource/agentFiled by an agenttype/bugType bug: the code does not do what it mustvalue/mediumValue Medium
Activity
dan-petty commentedon Nov 13, 2026
http, and .github/labels.yml declares no scope/http label. Add the label to the file to give the scope to this item.Both map cluster-service HTTP errors to a clean DevOpsCLIError line. #5487 covers the 4xx branch; this candidate covers the 5xx retry branch.devops-cli-service commentedon Nov 13, 2026
Released in v0.132.1: https://github.com/dan-petty/devops-cli/releases/tag/v0.132.1
devops-cli-service commentedon Nov 13, 2026
Live since 2026-11-13 21:55 UTC