CANCELLED - Cancelled: Operation Terminated
CANCELLED means the operation was terminated before completion—either you explicitly cancelled it, a client timeout killed it, or GCP's system cancelled it due to resource constraints. This can be client-side (user cancellation, timeout) or server-side (system cancellation). Most common in Compute Engine when VM operations get cancelled, but also appears in Cloud SQL during cancelled database operations, GKE during cancelled cluster operations, and BigQuery when queries are cancelled. Unlike ABORTED (which indicates concurrency conflicts), CANCELLED means intentional or automatic termination—operations that exceed timeouts or get manually stopped return this error.
#Common Causes
- →Explicit Cancellation: The operation is cancelled by the caller (e.g., user cancellation, client timeout). The operation is intentionally terminated. This is transient—retrying the operation may succeed if it's still needed.
- →Timeout Cancellation: The operation exceeds a client-side timeout and is automatically cancelled. Client-side timeouts can cancel operations. This is transient—retrying with longer timeout may help.
- →System Cancellation: GCP's system cancels the operation due to system conditions (e.g., resource constraints, service issues). This is transient—retrying later may succeed.
- →Service-Specific Cancellation: Cancellation behavior varies by service. Some operations can be cancelled mid-execution, others cannot.
✓Solutions
- 1Step 1: Diagnose - Check operation status to see why it was cancelled: gcloud compute operations describe OPERATION_ID --zone ZONE --format="get(status,error)" --project PROJECT_ID
- 2Step 2: Diagnose - Review operation logs for cancellation reason: gcloud compute operations list --filter="name:OPERATION_ID" --project PROJECT_ID
- 3Step 3: Diagnose - Check if timeout was the cause by reviewing timeout settings and operation duration.
- 4Step 4: Diagnose - Check system conditions by reviewing GCP status page for known issues: Visit https://status.cloud.google.com/
- 5Step 5: Fix - If operation is still needed, retry the operation. Check why it was cancelled and address the cause.
- 6Step 6: Fix - For timeout cancellation, increase timeout: gcloud config set compute/timeout 600 Or use async operations for long-running tasks.
- 7Step 7: Fix - For system cancellation, retry after a delay.
- 8Step 8: Verify - Retry the operation. If it succeeds, the cancellation was transient.
</>Code Examples
1# This script handles CANCELLED errors by checking operation status and retrying
2
3PROJECT_ID="my-project"
4OPERATION_ID="operation-123"
5ZONE="us-central1-a"
6
7# Step 1: Check operation status
8echo "Checking operation status..."
9STATUS=$(gcloud compute operations describe $OPERATION_ID \
10 --zone $ZONE \
11 --project $PROJECT_ID \
12 --format="value(status)")
13
14echo "Operation status: $STATUS"
15
16# Step 2: If operation is done, check for cancellation error
17if [ "$STATUS" == "DONE" ]; then
18 ERROR=$(gcloud compute operations describe $OPERATION_ID \
19 --zone $ZONE \
20 --project $PROJECT_ID \
21 --format="value(error.code)" 2>/dev/null)
22
23 if [ "$ERROR" == "CANCELLED" ]; then
24 echo "Operation was cancelled. Checking cancellation reason..."
25
26 # Get error details
27 ERROR_MESSAGE=$(gcloud compute operations describe $OPERATION_ID \
28 --zone $ZONE \
29 --project $PROJECT_ID \
30 --format="value(error.message)" 2>/dev/null)
31
32 echo "Cancellation reason: $ERROR_MESSAGE"
33
34 # Step 3: Retry operation if still needed
35 echo "Retrying operation..."
36 INSTANCE_NAME="my-instance"
37 MACHINE_TYPE="n1-standard-1"
38
39 # Increase timeout before retry
40 gcloud config set compute/timeout 600
41
42 # Retry with async operation
43 NEW_OPERATION=$(gcloud compute instances create $INSTANCE_NAME \
44 --zone $ZONE \
45 --machine-type $MACHINE_TYPE \
46 --async \
47 --project $PROJECT_ID)
48
49 echo "New operation started: $NEW_OPERATION"
50 else
51 echo "Operation completed with status: $STATUS"
52 fi
53else
54 echo "Operation is still in progress: $STATUS"
55fi↗Related Errors
Provider Information
This error code is specific to GCP services. For more information, refer to the official GCP documentation.