Skip to content

feat: use shared KV for content site routing - #35

Merged
kptdobe merged 5 commits into
mainfrom
feat/shared-site-backend-registry
Nov 25, 2026
Merged

kptdobe merged 5 commits into
mainfrom
feat/shared-site-backend-registry

Conversation

@kptdobe

@kptdobe kptdobe commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Replace migrated-site environment lists with the shared DA_SITE_BACKENDS KV registry (org/site -> da or hlx6), normalizing cached values.
  • Probe Helix Admin only on misses; successful results persist, while 404-derived results expire after 300 seconds. HLX_ADMIN configures the probe base URL.
  • Log failed KV writes and return the known probe result. Keep request-scoped I/O independent across requests; read/probe failures still fail closed with 503.
  • Remove all dual-write configuration/parsing from da-content. Dual writes belong exclusively to da-admin.
  • Preserve migrated-site routing ahead of R2 bypasses and detection bypasses for preflight/cookie requests.
  • Bind the shared production/staging namespaces and document rollout, new-site provisioning, manual cutover, residual probe traffic, and forward-or-410 contributor requirements.

Companion and rollout

  • Companion: feat: resolve site backends through shared KV da-admin#349. Deploy da-admin first.
  • Preload all sites still served by DA, including dual-write sites, as da, and migrated sites as hlx6. Audit conflicting inventory instead of overwriting authoritative entries.
  • For every new DA-served site after rollout, explicitly seed a non-expiring da entry and wait for KV propagation before its first request, including document creation. Site creation does not seed the registry automatically.
  • The upgrade header reflects source-bus configuration, including overlays; it does not prove completed migration. Explicit registry entries take precedence.
  • Pause traffic and drain in-flight requests/probes before manual cutovers. KV changes can take 60 seconds or more to propagate; verify both workers before resuming traffic.
  • da-admin separately caches its org-discovery gate at org:<org> for 300 seconds. After site changes propagate, this derived entry can be deleted to refresh discovery sooner. It does not affect direct site routing.
  • No HLX6_DUAL_WRITES variable is needed on da-content; leftover values are ignored.
  • The 404 TTL limits retention, not request volume. Unauthenticated arbitrary-site requests can still cause probes; duplicate concurrent probes remain possible.

Validation

  • Full suite: 111 passing with 100% statements, branches, functions, and lines.
  • Focused cases cover the 300-second 404 TTL, permanent successful results, known-result routing after failed KV writes, normalized values, configurable host, and concurrent request isolation.
  • ESLint and production Wrangler dry-run build passed; no manual deployment.
  • The latest companion follow-up is documentation-only; its CI is green: https://github.com/adobe/da-content/actions/runs/45390569123

Use the same site registry as da-admin instead of migration lists.
Keep dual-write configuration exclusively in da-admin.

Seed active dual-write sites as da before rollout. KV cutovers are
eventually consistent and require request draining.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Keep the 100% branch coverage gate for missing org/site input.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@kptdobe
kptdobe requested a review from bosschaert November 24, 2026 10:44
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@bosschaert

Copy link
Copy Markdown

Review of 942827e: CI passes, but there are two issues in the registry probe.

P1 — A 404 from the ping is saved as da forever (src/utils/hlx6.js:25-29)

  • https://admin.hlx.page/ping/{org}/{site} returns 404 for any site Helix has no config for, including made-up names (checked against the live endpoint).
  • Anyone, without authenticating, can request a not-yet-created org/site and lock in da for it with no expiry. If that site is later created on HLX6, both workers keep routing it to DA until the entry is fixed by hand. feat: resolve site backends through shared KV da-admin#349 has the same logic.
  • The same request pattern also creates unlimited KV keys and outbound pings.
  • Suggested fix: don't persist 404s, or persist them with a short expirationTtl.

P2 — A failed KV write turns into a 503 (line 29)

  • Cloudflare KV allows only one write per second to the same key.
  • Lookups are only coalesced within a single isolate. When a site is first hit from several isolates/locations at once, their puts clash, some fail, and those requests return 503 even though the backend was already determined.
  • Suggested fix: return the probe result regardless and log the failed write.

Expire 404 results after five minutes and keep known routing results
when KV writes fail. Avoid sharing request-scoped I/O across requests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@kptdobe

kptdobe commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

@bosschaert Both findings are addressed in e803ef8, with matching resolver changes in adobe/da-admin#349.

  • P1: 404-derived classifications now use expirationTtl: 300 (five minutes), so an early request cannot pin a not-yet-created site indefinitely. Successful non-404 classifications and manual entries remain persistent.
  • P2: only KV write failures are caught and logged; routing returns the already-known probe result, for either backend. KV read failures, invalid values, and unsuccessful probes still fail closed rather than falling back to R2.

Also removed cross-request promise sharing, normalized cached values, and added the configurable HLX_ADMIN probe base URL. Focused regressions cover the exact 300-second TTL, permanent successful results, write failures for both backends, and independent concurrent probes when one fails.

The README now requires preloading all still-DA sites as da before rollout and clarifies that the upgrade header is a source-bus/overlay heuristic, not proof of completed cutover.

Residual limit: expiry limits retention, not traffic. Unauthenticated arbitrary-name requests can still create temporary entries and outbound pings; this change does not add a rate limiter or org-existence policy.

Validation: 111 tests pass with 100% statements, branches, functions, and lines; lint and the production dry-run build pass. All checks on the pushed head are green: CI run. PR descriptions and docs are updated; no manual production deployment was performed.

@bosschaert

bosschaert commented Nov 24, 2026 •

Copy link
Copy Markdown

Hi @kptdobe,

Thanks for the fixes. One non-blocking point: a DA site that isn't preloaded in KV and has no Helix config is pinged again every 5 minutes. If admin.hlx.page is down when that happens, those sites get 503s. The README's instruction to preload all DA sites as da covers this.

Rollout preloading does not protect later DA sites with AEM overlays.
Document explicit registry seeding and the derived org discovery cache.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@kptdobe
kptdobe merged commit 468fcaf into main Nov 25, 2026
3 checks passed
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.

2 participants