Skip to content

fix(backend): declare Cloud Run Redis ports - #21127

Merged
Git-on-my-level merged 3 commits into
mainfrom
lane/dev-backend-redis-port
Oct 10, 2026
Merged

Git-on-my-level merged 3 commits into
mainfrom
lane/dev-backend-redis-port

Conversation

@Git-on-my-level

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

Copy link
Copy Markdown
Member

Declare Redis ports so a deploy restores the reviewed binding rather than relying on inherited Cloud Run configuration. Dev backend fell back to 6379 after its undeclared 13151 binding disappeared.

Changes

  • Declare REDIS_DB_PORT=13151 on backend, backend-integration, backend-sync and backend-sync-backfill in the base and explicitly in the dev overlay; regenerate runtime_env.yaml with compose_runtime_env.py. Read-only live checks confirm 13151 on all four services in both environments, so deploying this PR preserves current behavior.
  • Reject missing, empty, provisional or invalid Redis ports on these four services, and require a port wherever a Cloud Run service/job or desktop-backend declares REDIS_DB_HOST. Validate the corresponding Helm binding for GKE services with a declared host.
  • Assert the port reaches the actual deployment env renderer for every managed service/environment pair; add validator mutations and update the existing deployed-state fixture.

Incident evidence and scope

The first observed missing binding was dev revision backend-03418-fb2 at 2026-10-09 10:15:56Z. Both preceding revisions checked had 13151. Auto-deploy run 37914815339 subsequently deployed backend-2cfa871-37914815339-1 using --update-env-vars (merge), not replacement. Its rendered input did not declare the port, so it could not restore the earlier omission. COULD NOT DETERMINE the actor or mutation that created the 10:15 revision from the authorized service/revision metadata reads.

Inventory also confirms legacy dev Cloud Run backend-listen and pusher use 10797 (no corresponding prod Cloud Run services), and dev/prod plugins use 13151. These separate deployment paths are outside the four-service runtime manifest; they are unchanged. The currently managed GKE listen/pusher ports already live in Helm. This PR does not migrate deployment ownership.

No feature flags or application behavior change. No secrets or account data were read. Deployment applies to the four managed Cloud Run services; no pusher/listen image or backfill is required.

Validation

  • Regression before fix: 24 failed, 2 passed; eight failures demonstrate the missing port in actual deploy-renderer output.
  • Focused suites after fix: 27 passed, 49 passed, 161 passed (237 tests).
  • Runtime composition check and dev/prod manifest admission passed. All four full backend CI shards executed (1,706 files); shards 1 and 3 passed. Shards 2 and 4 each hit an unrelated transient timing failure (announcement CPU 1.20s against 1.00s; Soniox 100ms queue wait). Both files passed isolated retries with the original limits, one worker and a fresh TMPDIR: 5 passed in 5.36s and 24 passed in 4.76s. No allowlist or limit changes. Main's subsequent changelog and PR-evidence checker commits are merged. Focused tests re-passed (237 tests); local preflight passed all 35 selected checks. The normal push hook rechecks the final merge head.

Declarations and review risks

Failure-Class: FC-runtime-binding-contract

Invariant: INV-MEM-4 — runtime bindings preserve canonical promotion authority; all memory capability/rollout settings and mutation paths are unchanged.

GUARD CHANGED: backend/scripts/runtime_env_validation/manifest.py now rejects omitted Redis ports. Regression mutations still reject real violations; no guard bypass or exemption was added. The existing failure-class artifact list now names this reusable guard and its tests.

Review risks: confirm 13151 remains the desired Redis database for each managed service; verify consumers use the composed env renderer; review the explicit four-service requirement when adding another Cloud Run service. Exact causality of the earlier 10:15 configuration mutation remains undetermined.

View guided diff Turn on auto-fix

Keep the verified 13151 port on all four managed Cloud Run services in dev and prod. Reject omitted Redis port bindings before deploy and prove the port reaches the deploy renderer.

Failure-Class: FC-runtime-binding-contract
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 10, 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-10T08:59:24.498022Z 132a53e PR opened
ℹ️ 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.

@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: 132a53e820

ℹ️ 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 +145 to +146
port = actual_env.get('REDIS_DB_PORT') or {}
if not port.get('value') and not port.get('valueFrom'):

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 Validate the GKE Redis port value, not only its presence

When a Helm values file supplies a nonempty but invalid port such as not-a-port, 0, or 65536, this check passes because it tests only truthiness. _validate_env_entries does not inspect REDIS_DB_PORT because the GKE manifest declares only the host, so pre-deploy validation succeeds even though database/redis_db.py parses the value with int() and can crash backend-listen at import or fail to connect. Apply the same decimal and 1–65535 validation used for Cloud Run literals.

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

Useful? React with 👍 / 👎.

actual_env = _env_entries_by_name(values.get('env', []))
# GKE ports are declared in Helm values, while the host may come from
# the manifest's shared ConfigMap. Validate the effective pair.
if 'REDIS_DB_HOST' in (service_config.get('env') or {}):

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 Detect Redis hosts from the rendered GKE environment

The production pusher chart declares REDIS_DB_HOST and REDIS_DB_PORT, but environments.prod.gke.pusher.env intentionally omits the legacy host binding, so this predicate is false for that workload. Removing REDIS_DB_PORT from prod_omi_pusher_values.yaml therefore passes the new validator even while the host remains configured, causing pusher's Redis consumers to fall back to port 6379 instead of 13151. Base the requirement on actual_env (or explicitly include this chart) so the production workload is covered.

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

Useful? React with 👍 / 👎.

@Git-on-my-level
Git-on-my-level merged commit ce9c39f into main Oct 10, 2026
60 checks passed
@Git-on-my-level
Git-on-my-level deleted the lane/dev-backend-redis-port branch October 10, 2026 10:07
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