← Professional Cloud Developer: applications and production
05 / 7 · 35 MIN

Cloud Run: contracts and events

Validate execution contracts, invocation identity, and retry effects.

Concept and mechanism

A container working locally does not demonstrate compliance with the Cloud Run contract. In a service, the ingress container must listen on 0.0.0.0 at the configured port provided through PORT; listening only on loopback prevents the expected path. Cloud Run terminates TLS before forwarding to the container under the contract. A job differs: it runs work to completion, using exit code zero for success and nonzero for failure; it should not wait for requests like a server. These distinctions also affect logs, timeouts, and completion. Prepare the process for controlled termination and do not assume local memory survives instance replacement. Keep required state in an appropriate mechanism.

Guided application

In a fictional integration, A invokes B with authentication. Check caller identity, the Invoker role on the destination, and an ID token with B’s audience or an accepted custom audience. Additional privilege does not fix a token intended for another service. For asynchronous tasks, failure after persistence and before acknowledgment can cause redelivery; the handler should recognize the operation without repeating its effect. During release, observe revision-specific signals and understand interaction between traffic splitting and session affinity. Affinity can make observed distribution differ from configured percentages, especially when one client generates many requests. Use error and outcome evidence by version to decide advancement while retaining recovery covering data and configuration.

IN PRACTICE

A task can have produced its effect even when the service did not receive the 2xx response.

Common pitfalls

Loopback as ingress; job as server; Invoker as audience; percentage as an exact per-client quota.

Related topics: State, caching, and asynchronous flows · Credentials, secrets, and access · Build, artifacts, and provenance

Take this idea with you

Connect the technical contract to confirmation of the application’s outcome.

Create account

Reference: Cloud Run container contract · Current linked guide; edition date unconfirmed (2026-09-30 inspection)