Skip to content

Add cpu_utilization and concurrency_utilization to Cloud Run v2 service revision scaling (beta)#18291

Open
yotamobol wants to merge 1 commit into
GoogleCloudPlatform:mainfrom
yotamobol:yotam/cloudrunv2-scaling-utilization-targets
Open

Add cpu_utilization and concurrency_utilization to Cloud Run v2 service revision scaling (beta)#18291
yotamobol wants to merge 1 commit into
GoogleCloudPlatform:mainfrom
yotamobol:yotam/cloudrunv2-scaling-utilization-targets

Conversation

@yotamobol

Copy link
Copy Markdown

Fixes hashicorp/terraform-provider-google#28324

Cloud Run added custom scaling controls in Preview on April 16, 2026 (release note). The Cloud Run Admin API v2 exposes them as template.scaling.cpuUtilization and template.scaling.concurrencyUtilization (GoogleCloudRunV2RevisionScaling, per the v2 discovery document), but the provider's revision scaling block only supports min_instance_count/max_instance_count, and the v2 API rejects the v1-style run.googleapis.com/scaling-* annotations — so these targets currently cannot be managed with Terraform at all.

This PR adds both fields to google_cloud_run_v2_service:

  • template.scaling.cpu_utilization (Double, beta-only)
  • template.scaling.concurrency_utilization (Double, beta-only)

Design notes for review:

  • min_version: 'beta' — the underlying feature is in Preview (configured via gcloud beta run services update --scaling-cpu-target/--scaling-concurrency-target).
  • No send_empty_value — the API uses 0.0 to disable a scaling driver and rejects requests where both drivers are disabled. Sending zero values for unset fields would therefore break every existing configuration that omits them. Consequence: explicitly setting 0.0 in config to disable a driver is not expressible with this change; happy to add custom expand logic if maintainers prefer supporting that case.
  • default_from_api: true — the server controls the effective default (0.6) and the fields are part of an opt-in surface; this avoids permadiffs when unset.
  • Fields are scoped to google_cloud_run_v2_service only; the gcloud/docs surface for this Preview is services-only (worker pools are not mentioned).
  • Added a beta acceptance test (TestAccCloudRunV2Service_cloudrunv2ServiceWithScalingUtilizationTargets) covering create (0.5/0.5), update (0.8/0.7), and import, modeled on the existing manual-scaling test in the same file.

Release Note Template for Downstream PRs (will be copied)

cloudrunv2: added `template.scaling.cpu_utilization` and `template.scaling.concurrency_utilization` fields to `google_cloud_run_v2_service` resource (beta)

@modular-magician modular-magician added the awaiting-approval Pull requests that need reviewer's approval to run presubmit tests label Jul 15, 2026
@google-cla

google-cla Bot commented Jul 15, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@github-actions

Copy link
Copy Markdown

Googlers: For automatic test runs see go/terraform-auto-test-runs.

@rileykarson, a repository maintainer, has been assigned to review your changes. If you have not received review feedback within 2 business days, please leave a comment on this PR asking them to take a look.

You can help make sure that review is quick by doing a self-review and by running impacted tests locally.

…ce revision scaling (beta)

Cloud Run custom scaling controls (Preview, April 2026) expose
template.scaling.cpuUtilization and template.scaling.concurrencyUtilization
in the Cloud Run Admin API v2, letting users configure the utilization
thresholds at which the autoscaler starts new instances.

Adds both fields as beta-only Double properties on the revision scaling
block of google_cloud_run_v2_service, plus a beta acceptance test
covering create and update.
@yotamobol yotamobol force-pushed the yotam/cloudrunv2-scaling-utilization-targets branch from cb352d6 to 709d72d Compare July 15, 2026 09:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting-approval Pull requests that need reviewer's approval to run presubmit tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for scaling utilization targets (cpuUtilization, concurrencyUtilization) to google_cloud_run_v2_service

2 participants