Repository navigation
fix(k8s): the grafana, prometheus, argo cd and loki clients dial through the egress-checked factory, and their pre-flight address checks go - #2497
Conversation
… loki clients to the egress factory Refs #2424
…go cd and loki caller Refs #2424
…he egress factory The commands get their clients from new_http_client at the configured level, so the connect checks the address that it dials. The validate_service_url calls before the request go. The commands keep a check of the URL scheme that makes no lookup, service_base_url, which names the setting when a k8s:// address is in it. A refusal at the connect ends the command with its message and no traceback. Refs #2424
…through the egress factory Each one gets its client from new_http_client at the configured level, and its validate_service_url call before the request goes. Each one already reports the error of one request in its result, so a refusal at the connect needs no new branch. Refs #2424
… factory The mint and the check functions take a keyword level in place of allow_private_network, whose default allowed private addresses. The callers that read the settings give the configured level, the credential sync too. An address that the level refuses fails the step with its cause, as a request error does, so the sync reports it and keeps the stored token. Refs #2424
…once The validate_url_egress calls before the request go. The factory client at the private level resolves the host at the connect, and httpx2 refuses a scheme other than http and https before any lookup. The purpose parameter of get_json, which only the deleted check read, goes too. Refs #2424
…s as checked at the connect Refs #2424
… cd commands Refs #2424
…file The per-file handler of `devops grafana dashboards sync` caught the refusal of the connect as a failed file, so each file printed the refusal and the sync exited 1. The refusal applies to each file. The handler now lets `SSRFBlockedError` out, and `exit_on` reports it with status 2. Refs #2424
…nd report a failed mint `_argocd` minted the Argo CD token before its URL check and outside any handler. A mint that the egress level refused, or a `k8s://` address in `argocd.url`, came out of `devops argo cd apps list`, `sync` and `status` with a traceback. The URL check now runs first, and a failed mint ends the command with its cause and status 1. Refs #2424
…nd the failed argo cd token mint Refs #2424
…oopback rule of the grafana, prometheus and argo cd urls The wizard checks these URLs with `validate_service_url`, which refuses loopback without `ai.allow_private_network`. Part 5 (#2437) changes it to the configured level. Until then, `devops config set` sets a loopback URL, because it checks only the syntax. Refs #2424
…, argo cd and loki clients to the egress factory Refs #2424
Test resultsTargeted run after the rebase onto The pre-push hook (fast static checks) passed. Fail-to-pass
Tests that failed on the baseThe last 3 credential tests fail on the base only from the new |
🤖 I have created a release *beep* *boop* --- ## [0.11.0](v0.10.1...v0.11.0) (2026-10-28) ### Features * **monitoring:** the roadmap Service's identity refusals, failing and stalled jobs, restarts, and GitHub and model request volume raise alerts ([#2496](#2496)) ([0137f23](0137f23)), closes [#2472](#2472) * **service:** roadmap-service runs at one replica, and each model call in the cluster is sent at most two times ([#2500](#2500)) ([2d32dae](2d32dae)), closes [#2494](#2494) ### Bug Fixes * **cli:** every command reports a DevOpsCLIError through one exit seam ([#2502](#2502)) ([eadd55f](eadd55f)), closes [#2487](#2487) * **github:** pr monitor waits until the checks settle and names every blocker, and pr ready reads the merge-readiness verdict ([#2498](#2498)) ([43326ea](43326ea)) * **k8s:** a pod that does not call the Kubernetes API mounts no service account token ([#2522](#2522)) ([305d3ba](305d3ba)) * **k8s:** the cloudflared tunnel replicas prefer different nodes and keep one up through a drain ([#2499](#2499)) ([d4edaf6](d4edaf6)), closes [#1023](#1023) * **k8s:** the grafana, prometheus, argo cd and loki clients dial through the egress-checked factory, and their pre-flight address checks go ([#2497](#2497)) ([e7ca1d5](e7ca1d5)) * **monitoring:** the roadmap Service alerts count a series that starts in the hour, and a lane of a new pod can stall ([#2514](#2514)) ([c7692b2](c7692b2)), closes [#2505](#2505) * **review:** a review's scanners leave out the rules that never gave a valid finding here ([#2508](#2508)) ([fe953ac](fe953ac)) * **roadmap:** a refine round leaves an outside account issue to a person, and refine neutralizes comment openers, www links and cross-repository references ([#2507](#2507)) ([e6230dc](e6230dc)), closes [#2478](#2478) * **sandbox:** the metrics scrape and the whitelist NetworkPolicy resolve each host one time, through the egress check ([#2521](#2521)) ([7c01426](7c01426)) * **security:** the subprocess environment guard refuses the zsh and interpreter keys that make a child run code ([#2510](#2510)) ([459621a](459621a)) * **service:** a restart keeps the halt, the budget window and the failure ledger, and a rate limit or a suspended installation stops every worker ([#2515](#2515)) ([3630de1](3630de1)), closes [#2474](#2474) ### Code Refactoring * **config:** settings resolve in one declared order through pydantic-settings sources ([#2518](#2518)) ([6a5447a](6a5447a)), closes [#2445](#2445) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: dan-petty-release[bot] <346998822+dan-petty-release[bot]@users.noreply.github.com>
The Grafana, Prometheus and Argo CD clients now get their HTTP client from the egress-checked factory (
devops_cli.http.client). Each client resolves the host one time, at the connect, and dials only the addresses that its egress level admits. The factory checks each redirect hop in the same way. Before, these clients built a rawhttpx2.Clientand checked the host name withvalidate_service_urlbefore the request. Then httpx2 resolved the name again at the socket. A rebinding DNS server could give a different address at the second lookup, for example a private or cloud metadata address. The Loki client and the direct cluster-service URLs already used the factory, but a pre-flightvalidate_url_egresscheck resolved the name a second time. This change is part 2 of the split of #1381. Part 1 (#2422) moved the AI service clients.The moved callers and their levels:
devops grafana,devops prometheusanddevops argo cd appscommands: configured level.trigger_argocd_sync) and the rollout metric gate: configured level.k8s/credentials.py): configured level.execute_loki_query) and the direct cluster-service URL (service_http.get_json): private level, as before. Each request now looks up its host one time."Configured" is loopback and public addresses, and private addresses too when
ai.allow_private_networkis true. Cloud metadata addresses are refused at every level.The pre-flight address checks of these callers are deleted, with
_service_base_urlofk8s/credentials.pyand thepurposeparameter ofservice_http.get_json, which only the deleted check read. The mint and check functions take a keywordlevelin place ofallow_private_network, whose default wasTrue.get_or_mint_argocd_token,get_or_mint_grafana_authandsync_k8s_credentialsgiveconfigured_level(settings.ai). A refused address in a mint or a token check is a failed step with its cause, as a request error is: the sync reports it, keeps the stored token and does not stop.A check that reads only the URL stays where a command needs an early error.
_clean_service_base_urlmoves todevops_cli.http.urlsasservice_base_url. The three command groups call it, so ak8s://address thatdevops k8s configure-urls --addressing proxywrote stops the command with an error that names the setting, before any lookup. Indevops argo cd apps, this check now runs before the token mint. httpx2 refuses a URL that is not http or https before any lookup, so Loki andget_jsonneed no scheme check of their own.The three command groups report
SSRFBlockedErrorwithout a traceback (new_typer(exit_on=...)). The exit status of a refusal is 2, the status ofSSRF_BLOCKEDindocs/ERRORS.md. The pre-flight refusal exited with status 1.devops grafana dashboards syncstops at the first refused file. A failed Argo CD token mint in adevops argo cd appscommand prints the failure with its cause, without a traceback, and exits with status 1.Some levels change. Without the flag, the commands and the token calls are wider: they dial a loopback answer, such as a
kubectl port-forwardonlocalhost. The credential sync is narrower: before, it checked withallow_private_network=Truewhatever the flag said. Now a private Argo CD or Grafana address needs the flag in the sync too, as it does in the commands. Thedevops config initwizard still checks these three URLs withvalidate_service_url, so it refuses loopback without the flag; part 5 (#2437) changes it.devops config setchecks only the syntax of these URLs.test_each_caller_dials_at_its_levelhas a row for each moved caller, with and without the flag, and fails when a caller host name reaches the dial.test_each_k8s_service_caller_dials_the_address_it_checkedreproduces the issue: each host answers a public address at the first lookup and cloud metadata at each later lookup.test_loki_and_a_direct_service_url_look_up_their_host_oncecounts the lookups. The specsconfigured-service-urls,stack-credential-sync,k8s-logsandk8s-service-proxyget requirements for these levels, refusals and lookups.README.md,SECURITY.mdanddocs/KNOWN_ISSUES.mdname the moved clients and the exception of the wizard.Closes #2424
Change:
openspec/changes/archive/2026-10-28-2424-k8s-clients-egress-factory/