Skip to content

docs(backend): C025 runbook — regionalize syncing-local staging bucket to us-central1 - #21242

Merged
Git-on-my-level merged 6 commits into
BasedHardware:mainfrom
Git-on-my-level:cost/c025-syncing-local-region
Oct 11, 2026
Merged

Git-on-my-level merged 6 commits into
BasedHardware:mainfrom
Git-on-my-level:cost/c025-syncing-local-region

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Oct 11, 2026 •

Copy link
Copy Markdown
Member

What

Ops runbook for regionalizing the sync v2 temporal staging bucket (syncing-local prod, syncing-local-development dev) from multi-region to us-central1, where every serving consumer (backend, backend-sync, pusher) already runs. Docs-only change — no code touched.

Why

Cost ledger card C025 (MEASURED, billing export): the bucket pays "Network Data Transfer GCP Replication within Northern America" for staging blobs, plus multi-region Class A unit prices. Combined ops+replication across the sync buckets stepped 2026-10-06 from ~$41/day to ~$129/day run rate (+$46/day WoW ex-drip), scaling with sync v2 adoption. The staging bucket's blobs are disposable (480s janitor + 1-day lifecycle backstop), so multi-region durability buys nothing here. Avoidable share modelled ~$40–60/day at current volume (replication line removal + lower Class A unit price; Class B list prices are identical multi-region vs regional).

What the runbook covers

  • Provisioning: regional Standard replacement buckets, UBLA + public-access-prevention, soft-delete disabled, age-1 Delete lifecycle, IAM carry-over review.
  • Migration safety — the non-obvious part: staged raw audio for queued/delayed/retry sync jobs can outlive the 8-minute segment TTL (payloads carry raw_blob_paths, resolved against the worker's current env). So the cutover requires: pause intake → drain Cloud Tasks/sequenced/retry jobs → wait out the 15-min signed-URL Redis cache → flip BUCKET_TEMPORAL_SYNC_LOCAL in all four chart values (prod+dev, backend-listen+pusher) → deploy → verify → resume.
  • Rollback: flip env back to the old bucket (kept until all consumers drain); available until old-bucket deletion.
  • Deletion gates: ≥48h after final write, no outstanding references, confirmed empty.
  • The durable omi-private-cloud-sync bucket is explicitly out of scope.

Verification

  • Every BUCKET_TEMPORAL_SYNC_LOCAL wiring site enumerated (4 chart values files, storage.py, recovery script, export_openapi, test harnesses).
  • Signed-URL path verified region-independent (V4 IAM-signed GET; Redis URL cache keyed by object path, not bucket).
  • make preflight passed (13 checks). Docs-only; no tests required.

Deploy note

The GCP-side bucket provisioning + cutover is an operator procedure executed per the runbook after merge; chart values intentionally remain unchanged in this PR until the new buckets exist.

🤖 Generated with Claude Code

View guided diff

Product invariants affected

Cost ledger card C025: prod syncing-local is multi-region, paying replication
for <=8-minute staging blobs (+$46/day WoW). Runbook covers replacement
bucket provisioning, intake pause + job drain (queued raw audio can outlive
8 min), 15-min signed-URL cache waitout, env flip in all four chart values,
rollback, and old-bucket deletion gates.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-11T19:20:42.800389Z c610554 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@Git-on-my-level Git-on-my-level added the ci:full Maintainer-granted: run full CI on this fork PR label Oct 11, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d01c19c319

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +134 to +136
and unused raw blobs drain via the one-day lifecycle. Account-deletion
cleanup resolves only the currently configured temporal bucket: ensure old
processes/URLs are drained and the old bucket expires leftovers; do not

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Fence account-deletion jobs during the bucket flip

When an account-deletion task is queued before the flip but executes after backend-sync starts with the new value, backend/utils/other/storage.py::delete_all_user_storage_objects() scans syncing/{uid}/ only in the currently configured bucket, so the task can mark the wipe complete while that user's raw audio remains in the old bucket until asynchronous lifecycle cleanup. The procedure drains only sync work and explicitly relies on expiry here; fence and drain deletion admissions/tasks too, or make the wipe cover both buckets, before changing the env.

AGENTS.md reference: backend/AGENTS.md:L145-L145

Useful? React with 👍 / 👎.

Comment on lines +118 to +119
`syncing-local-us-central1`. For dev, change both corresponding `dev_` files
to `syncing-local-development-us-central1` after dev provisioning.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep an already-regional dev bucket configured

When preflight finds syncing-local-development already regional, the earlier branch says not to create a replacement, but this step still switches both dev charts and the later Cloud Run values to syncing-local-development-us-central1. In that permitted path the named replacement was never provisioned, so the dev rollout loses staging access; make this update conditional and retain the verified existing name when provisioning is skipped.

Useful? React with 👍 / 👎.

@Git-on-my-level

Copy link
Copy Markdown
Member Author

Hermetic E2E + Merge Gate red is pre-existing on main: the same workflow fails on main at 2f0e9b2 (this PR's base, 17:27Z run) and a36fe08 (17:34Z), and multiple unrelated PR branches failed in the same 17:56–18:10Z window while others passed — 'Memory read admission exhausted' is the #21227 admission machinery tripping inside the shared hermetic harness. Absent from this diff (docs-only). Rerunning the failed jobs.

@Git-on-my-level

Copy link
Copy Markdown
Member Author

Red hermetic/unit checks root-caused and fixed in #21249 (first-attempt admission gated on document headroom denied legitimate truncated pages with 503 'Memory read admission exhausted'; reproduced on clean main, fix validated against #21227's own suites). Once #21249 merges, base-updating this PR should clear the shared failures; rerunning failed jobs in the meantime.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ab37d80099

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

# deterministically (attempts=0 → MemoryReadAdmissionDenied). Raise the
# burst for this suite and give every test a fresh allowance — the shared
# module-global instance otherwise carries spent tokens between tests.
import utils.memory.read_resilience as _rr

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Move the resilience import to module scope

Move utils.memory.read_resilience into the top-level import block rather than importing it when this fixture executes; otherwise this test's module graph depends on fixture ordering and violates the backend's strict requirement that imports never live inside functions.

AGENTS.md reference: backend/AGENTS.md:L161-L161

Useful? React with 👍 / 👎.

Grok review (read-only) found two blockers in the no-copy drain: Firestore
sync_backfill_pending docs carry raw_blob_paths and survive a Cloud Tasks +
Redis drain (expire as sync_staged_audio_expired post-flip); failed/partial
backfill jobs keep staged blobs and recover_dev_failed_sync_backfill.py
resolves paths against the current bucket env. Runbook now requires the
sequencer queue drained + recoverable failed/partial jobs finished or
copied before the flip, accounts chat voice-message staging in the URL-cache
clock, and documents the backfill clone-order hazard.
@Git-on-my-level

Copy link
Copy Markdown
Member Author

Both BLOCKERs fixed in c610554 (verified against sync_backfill_sequencer.py/uid_sequencer.py/recover_dev_failed_sync_backfill.py and the sibling env-isolation runbook): the drain now explicitly requires Firestore sync_backfill_pending documents enqueued+finished or operator-verified empty, and recoverable failed/partial jobs requeued+finished (or their objects copied) before the flip. NICE-TO-HAVEs folded in: chat voice-message staging accounted in the URL-cache clock, backfill clone-order hazard documented, dev-skip made verify-first. Fresh CI on the new head.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c610554392

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

4. Change `BUCKET_TEMPORAL_SYNC_LOCAL` in **both** prod charts:
`backend/charts/backend-listen/prod_omi_backend_listen_values.yaml` and
`backend/charts/pusher/prod_omi_pusher_values.yaml` to
`syncing-local-us-central1`. For dev, change both corresponding `dev_` files

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Deploy the bucket name selected during provisioning

When syncing-local-us-central1 is globally occupied—the provisioning section explicitly permits choosing a different unique name—this line still directs both production charts to the fixed occupied name. The later Cloud Run literal will then either diverge from Helm if it uses the bucket actually created, or every producer will target a bucket this procedure never provisioned if it copies this literal, breaking the cutover uploads; use the recorded/provisioned C025_NEW value in every chart and runtime overlay instead.

AGENTS.md reference: backend/AGENTS.md:L151-L151

Useful? React with 👍 / 👎.

@Git-on-my-level
Git-on-my-level merged commit 3e99087 into BasedHardware:main Oct 11, 2026
45 checks passed
@Git-on-my-level

Copy link
Copy Markdown
Member Author

Re-review (cursor grok-4.7-high, read-only — agentctl exec-horse-lion-fresh-nest-access-weather): VERDICT: APPROVE. Both prior blockers verified closed against the code (sequencer pending-doc semantics in register_job/kick; terminal-ack skip of _delete_staged_blobs_async for failed/partial; recovery script's current-env resolution + env-isolation runbook constraint). All three NICE-TO-HAVEs confirmed covered. Merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:full Maintainer-granted: run full CI on this fork PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant