Skip to content

fix(deploy): render the desktop-backend expected env state its sidecar requires - #12147

Merged
Git-on-my-level merged 1 commit into
mainfrom
fix/desktop-sidecar-expected-env-state
Aug 24, 2026
Merged

Git-on-my-level merged 1 commit into
mainfrom
fix/desktop-sidecar-expected-env-state

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Aug 24, 2026 •

Copy link
Copy Markdown
Member

Summary

attach_cloud_run_gmp_sidecar.py gained a required --expected-env-state argument in #12098, and only one of its three callers was updated. Both desktop-backend deploy paths — production and automatic dev — have been failing at the sidecar attach step ever since:

attach_cloud_run_gmp_sidecar.py: error: the following arguments are required: --expected-env-state
Process completed with exit code 2
caller passed it before now
.github/actions/deploy-backend-stack/action.yml yes yes
.github/workflows/desktop_backend_prod.yml no yes
.github/workflows/desktop_backend_auto_dev.yml no yes

This is what failed production run 32690712862. It also explains something that read as a benign rollout state: dev's serving desktop-backend revision has no collector container because the last successful dev attach predates #12098 — dev was not waiting, it was failing every time.

Approach

The guard is worth keeping — it is what catches the dialect-coercion class fixed in #12083 — so the fix supplies the argument rather than relaxing it.

The backend path renders its expectation from backend/deploy/runtime_env.yaml and hands the same file to the sidecar script, so the expectation cannot drift from the deploy. The desktop workflows set their env inline in deploy-cloudrun, so the obvious fix is to restate those values in a second place — which recreates the exact "two copies drift apart" shape that caused this.

Instead, runtime_env.yaml already owns a desktop_backend.env section in both environments (USE_VERTEX_AI, GOOGLE_CLOUD_PROJECT, GCP_LOCATION, PROMETHEUS_SIDECAR_PORT), and all four already match what the workflows deploy. So:

  • render_backend_runtime_env.py gains --desktop-state-output, emitting {"services": {"desktop-backend": {"env": [...]}}} from that section.
  • Both workflows render it and pass --expected-env-state.

Two deliberate constraints:

  • Separate from --state-output. That file is also read by validate-backend-runtime-env.py, which walks cloud_run.services, and desktop-backend is not one of them. Keeping the builders apart means this cannot perturb the backend deploy path.
  • Standalone. The full render requires the backend service env ($CLOUD_RUN_VPC_NETWORK and friends). --desktop-state-output writes and returns before that, so desktop callers do not inherit the backend's environment requirements.

The manifest owns a subset of desktop-backend's env today, and that is fine: _expected_literal_env checks only the names it is given. A subset guard is a real guard; the empty one it replaces was not. Moving the remaining inline values into the manifest is the follow-up.

Why nothing caught it

check-desktop-backend-release-policy.py required the string attach_cloud_run_gmp_sidecar.py to appear somewhere in the file. It did. Every one of its ~30 required fragments still matched, all 26 fixtures passed, and the workflow was broken. The check triggers on backend/**/*.py, so it ran on #12098 — its contract was simply file-scoped where the defect was step-scoped.

The requirement is now bound to the step via the existing _step_block helper: the attach step must pass --expected-env-state, the render step must exist, must use --desktop-state-output, and must precede the attach.

Verification

  • test_check_desktop_backend_release_policy.py: 27 passed, including three new mutation fixtures per environment — dropping the argument, dropping the render step, and rendering with the wrong flag each fail with the reason named.
  • test_render_backend_runtime_env.py, test_backend_runtime_env_validator.py: 114 passed. The renderer change leaves the backend path untouched.
  • New test_desktop_state_output_is_shaped_for_the_sidecar_guard round-trips the rendered file through the consumer's own _expected_literal_env, so producer and consumer stay compatible by construction rather than by comment.
  • New test_desktop_manifest_env_matches_what_the_workflow_deploys asserts every manifest-owned value is what the workflow actually deploys. Negative proof: changing the manifest's prod PROMETHEUS_SIDECAR_PORT to 9091 fails with prod: PROMETHEUS_SIDECAR_PORT=9091 is not what the workflow deploys. Without this, drift would surface as a failed production deploy instead of a failed review.
  • Rendered output confirmed byte-for-byte against both environments' live values.

Product invariants affected

  • INV-DATA-1

No serving authority, routing pin, image lineage, or traffic-promotion rule is changed. This restores an argument to a deploy step and renders it from the manifest that already owned the values.

Failure-Class: FC-workflow-script-input-contract

Review in cubic

…r requires

attach_cloud_run_gmp_sidecar.py and updated only the backend caller, so
both desktop-backend deploy paths have failed at the attach step with an
argparse usage error ever since. Production run 32690712862 died there,
and dev's serving revision has no collector container for the same
reason -- it was failing, not waiting.

Supply the argument rather than relaxing the guard: it is what catches
the dialect-coercion class fixed in #12083. runtime_env.yaml already
owns desktop_backend.env in both environments and all four values
already match what the workflows deploy, so render the expectation from
there instead of restating it in the workflow, which would recreate the
drift this bug is an instance of.

Keep the new --desktop-state-output separate from --state-output, which
validate-backend-runtime-env.py reads, and let it write and return
before the full render so desktop callers do not inherit the backend
service env requirements.

Bind the release policy to the step: it required the script name
anywhere in the file, which still matched while both callers were
broken.
@Git-on-my-level
Git-on-my-level force-pushed the fix/desktop-sidecar-expected-env-state branch from cbbc156 to ea4f795 Compare August 24, 2026 15:16
@Git-on-my-level
Git-on-my-level merged commit 4b8636e into main Aug 24, 2026
35 checks passed
@Git-on-my-level
Git-on-my-level deleted the fix/desktop-sidecar-expected-env-state branch August 24, 2026 15:26
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