Repository navigation
fix(deploy): let Cloud Run preflight see past the metrics sidecar - #12080
Merged
Merged
Conversation
Automatic development deploys have failed since the Managed Prometheus sidecar landed in #11998: preflight-cloud-run-deploy.py: error: Legacy public-binding migration requires exactly one container per Cloud Run service The sidecar is attached to the candidate revision after the deploy, so the service carries two containers from then on. `_single_container` counted containers to prove there was one unambiguous set of runtime bindings to read, and the collector -- which holds none of those bindings -- broke that count. Select the application container by excluding the sidecar by name instead, which is the same rule `attach_cloud_run_gmp_sidecar.py` already applies when it resolves the ingress container. This is not development-only. `check_runtime_bindings` is gated to the auto-dev profile, but `migrate_legacy_public_bindings` runs unconditionally in `deploy-backend-stack`, and the sidecar attach is likewise ungated. The first production deploy would attach the sidecar and succeed; every production deploy after it would fail this argument check. Production has one container today (`backend-1`), so the fix lands before the trap arms rather than after. Tests cover both call sites and both directions: a service carrying the collector passes, and a service with two genuine application containers is still rejected. Both new tests fail against the current script with the exact error seen in CI. Co-Authored-By: Claude Opus 5 <[email protected]>
Git-on-my-level
added a commit
that referenced
this pull request
Aug 23, 2026
…12081) Development backend deploys still fail after #12080, now inside gcloud: ERROR: gcloud crashed (ValueError): Invalid secret path 'projects/based-hardware-dev/secrets/cloud-run-gmp-config' in annotation `_merge_secret_annotation` wrote the config secret into `run.googleapis.com/secrets` using the project ID. gcloud parses that annotation with ^projects/(?P<project>[0-9]{1,19})/secrets/(?P<secret>[a-zA-Z0-9-_]{1,255})... (googlecloudsdk/command_lib/run/secrets_mapping.py), so the project segment must be numeric. Resolve the project number and write that instead. The shape of this is worth naming. Cloud Run accepts the attach with either form, so nothing fails at attach time; the annotation is only re-parsed by the *next* `gcloud run deploy` on that service. The first deploy after the sidecar lands succeeds, and the one after it crashes on a service nobody touched in between -- which is why this read as unrelated to #11998. Production has no sidecar attached yet, so it has never written this annotation and is not carrying the defect. It would have written it on its first deploy and crashed on its second. `patch_service` stays pure: `attach_sidecar` resolves the number and passes it in, so no test needs a subprocess. A numeric project is passed through without calling gcloud at all. The new annotation test asserts against the gcloud regex verbatim rather than a hand-copied expectation. Failure-Class: new Co-authored-by: r <r@r> Co-authored-by: Claude Opus 5 <[email protected]>
abunet
added a commit
to abunet/omi
that referenced
this pull request
Aug 23, 2026
Six commits, no conflicts. Nineteen of the forty files are Swift desktop (legacy Home visibility, BasedHardware#11933, plus the v0.12.209 changelog). The rest is upstream's Cloud Run / GCP deploy lane: converging automatic dev deploys (BasedHardware#12019), a preflight that can see past the metrics sidecar (BasedHardware#12080), and the GMP secret annotation written with a project number (BasedHardware#12081). Post-merge audit (ADR-0029/0030): nothing to resolve. ports untouched — no file under database/store/, utils/{auth,vector,object_store}/, _client.py, or the notification transport is in the diff at all fidelity the four new backend modules (attach_cloud_run_gmp_sidecar, firebase_release_probe_token, preflight-cloud-run-deploy, runtime_env_validation/workflows) introduce no raw persistence and no firebase_admin.auth — they are deploy tooling, not request-path code guards 9/9 exit 0, including the env-parity guard: upstream declared no new runtime variable this time Worth noting for our own backlog: BasedHardware#12080 and the GMP sidecar attach script are the Cloud Run mechanism behind PROMETHEUS_SIDECAR_PORT, which the previous merge wrote off as a shape we do not deploy. Upstream building on it confirms the write-off was the right call rather than a gap on our side. Verification contract lane 55 files, 1083 passed, 78 skipped (live-tier only), 0 failed full sweep 1027 files in 3m19s, FAIL set identical to the pre-merge baseline upstream's five new backend test files run and pass under our runner (8 + 9 + 13 + 18 + 49), and their two new .github guard suites pass (37 + 67 subtests)
Git-on-my-level
added a commit
that referenced
this pull request
Aug 23, 2026
Development backend deploys fail at the post-deploy runtime-env validator:
ERROR [cloud_run/backend]: env MEMORY_ENABLED value mismatch: expected 'on'
The deploy sets it correctly -- the gcloud command carries MEMORY_ENABLED=on
-- and the live revision then holds 'true'. The sidecar attach rewrites it
in between.
gcloud emits YAML 1.2, where `on` is a string; production's untouched export
literally contains `value: on`. PyYAML implements YAML 1.1, where on/off/yes/no
are booleans. `attach_sidecar` safe_loads that export, patches it, and
safe_dumps it back through `services replace`, so `on` lands as the string
'true'. All three of the manifest's on/off keys are rewritten; none survive.
Nothing fails at attach time. Cloud Run stores the rewritten string, and every
consumer accepts the coerced spelling, so behaviour is unchanged. It surfaces
one step later in a validator, on a service nobody edited -- the same delayed
shape as #12080 and #12081.
Restrict the bool resolver to the YAML 1.2 core set so the round trip preserves
what gcloud wrote. safe_dump already quotes ambiguous strings, so only the read
side changes. containerPort, periodSeconds and containerConcurrency still load
as integers and real booleans still load as booleans.
Production has never attached the sidecar, so its export still says `value: on`.
Its first attach would rewrite all three flags and then fail its own gate.
The test fixture is copied verbatim from a real `--format=export` of the
production service, including the unquoted `value: on`. A hand-written fixture
would have been written in the dialect the author already assumes.
Failure-Class: new
Co-authored-by: r <r@r>
Co-authored-by: Claude Opus 5 <[email protected]>
This was referenced Aug 23, 2026
formed2forge
pushed a commit
to formed2forge/omi
that referenced
this pull request
Aug 24, 2026
…sedHardware#12080) Automatic development deploys have failed since the Managed Prometheus sidecar landed in BasedHardware#11998: preflight-cloud-run-deploy.py: error: Legacy public-binding migration requires exactly one container per Cloud Run service The sidecar is attached to the candidate revision after the deploy, so the service carries two containers from then on. `_single_container` counted containers to prove there was one unambiguous set of runtime bindings to read, and the collector -- which holds none of those bindings -- broke that count. Select the application container by excluding the sidecar by name instead, which is the same rule `attach_cloud_run_gmp_sidecar.py` already applies when it resolves the ingress container. This is not development-only. `check_runtime_bindings` is gated to the auto-dev profile, but `migrate_legacy_public_bindings` runs unconditionally in `deploy-backend-stack`, and the sidecar attach is likewise ungated. The first production deploy would attach the sidecar and succeed; every production deploy after it would fail this argument check. Production has one container today (`backend-1`), so the fix lands before the trap arms rather than after. Tests cover both call sites and both directions: a service carrying the collector passes, and a service with two genuine application containers is still rejected. Both new tests fail against the current script with the exact error seen in CI. Co-authored-by: r <r@r> Co-authored-by: Claude Opus 5 <[email protected]>
formed2forge
pushed a commit
to formed2forge/omi
that referenced
this pull request
Aug 24, 2026
…asedHardware#12081) Development backend deploys still fail after BasedHardware#12080, now inside gcloud: ERROR: gcloud crashed (ValueError): Invalid secret path 'projects/based-hardware-dev/secrets/cloud-run-gmp-config' in annotation `_merge_secret_annotation` wrote the config secret into `run.googleapis.com/secrets` using the project ID. gcloud parses that annotation with ^projects/(?P<project>[0-9]{1,19})/secrets/(?P<secret>[a-zA-Z0-9-_]{1,255})... (googlecloudsdk/command_lib/run/secrets_mapping.py), so the project segment must be numeric. Resolve the project number and write that instead. The shape of this is worth naming. Cloud Run accepts the attach with either form, so nothing fails at attach time; the annotation is only re-parsed by the *next* `gcloud run deploy` on that service. The first deploy after the sidecar lands succeeds, and the one after it crashes on a service nobody touched in between -- which is why this read as unrelated to BasedHardware#11998. Production has no sidecar attached yet, so it has never written this annotation and is not carrying the defect. It would have written it on its first deploy and crashed on its second. `patch_service` stays pure: `attach_sidecar` resolves the number and passes it in, so no test needs a subprocess. A numeric project is passed through without calling gcloud at all. The new annotation test asserts against the gcloud regex verbatim rather than a hand-copied expectation. Failure-Class: new Co-authored-by: r <r@r> Co-authored-by: Claude Opus 5 <[email protected]>
formed2forge
pushed a commit
to formed2forge/omi
that referenced
this pull request
Aug 24, 2026
…Hardware#12083) Development backend deploys fail at the post-deploy runtime-env validator: ERROR [cloud_run/backend]: env MEMORY_ENABLED value mismatch: expected 'on' The deploy sets it correctly -- the gcloud command carries MEMORY_ENABLED=on -- and the live revision then holds 'true'. The sidecar attach rewrites it in between. gcloud emits YAML 1.2, where `on` is a string; production's untouched export literally contains `value: on`. PyYAML implements YAML 1.1, where on/off/yes/no are booleans. `attach_sidecar` safe_loads that export, patches it, and safe_dumps it back through `services replace`, so `on` lands as the string 'true'. All three of the manifest's on/off keys are rewritten; none survive. Nothing fails at attach time. Cloud Run stores the rewritten string, and every consumer accepts the coerced spelling, so behaviour is unchanged. It surfaces one step later in a validator, on a service nobody edited -- the same delayed shape as BasedHardware#12080 and BasedHardware#12081. Restrict the bool resolver to the YAML 1.2 core set so the round trip preserves what gcloud wrote. safe_dump already quotes ambiguous strings, so only the read side changes. containerPort, periodSeconds and containerConcurrency still load as integers and real booleans still load as booleans. Production has never attached the sidecar, so its export still says `value: on`. Its first attach would rewrite all three flags and then fail its own gate. The test fixture is copied verbatim from a real `--format=export` of the production service, including the unquoted `value: on`. A hand-written fixture would have been written in the dialect the author already assumes. Failure-Class: new Co-authored-by: r <r@r> Co-authored-by: Claude Opus 5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What broke
Automatic development backend deploys have failed on every run since the Managed Prometheus sidecar landed in #11998:
deploy-backend-stackattaches the GMP collector to the candidate revision after the deploy, so from the first attach onward the service describes two containers._single_containercounted containers to prove there was one unambiguous set of runtime bindings to read, and the collector — which carries none of those bindings — broke the count. A correctly configured service now fails an argument check.Live confirmation:
The fix
Select the application container by excluding the sidecar by name, instead of counting containers. This is the same rule
attach_cloud_run_gmp_sidecar.pyalready applies when it resolves the ingress container, so the two scripts now agree on what the sidecar is.This is not development-only
check_runtime_bindingsis gated to theauto-devprofile, butmigrate_legacy_public_bindingsruns unconditionally indeploy-backend-stack, and the sidecar attach step is likewise ungated. Production has one container today, so the sequence there would be:This lands before that trap arms rather than after.
A second occurrence, deliberately not fixed here
backend/scripts/sync_ledger_fence_cutover.py:307has the same defect:It collects images across every container and requires exactly one, and its
SERVICEStuple includesbackend— the service that now carries the collector. It isworkflow_dispatch-only, so it blocks nothing today, but the next manual sync-ledger fence cutover would fail on it.It is left out of this PR on purpose: that script sets up no sibling imports, so sharing the sidecar name with it means either duplicating a magic string (the drift that caused this class) or adding import machinery to a deploy-critical script under
backend-import-purity. That deserves its own change rather than riding along with an urgent unblock.Verification
Both new tests fail against the current script with the exact error string seen in CI, and pass with the fix. Coverage runs in both directions: a service carrying the collector is accepted, and a service with two genuine application containers is still rejected.
tests/unit/test_preflight_cloud_run_deploy.py— 18 passedtest_attach_cloud_run_gmp_sidecar.py,test_backend_runtime_env_validator.py,test_render_backend_runtime_env.py— 114 passedFailure-Class: new