Skip to content

Add Google Cloud Run worker-identity sample - #356

Draft
seanbollin wants to merge 1 commit into
mainfrom
cloud-run-worker-id
Draft

Add Google Cloud Run worker-identity sample#356
seanbollin wants to merge 1 commit into
mainfrom
cloud-run-worker-id

Conversation

@seanbollin

Copy link
Copy Markdown

What

Adds a runnable Google Cloud Run worker pool sample under gcp_cloud_run_worker_id/ that uses the new temporalio.contrib.gcp.cloud_run helper to derive a worker identity (<instance_id>@<revision>) and a PINNED Worker Deployment version from Cloud Run instance metadata, then runs a long-lived Worker until Cloud Run sends SIGTERM.

  • worker.py — derives identity + worker_deployment_config from get_google_cloud_run_metadata() and runs a versioned Worker.
  • workflows.py / activities.py — a small greeting Workflow (PINNED versioning behavior) + Activity.
  • settings.py — reads TEMPORAL_ADDRESS / TEMPORAL_NAMESPACE / TEMPORAL_TASK_QUEUE (plaintext), with optional TEMPORAL_API_KEY for Temporal Cloud (TLS).
  • starter.py — starts a Workflow from a local machine.
  • Dockerfile / .dockerignore — container build for gcloud run worker-pools deploy.
  • README.md — explains Cloud Run worker pools and the gcloud run worker-pools deploy … --set-env-vars … flow.

Structure mirrors the existing lambda_worker sample (standalone directory, own pyproject.toml, excluded from the root project's build/lint/type tooling).

Draft — depends on an unreleased helper

The Cloud Run metadata helper is not released yet (SDK PR: temporalio/sdk-python#1776). To keep this sample runnable, pyproject.toml pins temporalio to a local path source (../../sdk-python-2) on the cloud-run-worker-id branch. This [tool.uv.sources] override must be dropped (in favor of a released temporalio) once the helper ships; the README and Dockerfile call this out. The local path is not available inside a Docker build context, so the container build must use a released or git-pinned temporalio (documented in the Dockerfile).

Note: directory naming vs. the Cloud Run OpenTelemetry sample

There is a separate in-flight Cloud Run effort that adds a gcp_cloud_run/ sample (OpenTelemetry plugin). To avoid a directory collision, this worker-identity sample is named gcp_cloud_run_worker_id/. If both land, we may want to consolidate them under a single gcp_cloud_run/ sample (worker identity + OTel) or settle on a consistent naming scheme — flagging here for a maintainer decision before un-drafting.

Verification

🤖 Generated with Claude Code

Add a runnable sample that runs a long-lived Temporal Worker in a Google Cloud
Run worker pool and uses temporalio.contrib.gcp.cloud_run to derive the worker
identity and a PINNED Worker Deployment version from Cloud Run instance
metadata. The sample registers a small greeting Workflow and Activity, reads
TEMPORAL_ADDRESS / TEMPORAL_NAMESPACE / TEMPORAL_TASK_QUEUE (plaintext or, with
TEMPORAL_API_KEY, Temporal Cloud over TLS), and runs until Cloud Run sends
SIGTERM.

The sample is standalone and excluded from the root project's build/lint/type
tooling, mirroring the lambda_worker sample.

The Cloud Run metadata helper is not released yet, so pyproject.toml pins
temporalio to the local SDK checkout (../../sdk-python-2) on the
cloud-run-worker-id branch; the README and Dockerfile note this must be dropped
for a released (or git-pinned) temporalio once the helper ships.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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