compute resource availability troubleshooting
Diagnoses, mitigates, and prevents Google Compute Engine resource availability and capacity stockout errors (ZONE_RESOURCE_POOL_EXHAUSTED, ZONE_RESOURCE_POOL_EXHAUSTED_WITH_DETAILS, and machine type or accelerator unavailable in zone). Use ONLY when VM creation, Managed Instance Group (MIG) scale-out, or stopped instance startup fails due to regional or zonal hardware capacity exhaustion for GPUs, TPUs, or specific CPU shapes. DO NOT read or use for IAM permission errors, project quota limit inc
Documentation & Preview
--- name: compute-resource-availability-troubleshooting description: >- Diagnoses, mitigates, and prevents Google Compute Engine resource availability and capacity stockout errors (ZONE_RESOURCE_POOL_EXHAUSTED, ZONE_RESOURCE_POOL_EXHAUSTED_WITH_DETAILS, and machine type or accelerator unavailable in zone). Use ONLY when VM creation, Managed Instance Group (MIG) scale-out, or stopped instance startup fails due to regional or zonal hardware capacity exhaustion for GPUs, TPUs, or specific CPU shapes. DO NOT read or use for IAM permission errors, project quota limit increases without stockouts, general greenfield VM creation, or unexpected host reboots on already-running VMs. metadata: version: "1.0.0" category: Compute
---
Compute Engine Resource Availability and Stockout Troubleshooting
> MCP Tools: list_machine_types, list_accelerator_types, > get_zone_operation, list_instance_group_managers, > list_managed_instances, list_reservations, get_reservation_details
This skill diagnoses and resolves Google Compute Engine resource availability errors (capacity stockouts). It provides immediate tactical workarounds to get blocked workloads running and long-term architectural mitigations using Regional Managed Instance Group (MIG) distribution shapes, Instance Flexibility, Dynamic Workload Scheduler (DWS) Flex-Start, and On-Demand Capacity Reservations.
Usage Attribution
MUST READ: Before executing any gcloud, REST API, or MCP command, you MUST read and follow the instructions in Usage Attribution.
---
Prerequisites & Environment Setup
Any host, project, IAM, or Compute Engine resource modifications (installing gcloud, configuring MCP, enabling APIs or Log Analytics, creating instances or reservations, updating MIGs, or deleting resources) must be explicitly approved by the user before execution.
- Google Cloud SDK: Verify
gcloudis installed (gcloud --version). If
missing or outdated, ask the user for approval before installing via Install the Google Cloud SDK.
- Compute Engine MCP Server & Capability Boundary: When the Compute Engine
MCP server is configured (see Use the Compute Engine MCP server; requires roles/mcp.toolUser), prefer its read-only discovery tools before falling back to gcloud:
list_machine_typesandlist_accelerator_typesto check whether a
machine shape or GPU accelerator is offered in a target zone.
get_zone_operationto inspect a failed zonal operation'serror.errors
array (ZONE_RESOURCE_POOL_EXHAUSTED, ZONE_RESOURCE_POOL_EXHAUSTED_WITH_DETAILS, or QUOTA_EXCEEDED).
list_instance_group_managersandlist_managed_instancesto inspect
zonal MIGs and per-instance currentAction / lastAttempt.errors (note: all Compute Engine MCP MIG tools—list_instance_group_managers, list_managed_instances, and get_instance_group_manager_basic_info—only accept a zone parameter and cannot inspect regional MIGs; use gcloud with --region={region} or REST for regional MIGs).
list_reservationsandget_reservation_detailsto inspect existing
zonal reservation capacity (specificReservation.count vs. specificReservation.inUseCount).
- MCP Limitations (Use
gcloudor REST Instead): MCPcreate_instance
does not expose provisioning_model (FLEX_START / SPOT), max_run_duration, instance_termination_action, or reservation_affinity. MCP also lacks tools for Cloud Logging queries (gcloud logging read), Spot Capacity Advisor (gcloud beta compute advice capacity), Bulk Insert (gcloud compute instances bulk create), MIG distribution updates (gcloud compute instance-groups managed update), and reservation creation or deletion (gcloud compute reservations create / delete). Always use gcloud or the Compute Engine REST API for those operations.
- Authentication: Local CLI (
gcloud auth login), Application Default
Credentials (gcloud auth application-default login), or headless/CI-CD via GOOGLE_APPLICATION_CREDENTIALS or Workload Identity Federation.
- Project, Region, Billing & API Enablement:
gcloud config set project {project_id}
gcloud config set compute/region {region}
gcloud config set compute/zone {zone}
gcloud services enable compute.googleapis.com logging.googleapis.com*Note: An active billing account attachment is required (even for Free Tier eligible resources such as e2-micro). Never hardcode regions or zones; confirm {project_id}, {region}, and {zone} (defaulting to a well-supported region such as us-central1 / us-central1-a if unspecified), and consult Google Cloud Locations to verify regional and zonal availability (preview features and specialized GPUs/TPUs are restricted to specific locations).*
- Required IAM Roles:
- Read-Only Diagnostics & Capacity Advice:
roles/compute.viewerand
roles/logging.viewer.
- Log Analytics SQL (
_Default._AllLogs):roles/logging.viewAccessor
(plus roles/bigquery.jobUser and roles/bigquery.dataViewer when querying via a linked BigQuery dataset).
- Instance & MIG Remediation:
roles/compute.instanceAdmin.v1(plus
roles/iam.serviceAccountUser when attaching a service account to VMs).
- Reservation Creation & Teardown:
roles/compute.admin(or a custom
role granting compute.reservations.create, compute.reservations.update, and compute.reservations.delete, which are not included in roles/compute.instanceAdmin.v1).
- MCP Tool Invocation:
roles/mcp.toolUser.
---
Step 1: Verify Stockout Scope & Distinguish from Quota Errors
A. Core Domain Rules (Explain to User)
Before taking action, clarify these three foundational Compute Engine behaviors (see Troubleshooting resource availability errors):
- Stockout != Quota:
ZONE_RESOURCE_POOL_EXHAUSTED(and
ZONE_RESOURCE_POOL_EXHAUSTED_WITH_DETAILS) means physical hardware capacity for that specific resource pool in that specific zone is temporarily full. Increasing project quota (IAM & Admin > Quotas & System Limits) will not resolve a physical stockout. Conversely, QUOTA_EXCEEDED means the project's administrative quota ceiling has been reached regardless of physical hardware availability. When returned, ZONE_RESOURCE_POOL_EXHAUSTED_WITH_DETAILS also includes errorInfo.reason (such as configuration_availability for unsupported hardware combinations that will not succeed on retry) and errorInfo.metadata.zonesAvailable listing sibling zones with capacity.
- Scoped to Specific Shape & Zone: A stockout applies only to the exact
machine shape or accelerator (for example, g2-standard-4 or c4-standard-32) in that zone (for example, us-central1-a). Sibling zones (us-central1-b, us-central1-c, us-central1-f) or smaller shapes (c4-standard-16) frequently have ample capacity.
- Existing Running VMs Are Safe: Resource availability errors affect only
new capacity allocations (creating new VMs, starting stopped TERMINATED VMs, changing machine types, or MIG scale-out). Currently running RUNNING VMs in the zone are unaffected.
B. Query Cloud Audit Logs for Resource Availability vs. Quota Failures
Run gcloud logging read with an explicit --freshness window (gcloud logging read defaults to 1d, so multi-day investigations require --freshness=7d or --freshness=14d). Inspect protoPayload.response.error.errors[0].code (not .reason) to distinguish ZONE_RESOURCE_POOL_EXHAUSTED / ZONE_RESOURCE_POOL_EXHAUSTED_WITH_DETAILS from QUOTA_EXCEEDED:
gcloud logging read \
'resource.type="gce_instance" AND log_id("cloudaudit.googleapis.com/activity") AND (protoPayload.status.message:("ZONE_RESOURCE_POOL_EXHAUSTED" OR "does not have enough resources available" OR "resource pool exhausted" OR "does not exist in zone" OR "QUOTA_EXCEEDED" OR "Quota") OR protoPayload.response.error.errors.code:("ZONE_RESOURCE_POOL_EXHAUSTED" OR "ZONE_RESOURCE_POOL_EXHAUSTED_WITH_DETAILS" OR "QUOTA_EXCEEDED"))' \
--project={project_id} --freshness=7d --limit=20 \
--format="table(timestamp, resource.labels.zone, protoPayload.resourceName, protoPayload.response.error.errors[0].code, protoPayload.status.message)"- If
codeisQUOTA_EXCEEDED(Always Include Regional Quota Inspection):
Do not treat this as a physical stockout. Always provide gcloud compute regions describe to inspect regional quota limits and usage, and direct the user to IAM & Admin > Quotas & System Limits (or switch to a machine family with quota headroom):
gcloud compute regions describe {region} --project={project_id} \
--format="table(quotas:format='table(metric,limit,usage)')"- If a MIG is failing to scale out: Also inspect MIG provisioning errors
directly (via Compute Engine MCP list_managed_instances for zonal MIGs, or gcloud):
# Zonal MIG (--zone={zone}) vs. Regional MIG (--region={region}):
gcloud compute instance-groups managed list-errors {mig_name} \
--project={project_id} --zone={zone}
gcloud compute instance-groups managed list-errors {mig_name} \
--project={project_id} --region={region}C. Analyze Historical Stockout Frequency with Log Analytics SQL
Because failed cloudaudit.googleapis.com/activity entries have severity ERROR (severity_number >= 500), Cloud Logging routes them to the
_Default log bucket ({project_id}.global._Default._AllLogs), whereas _Required._AllLogs only stores Admin Activity logs below ERROR and System Event logs.
- Prerequisite: Upgrade
_Defaultto Log Analytics (see
Query and view logs in Log Analytics):
gcloud logging buckets update _Default \
--project={project_id} --location=global --enable-analytics- JSON Column Extraction Rule: In
_AllLogs,resource.labelsand
proto_payload.audit_log.request have BigQuery type JSON. Never reference resource.labels.zone directly in GROUP BY—always extract scalar STRING values with JSON_VALUE(...):
SELECT
JSON_VALUE(resource.labels.zone) AS zone,
REGEXP_EXTRACT(JSON_VALUE(proto_payload.audit_log.request.machineType), r'([^/]+)$') AS machine_type,
proto_payload.audit_log.status.message AS status_message,
COUNT(*) AS stockout_count,
MIN(timestamp) AS first_seen,
MAX(timestamp) AS last_seen
FROM `{project_id}.global._Default._AllLogs`
WHERE
timestamp >= TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 14 DAY)
AND log_id = 'cloudaudit.googleapis.com/activity'
AND resource.type = 'gce_instance'
AND (
proto_payload.audit_log.status.message LIKE '%ZONE_RESOURCE_POOL_EXHAUSTED%'
OR proto_payload.audit_log.status.message LIKE '%does not have enough resources available%'
OR TO_JSON_STRING(proto_payload.audit_log.response.error.errors) LIKE '%ZONE_RESOURCE_POOL_EXHAUSTED%'
)
GROUP BY zone, machine_type, status_message
ORDER BY stockout_count DESC;---
Step 2: Immediate Tactical Mitigations (Unblock Workload Now)
Execute these five steps in priority order to provision the blocked workload immediately:
1. Discover Sibling Zones Supporting the Machine Shape or GPU
If a zone returns ZONE_RESOURCE_POOL_EXHAUSTED or `Machine type with name '...' does