Cloud Run Admin API v2: HTTP 409 revision collision when restoring service-level automatic scaling

Cloud Run Admin API v2 — HTTP 409 when restoring service-level scaling

Hello Google Cloud Community,

We are experiencing an issue restoring automatic scaling on a production Cloud Run service associated with a Firebase Functions Gen 2 deployment.

Initial configuration:

  • Service-level scaling: AUTOMATIC

  • Maximum instances: 20

  • Traffic: 100% to the existing latest revision

Maintenance action:

We temporarily disabled the service by setting manual scaling to zero instances. This succeeded, and the service returned HTTP 503 as expected.

Recovery attempts:

We attempted to restore automatic scaling through Cloud Run Admin API v2 using an up-to-date etag.

First attempt:

  • Update mask: scaling,traffic

  • Result: HTTP 409

Second attempt:

  • Update mask: scaling

  • Requested scaling mode: AUTOMATIC

  • Maximum instances: 20

  • Result: HTTP 409 ALREADY_EXISTS

The second attempt returned:

Revision named '[existing-revision]' with different configuration already exists.

Neither PATCH explicitly modified the revision template.

Current verified state:

  • Service scaling: MANUAL

  • Manual instance count: 0

  • Service generation matches observed generation

  • Reconciliation completed successfully

  • No traffic tags

  • Revision template maximum instances: 10

  • Stored revision maximum instances: 10

The revision template and stored revision configurations match. The original service-level maximum of 20 is separate from the revision-level maximum of 10.

Both recovery requests omitted an explicit clearing of manualInstanceCount.

Questions:

  1. Why would a service-level scaling update produce an existing-revision configuration collision?

  2. What is the officially supported procedure for transitioning from MANUAL/0 back to AUTOMATIC through Cloud Run Admin API v2?

  3. Should manualInstanceCount be explicitly cleared using a granular update mask and a null value?

  4. Is there a known issue involving revision configuration comparisons during service-level scaling changes?

  5. Is there a safe recovery procedure that preserves the existing revision, traffic configuration and IAM settings without redeploying?

We have stopped further production modifications until the recovery procedure can be validated.

Any guidance or official documentation would be greatly appreciated. Thank you.

Hit the same thing on Firebase Functions gen 2 services. Any v2 services.patch that touches only scaling fails with:

ALREADY_EXISTS: Revision named '<revision>' with different configuration already exists.

What we tried, all refused the same way, and none changed the service:

  • mask scaling.min_instance_count with a partial body (name + scaling)
  • mask scaling with a partial body
  • the full Service exactly as services.get returned it, only scaling.minInstanceCount changed, with and without a mask
  • the same full body with the container image swapped for the revision’s digest and the revision’s labels merged in

The cause, as far as we can tell: Firebase pins the revision name in the service template, and v2 re-asserts the template on every update, even under a scaling-only mask. v2’s view of the template never matches the stored revision (the template names the image by tag, the revision by digest; the revision carries goog-managed-by: cloudfunctions and goog-cloudfunctions-runtime labels the template does not), so even the unmodified object is refused as a name clash.

What works: the v1 Knative surface, which is what gcloud run services update --min uses:

  1. GET https://<region>-run.googleapis.com/apis/serving.knative.dev/v1/namespaces/<project>/services/<service>
  2. Set metadata.annotations["run.googleapis.com/minScale"] (for example "1"), or delete the key to go back to default.
  3. PUT the same object back to the same URL.

That returns HTTP 200 synchronously, bumps metadata.generation, and creates no new revision: the template name and the latest ready revision stay the same. The PUT carries the GET’s metadata.resourceVersion, so a concurrent deploy answers 409 and you re-read and retry.

For your case (restoring automatic scaling after manual), we have not tested the run.googleapis.com/scalingMode / manual-instance annotations through v1, only minScale, so treat that part as untested.

One thing to avoid: clearing template.revision on v2 does get the update through, but it creates a new revision from the template’s image. With Firebase’s default Artifact Registry cleanup policy (images older than a day are deleted), that fails with Image … not found on any service that was deployed more than a day earlier.