Skip to content

feat(cf): unified cross-env Cloudflare map (GET /admin/cf/map)#283

Merged
posix4e merged 1 commit into
mainfrom
feat/cf-map-all-envs
Jun 3, 2026
Merged

feat(cf): unified cross-env Cloudflare map (GET /admin/cf/map)#283
posix4e merged 1 commit into
mainfrom
feat/cf-map-all-envs

Conversation

@posix4e
Copy link
Copy Markdown
Member

@posix4e posix4e commented Jun 3, 2026

PR-3 of the CF-reconcile arc — the unified cross-env view (per your steer: prod + PRs can't be cleanly isolated, so the management layer handles both together).

Why

The per-env /admin/cf/snapshot only sees its own dd-{env}-* slice, so it can't surface a closed PR's leaked CF resources — no per-env CP exists to notice them. Since prod and every pr-N share one Cloudflare account, the management view must enumerate and attribute everything together.

What

Built straight from the CF API (so it reflects reality regardless of which CPs are up — the basis for "CF is source of truth"):

  • Env::from_resource_name(name) attributes any dd-{env}-{cp|agent|api}-… resource to its env, recovering hyphenated labels (pr-42) intact.
  • cf_map::build_map enumerates ALL dd-* tunnels + apps + every tunnel-targeting CNAME, groups by installation (production, each pr-N, bot, dogfood) + an (unattributed) bucket for unparseable names or CNAMEs whose target tunnel is gone (the leak). DNS is attributed via the tunnel its *.cfargotunnel.com content references. Each install reports has_live_cp so torn-down envs stand out. Degraded-aware (reuses PR-2's independently-fallible fetches).
  • GET /admin/cf/map serves it — same auth as /admin/cf/snapshot, read-only. The per-env snapshot stays for the focused view.

Groundwork for the operator-gated reconcile (next PRs); no mutations here.

Validation

  • cargo fmt clean; compiles locally (only the macOS sessiond.rs noise; CI builds musl). Unit tests for Env::from_resource_name (incl. pr-42, bot, non-conforming → None).
  • CI build + preview deploy green; on the preview host (which runs prod + this pr-N), GET /admin/cf/map shows both installations grouped, each resource env-attributed.

🤖 Generated with Claude Code

The per-env snapshot only ever sees its own `dd-{env}-*` slice, so it
can't surface a closed PR's leaked resources (no per-env CP exists to
notice them). But prod and every pr-N share one CF account, so the
management view must handle them together.

Add a cross-env map built straight from the CF API (independent of any
CP being up — the basis for "CF is source of truth"):
- `Env::from_resource_name(name)` attributes any `dd-{env}-{cp|agent|api}-…`
  resource to its env, recovering hyphenated labels (pr-42) intact.
- `cf_map::build_map` enumerates ALL `dd-*` tunnels/apps + every
  tunnel-targeting CNAME, groups them by installation (production, each
  pr-N, bot, dogfood) plus an `(unattributed)` bucket for resources whose
  env can't be parsed or whose CNAME targets a tunnel we no longer have
  (the leak). DNS is attributed via the tunnel its content references.
  Each install reports `has_live_cp` (a non-deleted `-cp-` tunnel exists)
  so torn-down envs stand out. Degraded-aware (reuses the PR-2 pattern).
- `GET /admin/cf/map` serves it, same auth as `/admin/cf/snapshot`,
  read-only. The per-env snapshot stays for the focused view.

Groundwork for the operator-gated reconcile (next PRs); no mutations.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 3, 2026

DD preview ready

URL: https://pr-283.devopsdefender.com

Browser login: visit https://pr-283.devopsdefender.com — DD redirects you to
the GitHub App auth broker. A DD session cookie scoped
to .devopsdefender.com lets the preview, fleet, and
shell hosts share the same login.

Machine-to-machine: GitHub Actions workflows in the
DD_OWNER org pass their per-job OIDC JWT as
Authorization: Bearer … (audience dd-agent).

Register endpoint for a local agent: https://pr-283.devopsdefender.com/register
(authenticated by ITA attestation).

@posix4e posix4e merged commit e6356ec into main Jun 3, 2026
3 checks passed
@posix4e posix4e deleted the feat/cf-map-all-envs branch June 3, 2026 12:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant