Skip to content

Backport GCP Cloud Run scaling options to release/1.8.x - #1144

Merged
ks-temporal merged 2 commits into
temporalio:release/1.8.xfrom
chaptersix:cherry-pick-1135-1.8.x
Jul 31, 2026
Merged

Backport GCP Cloud Run scaling options to release/1.8.x#1144
ks-temporal merged 2 commits into
temporalio:release/1.8.xfrom
chaptersix:cherry-pick-1135-1.8.x

Conversation

@chaptersix

Copy link
Copy Markdown
Contributor

Related issues

Backports #1103 and #1135.

What changed?

Backports GCP Cloud Run Worker Deployment Version support and its min/max/initial instance and utilization-target scaling options to release/1.8.x. PR #1103 is included as the direct prerequisite for #1135.

Validation

  • go test ./...
  • Regenerated internal/temporalcli/commands.gen.go and confirmed it is unchanged
  • Confirmed module files are unchanged

Risk

This adds experimental Worker Deployment compute-configuration flags to the 1.8 release branch.

gcristea-temporal and others added 2 commits July 30, 2026 16:05
…nd (temporalio#1103)

Mirror the AWS Lambda support: four `--gcp-cloud-run-*` flags on
`create-version` and `update-version-compute-config`, writing a
gcp-cloud-run ComputeConfig provider.

## Related issues

<!-- Closes temporalio#123 -->

## What changed?

### Add GCP Cloud Run worker pools as a compute provider
Lets an operator point a Worker Deployment Version at a GCP Cloud Run
worker pool, mirroring the existing AWS Lambda support 1:1. CLI-only —
serializes the four detail keys WCI reads (`project`, `region`,
`worker_pool`, `service_account`)

```
  temporal worker deployment create-version \
      --deployment-name YourDeployment --build-id YourBuildID \
      --gcp-cloud-run-project YourProject \
      --gcp-cloud-run-region us-central1 \
      --gcp-cloud-run-worker-pool YourWorkerPool \
      --gcp-cloud-run-service-account customer-sa@proj.iam.gserviceaccount.com
 ```
  ### Changes
  - **commands.yaml / commands.gen.go**: four `--gcp-cloud-run-*` flags on
    `create-version` and `update-version-compute-config`, plus usage examples.
  - **commands.worker.deployment.go**: GCP validate/payload helpers and a
    shared `computeProviderConfig` selector that enforces AWS/GCP mutual
    exclusivity and dispatches on the trigger flag. Both `run` methods rewired.
  - **tests**: GCP validation + mutual-exclusivity cases folded into
    `TestCreateWorkerDeploymentVersion_Errors`; a skipped round-trip test
    mirrors the Lambda one (needs real GCP fixtures).

## Checklist

<!-- Your PR should satisfy all these requirements. However, feel free to remove items that don't apply to the PR. Consider giving this checklist to an AI agent before opening your PR. -->

**Stability**
- [ ] Breaking changes are marked with 💥 in the PR title and release notes
- [ ] Changes to JSON output (`-o json` / `-o jsonl`) are treated as breaking changes

**Design**
- [x] This feature does not depend on Cloud-only APIs or behavior (it works against an OSS server)
- [ ] New commands follow `temporal <noun> <verb>` structure (e.g. `temporal workflow start`)
- [x] New flags are named after the API concept, not the implementation mechanism (good: `--search-attribute`, bad: `--index-field`)
- [x] New flags don't duplicate an existing flag that serves the same purpose
- [x] New flags do not have short aliases without strong justification
- [ ] Experimental features are marked with `(Experimental)` in `commands.yaml`

**Help text** (see style guide at the top of `commands.yaml`)
- [ ] All flags shown in help text and examples are implemented and functional
- [x] Summaries use sentence case and have no trailing period
- [x] Long descriptions end with a period and include at least one example invocation
- [ ] Examples use long flags (`--namespace`, not `-n`), one flag per line
- [ ] Placeholder values use `YourXxx` form (`YourWorkflowId`, `YourNamespace`)

**Behavior**
- [x] Results go to stdout; errors and warnings go to stderr
- [x] Error messages are lowercase with no trailing punctuation

**Tests**
- [ ] Added functional test(s) (`SharedServerSuite`)
- [x] Added unit test(s) (`func TestXxx`) where applicable

## Manual tests

<!-- Edit the code samples below to provide setup and happy-path and error-path testing instructions. -->

**Setup**
```
./temporal --profile "ns-cloud-run-test" worker deployment
create-version \
    --deployment-name "cloud-run-deployment" \
    --build-id "1.0" \
    --gcp-cloud-run-project "compute-team-sandbox" \
    --gcp-cloud-run-region "us-west1" \
    --gcp-cloud-run-worker-pool "omes-worker-pool" \
--gcp-cloud-run-service-account
"wci-invocation-sa@compute-team-sandbox.iam.gserviceaccount.com"
Successfully created worker deployment version
```

**Happy path**
```
./temporal --profile "ns-cloud-run-test" worker deployment
describe-version \
      --deployment-name "cloud-run-deployment" \
      --build-id "1.0"
Worker Deployment Version:
  DeploymentName        cloud-run-deployment
  BuildID               1.0
  CreateTime            2 minutes ago
  RoutingChangedTime    a long while ago
  CurrentSinceTime      a long while ago
  RampingSinceTime      a long while ago
  RampPercentage        0
  ComputeConfigSummary  gcp-cloud-run
```

**Error case**
```
./temporal --profile "ns-cloud-run-test" worker deployment
create-version \
    --deployment-name "cloud-run-deployment" \
    --build-id "1.0" \
    --gcp-cloud-run-project "compute-team-sandbox" \
    --gcp-cloud-run-region "us-west1" \
    --gcp-cloud-run-worker-pool "fake-omes-worker-pool" \
--gcp-cloud-run-service-account
"wci-invocation-sa@compute-team-sandbox.iam.gserviceaccount.com"
Error: error creating worker deployment version: Worker Deployment
Version "cloud-run-deployment.1.0" already exists

./temporal --profile "ns-cloud-run-test" worker deployment
create-version \
    --deployment-name "cloud-run-deployment" \
    --build-id "2.0" \
    --gcp-cloud-run-project "compute-team-sandbox" \
    --gcp-cloud-run-region "us-west1" \
    --gcp-cloud-run-worker-pool "fake-omes-worker-pool" \
--gcp-cloud-run-service-account
"wci-invocation-sa@compute-team-sandbox.iam.gserviceaccount.com"
Error: error creating worker deployment version: default: worker pool
"projects/compute-team-sandbox/locations/us-west1/workerPools/fake-omes-worker-pool"
not found: rpc error: code = NotFound desc = Resource
'fake-omes-worker-pool' of kind 'WORKER_POOL' in region 'us-west1' in
project 'compute-team-sandbox' does not exist.
```

**Composition** <!-- How might a user combine this with existing commands? e.g. using the output of one command as input to another -->
```
$ temporal <command-one> ...
$ temporal <command-two> --flag <value-from-above>
<expected output>
```

(cherry picked from commit 076d1d5)
…alio#1135)

## Related issues

## What changed?

Adds four new (optional) flags `gcp-cloud-run-min-instances`,
`gcp-cloud-run-max-instances`, `gcp-cloud-run-initial-instances`, and
`gcp-cloud-run-utilization-target` to `create-version` and
`update-version-compute-config`.

```
temporal worker deployment create-version \
    --deployment-name YourDeployment \
    --build-id YourBuildID \
    --gcp-cloud-run-project YourProject \
    --gcp-cloud-run-region us-central1 \
    --gcp-cloud-run-worker-pool YourWorkerPool \
    --gcp-cloud-run-service-account customer-sa@proj.iam.gserviceaccount.com \
    --gcp-cloud-run-min-instances 0 \
    --gcp-cloud-run-max-instances 10 \
    --gcp-cloud-run-initial-instances 5 \
    --gcp-cloud-run-utilization-target 0.5
```

```
temporal worker deployment update-version-compute-config \
    --deployment-name YourDeployment \
    --build-id YourBuildID \
    --gcp-cloud-run-project YourProject \
    --gcp-cloud-run-region us-central1 \
    --gcp-cloud-run-worker-pool YourWorkerPool \
    --gcp-cloud-run-service-account customer-sa@proj.iam.gserviceaccount.com \
    --gcp-cloud-run-min-instances 0 \
    --gcp-cloud-run-max-instances 10 \
    --gcp-cloud-run-initial-instances 5 \
    --gcp-cloud-run-utilization-target 0.5
```

### Changes
- ***commands.yaml / commands.gen.go***: four new flags
  (--gcp-cloud-run-min-instances, --gcp-cloud-run-max-instances,
--gcp-cloud-run-initial-instances, --gcp-cloud-run-utilization-target)
on
create-version and update-version-compute-config, plus help text and
usage
  examples.

- ***commands.worker.deployment.go***: a new gcpCloudRunScalerDetails
helper turns
the flags into the scaling settings sent to the server, and rejects bad
input
early. All four settings are GCP-only and form a single all-or-none
group —
setting any one requires all four — with min <= initial <= max and
utilization-target a fraction in (0, 1]. Both commands use it, and
describe-version now shows the settings back in its JSON and summary
output.

- ***tests***: unit tests cover the helper's accept/reject cases and the
describe-version display; command-level error cases were added to
TestCreateWorkerDeploymentVersion_Errors. The end-to-end GCP test stays
skipped (needs real GCP resources).

## Checklist

<!-- Your PR should satisfy all these requirements. However, feel free
to remove items that don't apply to the PR. Consider giving this
checklist to an AI agent before opening your PR. -->

**Stability**
- [ ] Breaking changes are marked with 💥 in the PR title and release
notes
- [ ] Changes to JSON output (`-o json` / `-o jsonl`) are treated as
breaking changes

**Design**
- [x] This feature does not depend on Cloud-only APIs or behavior (it
works against an OSS server)
- [ ] New commands follow `temporal <noun> <verb>` structure (e.g.
`temporal workflow start`)
- [x] New flags are named after the API concept, not the implementation
mechanism (good: `--search-attribute`, bad: `--index-field`)
- [x] New flags don't duplicate an existing flag that serves the same
purpose
- [x] New flags do not have short aliases without strong justification
- [x] Experimental features are marked with `(Experimental)` in
`commands.yaml`

**Help text** (see style guide at the top of `commands.yaml`)
- [ ] All flags shown in help text and examples are implemented and
functional
- [x] Summaries use sentence case and have no trailing period
- [x] Long descriptions end with a period and include at least one
example invocation
- [ ] Examples use long flags (`--namespace`, not `-n`), one flag per
line
- [ ] Placeholder values use `YourXxx` form (`YourWorkflowId`,
`YourNamespace`)

**Behavior**
- [x] Results go to stdout; errors and warnings go to stderr
- [x] Error messages are lowercase with no trailing punctuation

**Tests**
- [ ] Added functional test(s) (`SharedServerSuite`)
- [x] Added unit test(s) (`func TestXxx`) where applicable

## Manual tests

Creation:
```
./temporal --profile "ns-cloud-run-test" worker deployment create-version \
    --deployment-name "zain-cloud-run-deployment" \
    --build-id "1.0" \
    --gcp-cloud-run-project "compute-team-sandbox" \
    --gcp-cloud-run-region "us-west1" \
    --gcp-cloud-run-worker-pool "omes-worker-pool" \
    --gcp-cloud-run-service-account "wci-invocation-sa@compute-team-sandbox.iam.gserviceaccount.com" \
    --gcp-cloud-run-min-instances 0 \
    --gcp-cloud-run-max-instances 10 \
    --gcp-cloud-run-initial-instances 5 \
    --gcp-cloud-run-utilization-target 0.5
Successfully created worker deployment version

./temporal --profile "ns-cloud-run-test" worker deployment describe-version \
    --deployment-name "zain-cloud-run-deployment" \
    --build-id "1.0" \
    --output json
...
        "scaler": {
          "type": "rate-based",
          "minInstances": 0,
          "maxInstances": 10,
          "initialInstances": 5,
          "utilizationTarget": 0.5
        }
...
```

Update existing:
```
./temporal --profile "ns-cloud-run-test" worker deployment update-version-compute-config \
    --deployment-name "zain-cloud-run-deployment" \
    --build-id "1.0" \
    --gcp-cloud-run-project "compute-team-sandbox" \
    --gcp-cloud-run-region "us-west1" \
    --gcp-cloud-run-worker-pool "omes-worker-pool" \
    --gcp-cloud-run-service-account "wci-invocation-sa@compute-team-sandbox.iam.gserviceaccount.com" \
    --gcp-cloud-run-min-instances 0 \
    --gcp-cloud-run-max-instances 20 \
    --gcp-cloud-run-initial-instances 10 \
    --gcp-cloud-run-utilization-target 0.5
Successfully updated worker deployment version compute config

./temporal --profile "ns-cloud-run-test" worker deployment describe-version \
    --deployment-name "zain-cloud-run-deployment" \
    --build-id "1.0" \
    --output json
{
...
        "scaler": {
          "type": "rate-based",
          "minInstances": 0,
          "maxInstances": 20,
          "initialInstances": 10,
          "utilizationTarget": 0.5
        }
...
```

Error checks:

```
./temporal --profile "ns-cloud-run-test" worker deployment create-version \
    --deployment-name "zain-cloud-run-deployment" \
    --build-id "1.0" \
    --gcp-cloud-run-project "compute-team-sandbox" \
    --gcp-cloud-run-region "us-west1" \
    --gcp-cloud-run-worker-pool "omes-worker-pool" \
    --gcp-cloud-run-service-account "wci-invocation-sa@compute-team-sandbox.iam.gserviceaccount.com" \
    --gcp-cloud-run-min-instances 0 \
    --gcp-cloud-run-max-instances 10 \
    --gcp-cloud-run-initial-instances 5
Error: --gcp-cloud-run-min-instances, --gcp-cloud-run-max-instances, --gcp-cloud-run-initial-instances, and --gcp-cloud-run-utilization-target must be set together
```

```
./temporal --profile "ns-cloud-run-test" worker deployment create-version \
    --deployment-name "cli-cloud-run-deployment" \
    --build-id "1.0" \
    --gcp-cloud-run-project "compute-team-sandbox" \
    --gcp-cloud-run-region "us-west1" \
    --gcp-cloud-run-worker-pool "omes-worker-pool" \
    --gcp-cloud-run-service-account "wci-invocation-sa@compute-team-sandbox.iam.gserviceaccount.com" \
    --gcp-cloud-run-min-instances 5 \
    --gcp-cloud-run-max-instances 10 \
    --gcp-cloud-run-initial-instances 0 \
    --gcp-cloud-run-utilization-target 0.5
Error: --gcp-cloud-run-initial-instances must be between --gcp-cloud-run-min-instances and --gcp-cloud-run-max-instances
```

```
./temporal --profile "ns-cloud-run-test" worker deployment create-version \
    --deployment-name my-deploy --build-id v1 \
    --aws-lambda-function-arn arn:aws:lambda:us-east-1:123:function:F:1 \
    --aws-lambda-assume-role-arn arn:aws:iam::123:role/R \
    --aws-lambda-assume-role-external-id x \
    --gcp-cloud-run-min-instances 0 \
    --gcp-cloud-run-max-instances 10 \
    --gcp-cloud-run-initial-instances 5 \
    --gcp-cloud-run-utilization-target 0.5
Error: the Cloud Run scaling flags are only valid with --gcp-cloud-run-worker-pool
```

(cherry picked from commit 41debba)
@chaptersix
chaptersix marked this pull request as ready for review July 30, 2026 21:10
@chaptersix
chaptersix requested a review from a team as a code owner July 30, 2026 21:10

@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: 8a43311148

ℹ️ 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 thread internal/temporalcli/commands.worker.deployment.go
@ks-temporal
ks-temporal merged commit c579925 into temporalio:release/1.8.x Jul 31, 2026
8 checks passed
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.

4 participants