Cloud Run traffic routing and prior revision rollback behavior
0 reputation · 20 Jun 2021, 04:53 UTC
0 reputation · 20 Jun 2021, 04:53 UTC
The goal is to determine the reliability of reversing a failed Cloud Run deployment by manually shifting 100% of traffic back to a previous immutable revision.
In fully managed Cloud Run, the service does not natively migrate traffic away from a new revision if the container instances crash or return consistent 5xx errors. Traffic remains assigned to the latest revision until the service traffic configuration is explicitly updated via the API or console.
There is uncertainty regarding the propagation latency of traffic updates across multiple regions; if a shift is initiated, the failed revision may continue to receive some requests during the transition. Additionally, the availability of a rollback depends entirely on whether the previous revision has been deleted during cleanup tasks.
Can traffic shifting to a prior revision be performed safely without a new deployment or image-rebuild? What are the specific indicators that confirm traffic has fully ceased reaching the failed revision? Does the deletion of old revisions immediately invalidate the ability to perform traffic-based rollback?
35275 reputation · 20 Jun 2021, 12:06 UTC
Yes, traffic shifting to a prior revision can be performed safely without a new deployment or image rebuild. Because Cloud Run revisions are immutable, you can reallocate 100% of traffic to any existing, non-deleted revision via the service traffic configuration. This update modifies the routing table of the service rather than the revision itself.
Cloud Run does not automatically detect container crashes or 5xx errors to trigger a rollback. Traffic remains assigned to the latest revision until an explicit configuration change is made via the Google Cloud Console, gcloud CLI, or the API.
The ability to perform a traffic-based rollback depends entirely on the existence of the target revision. If a revision has been deleted—either manually or via automated cleanup policies—it is permanently removed from the list of routable targets. Deletion immediately invalidates the ability to shift traffic back to that specific version; you cannot "undelete" a revision to restore it to the routing table.
While traffic reallocation is generally fast, it is not instantaneous. The following behaviors are expected during a shift:
To shift traffic back to a known stable revision (e.g., stable-revision-name) using the gcloud CLI:
gcloud run services update-traffic [SERVICE_NAME] --to-revisions=stable-revision-name=100 --region=[REGION]
To verify that traffic has fully ceased reaching the failed revision, monitor these three indicators:
Diagnostic Note: Please specify if you are using a Global Load Balancer or the default .a.run.app URL, as this changes the expected propagation latency for the traffic shift.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.