{"data":{"slug":"github-google-skills-skills-cloud-compute-resource-availability-troubleshooting-22ab5d07b120","title":"Compute Engine Resource Stockout Diagnosis and Mitigation","summary":"Diagnose and resolve Google Compute Engine resource availability and capacity stockout errors for VM creation, MIG scale-out, and instance startup failures. Identify and mitigate ZONE_RESOURCE_POOL_EXHAUSTED errors.","url":"https:\/\/skillshunter.net\/skills\/github-google-skills-skills-cloud-compute-resource-availability-troubleshooting-22ab5d07b120","json_url":"https:\/\/skillshunter.net\/api\/public\/v1\/skills\/github-google-skills-skills-cloud-compute-resource-availability-troubleshooting-22ab5d07b120","markdown_url":"https:\/\/skillshunter.net\/skills\/github-google-skills-skills-cloud-compute-resource-availability-troubleshooting-22ab5d07b120.md","download_url":"https:\/\/skillshunter.net\/skills\/github-google-skills-skills-cloud-compute-resource-availability-troubleshooting-22ab5d07b120\/download","category":{"slug":"software-development","name":"Software & Development"},"editor_note":"Before executing any `gcloud`, REST API, or MCP command, you must read and follow the instructions in [Usage Attribution](references\/attribution.md). Verify that the Google Cloud SDK is installed (`gcloud --version`) and obtain user approval before installing or updating it.","instructions":"---\nname: compute-resource-availability-troubleshooting\ndescription: >-\n  Diagnoses, mitigates, and prevents Google Compute Engine resource\n  availability and capacity stockout errors (ZONE_RESOURCE_POOL_EXHAUSTED,\n  ZONE_RESOURCE_POOL_EXHAUSTED_WITH_DETAILS, and machine type or accelerator\n  unavailable in zone). Use ONLY when VM creation, Managed Instance Group (MIG)\n  scale-out, or stopped instance startup fails due to regional or zonal\n  hardware capacity exhaustion for GPUs, TPUs, or specific CPU shapes. DO NOT\n  read or use for IAM permission errors, project quota limit increases without\n  stockouts, general greenfield VM creation, or unexpected host reboots on\n  already-running VMs.\nmetadata:\n  version: \"1.0.0\"\n  category: Compute\n---\n\n# Compute Engine Resource Availability and Stockout Troubleshooting\n\n> **MCP Tools:** `list_machine_types`, `list_accelerator_types`,\n> `get_zone_operation`, `list_instance_group_managers`,\n> `list_managed_instances`, `list_reservations`, `get_reservation_details`\n\nThis skill diagnoses and resolves Google Compute Engine resource availability\nerrors (capacity stockouts). It provides immediate tactical workarounds to get\nblocked workloads running and long-term architectural mitigations using\nRegional Managed Instance Group (MIG) distribution shapes, Instance\nFlexibility, Dynamic Workload Scheduler (DWS) Flex-Start, and On-Demand\nCapacity Reservations.\n\n## Usage Attribution\n\n**MUST READ**: Before executing any `gcloud`, REST API, or MCP command, you\nMUST read and follow the instructions in\n[Usage Attribution](references\/attribution.md).\n\n---\n\n## Prerequisites & Environment Setup\n\nAny host, project, IAM, or Compute Engine resource modifications (installing\n`gcloud`, configuring MCP, enabling APIs or Log Analytics, creating instances\nor reservations, updating MIGs, or deleting resources) must be explicitly\napproved by the user before execution.\n\n1. **Google Cloud SDK**: Verify `gcloud` is installed (`gcloud --version`). If\n   missing or outdated, ask the user for approval before installing via\n   [Install the Google Cloud SDK](https:\/\/docs.cloud.google.com\/sdk\/docs\/install-sdk.md.txt).\n2. **Compute Engine MCP Server & Capability Boundary**: When the Compute Engine\n   MCP server is configured (see\n   [Use the Compute Engine MCP server](https:\/\/docs.cloud.google.com\/compute\/docs\/use-compute-engine-mcp.md.txt);\n   requires `roles\/mcp.toolUser`), prefer its read-only discovery tools before\n   falling back to `gcloud`:\n   - `list_machine_types` and `list_accelerator_types` to check whether a\n     machine shape or GPU accelerator is offered in a target zone.\n   - `get_zone_operation` to inspect a failed zonal operation's `error.errors`\n     array (`ZONE_RESOURCE_POOL_EXHAUSTED`,\n     `ZONE_RESOURCE_POOL_EXHAUSTED_WITH_DETAILS`, or `QUOTA_EXCEEDED`).\n   - `list_instance_group_managers` and `list_managed_instances` to inspect\n     **zonal** MIGs and per-instance `currentAction` \/ `lastAttempt.errors`\n     (note: all Compute Engine MCP MIG tools\u2014`list_instance_group_managers`,\n     `list_managed_instances`, and `get_instance_group_manager_basic_info`\u2014only\n     accept a `zone` parameter and cannot inspect **regional** MIGs; use\n     `gcloud` with `--region={region}` or REST for regional MIGs).\n   - `list_reservations` and `get_reservation_details` to inspect existing\n     zonal reservation capacity (`specificReservation.count` vs.\n     `specificReservation.inUseCount`).\n   - **MCP Limitations (Use `gcloud` or REST Instead)**: MCP `create_instance`\n     does **not** expose `provisioning_model` (`FLEX_START` \/ `SPOT`),\n     `max_run_duration`, `instance_termination_action`, or\n     `reservation_affinity`. MCP also lacks tools for Cloud Logging queries\n     (`gcloud logging read`), Spot Capacity Advisor\n     (`gcloud beta compute advice capacity`), Bulk Insert\n     (`gcloud compute instances bulk create`), MIG distribution updates\n     (`gcloud compute instance-groups managed update`), and reservation\n     creation or deletion (`gcloud compute reservations create` \/ `delete`).\n     Always use `gcloud` or the Compute Engine REST API for those operations.\n3. **Authentication**: Local CLI (`gcloud auth login`), Application Default\n   Credentials (`gcloud auth application-default login`), or headless\/CI-CD via\n   `GOOGLE_APPLICATION_CREDENTIALS` or Workload Identity Federation.\n4. **Project, Region, Billing & API Enablement**:\n   ```sh\n   gcloud config set project {project_id}\n   gcloud config set compute\/region {region}\n   gcloud config set compute\/zone {zone}\n   gcloud services enable compute.googleapis.com logging.googleapis.com\n   ```\n   *Note: An active billing account attachment is required (even for Free Tier\n   eligible resources such as `e2-micro`). Never hardcode regions or zones;\n   confirm `{project_id}`, `{region}`, and `{zone}` (defaulting to a\n   well-supported region such as `us-central1` \/ `us-central1-a` if\n   unspecified), and consult\n   [Google Cloud Locations](https:\/\/cloud.google.com\/about\/locations) to verify\n   regional and zonal availability (preview features and specialized GPUs\/TPUs\n   are restricted to specific locations).*\n5. **Required IAM Roles**:\n   - **Read-Only Diagnostics & Capacity Advice**: `roles\/compute.viewer` and\n     `roles\/logging.viewer`.\n   - **Log Analytics SQL (`_Default._AllLogs`)**: `roles\/logging.viewAccessor`\n     (plus `roles\/bigquery.jobUser` and `roles\/bigquery.dataViewer` when\n     querying via a linked BigQuery dataset).\n   - **Instance & MIG Remediation**: `roles\/compute.instanceAdmin.v1` (plus\n     `roles\/iam.serviceAccountUser` when attaching a service account to VMs).\n   - **Reservation Creation & Teardown**: `roles\/compute.admin` (or a custom\n     role granting `compute.reservations.create`, `compute.reservations.update`,\n     and `compute.reservations.delete`, which are **not** included in\n     `roles\/compute.instanceAdmin.v1`).\n   - **MCP Tool Invocation**: `roles\/mcp.toolUser`.\n\n---\n\n## Step 1: Verify Stockout Scope & Distinguish from Quota Errors\n\n### A. Core Domain Rules (Explain to User)\n\nBefore taking action, clarify these three foundational Compute Engine behaviors\n(see\n[Troubleshooting resource availability errors](https:\/\/docs.cloud.google.com\/compute\/docs\/troubleshooting\/troubleshooting-resource-availability.md.txt)):\n\n1. **Stockout != Quota**: `ZONE_RESOURCE_POOL_EXHAUSTED` (and\n   `ZONE_RESOURCE_POOL_EXHAUSTED_WITH_DETAILS`) means physical hardware\n   capacity for that specific resource pool in that specific zone is\n   temporarily full. Increasing project quota (**IAM & Admin > Quotas & System\n   Limits**) will **not** resolve a physical stockout. Conversely,\n   `QUOTA_EXCEEDED` means the project's administrative quota ceiling has been\n   reached regardless of physical hardware availability. When returned,\n   `ZONE_RESOURCE_POOL_EXHAUSTED_WITH_DETAILS` also includes `errorInfo.reason`\n   (such as `configuration_availability` for unsupported hardware combinations\n   that will not succeed on retry) and `errorInfo.metadata.zonesAvailable`\n   listing sibling zones with capacity.\n2. **Scoped to Specific Shape & Zone**: A stockout applies only to the exact\n   machine shape or accelerator (for example, `g2-standard-4` or\n   `c4-standard-32`) in that zone (for example, `us-central1-a`). Sibling zones\n   (`us-central1-b`, `us-central1-c`, `us-central1-f`) or smaller shapes\n   (`c4-standard-16`) frequently have ample capacity.\n3. **Existing Running VMs Are Safe**: Resource availability errors affect only\n   **new capacity allocations** (creating new VMs, starting stopped\n   `TERMINATED` VMs, changing machine types, or MIG scale-out). Currently\n   running `RUNNING` VMs in the zone are unaffected.\n\n### B. Query Cloud Audit Logs for Resource Availability vs. Quota Failures\n\nRun `gcloud logging read` with an explicit `--freshness` window (`gcloud\nlogging read` defaults to `1d`, so multi-day investigations require\n`--freshness=7d` or `--freshness=14d`). Inspect\n`protoPayload.response.error.errors[0].code` (not `.reason`) to distinguish\n`ZONE_RESOURCE_POOL_EXHAUSTED` \/ `ZONE_RESOURCE_POOL_EXHAUSTED_WITH_DETAILS`\nfrom `QUOTA_EXCEEDED`:\n\n```sh\ngcloud logging read \\\n    '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\"))' \\\n    --project={project_id} --freshness=7d --limit=20 \\\n    --format=\"table(timestamp, resource.labels.zone, protoPayload.resourceName, protoPayload.response.error.errors[0].code, protoPayload.status.message)\"\n```\n\n- **If `code` is `QUOTA_EXCEEDED` (Always Include Regional Quota Inspection)**:\n  Do **not** treat this as a physical stockout. Always provide `gcloud compute\n  regions describe` to inspect regional quota limits and usage, and direct the\n  user to **IAM & Admin > Quotas & System Limits** (or switch to a machine\n  family with quota headroom):\n  ```sh\n  gcloud compute regions describe {region} --project={project_id} \\\n      --format=\"table(quotas:format='table(metric,limit,usage)')\"\n  ```\n- **If a MIG is failing to scale out**: Also inspect MIG provisioning errors\n  directly (via Compute Engine MCP `list_managed_instances` for zonal MIGs, or\n  `gcloud`):\n  ```sh\n  # Zonal MIG (--zone={zone}) vs. Regional MIG (--region={region}):\n  gcloud compute instance-groups managed list-errors {mig_name} \\\n      --project={project_id} --zone={zone}\n  gcloud compute instance-groups managed list-errors {mig_name} \\\n      --project={project_id} --region={region}\n  ```\n\n### C. Analyze Historical Stockout Frequency with Log Analytics SQL\n\nBecause failed `cloudaudit.googleapis.com\/activity` entries have severity\n`ERROR` (`severity_number >= 500`), Cloud Logging routes them to the\n**`_Default` log bucket** (`{project_id}.global._Default._AllLogs`), whereas\n`_Required._AllLogs` only stores Admin Activity logs below `ERROR` and System\nEvent logs.\n\n- **Prerequisite**: Upgrade `_Default` to Log Analytics (see\n  [Query and view logs in Log Analytics](https:\/\/docs.cloud.google.com\/logging\/docs\/analyze\/query-and-view.md.txt)):\n  ```sh\n  gcloud logging buckets update _Default \\\n      --project={project_id} --location=global --enable-analytics\n  ```\n- **JSON Column Extraction Rule**: In `_AllLogs`, `resource.labels` and\n  `proto_payload.audit_log.request` have BigQuery type `JSON`. Never reference\n  `resource.labels.zone` directly in `GROUP BY`\u2014always extract scalar `STRING`\n  values with `JSON_VALUE(...)`:\n  ```sql\n  SELECT\n    JSON_VALUE(resource.labels.zone) AS zone,\n    REGEXP_EXTRACT(JSON_VALUE(proto_payload.audit_log.request.machineType), r'([^\/]+)$') AS machine_type,\n    proto_payload.audit_log.status.message AS status_message,\n    COUNT(*) AS stockout_count,\n    MIN(timestamp) AS first_seen,\n    MAX(timestamp) AS last_seen\n  FROM `{project_id}.global._Default._AllLogs`\n  WHERE\n    timestamp >= TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 14 DAY)\n    AND log_id = 'cloudaudit.googleapis.com\/activity'\n    AND resource.type = 'gce_instance'\n    AND (\n      proto_payload.audit_log.status.message LIKE '%ZONE_RESOURCE_POOL_EXHAUSTED%'\n      OR proto_payload.audit_log.status.message LIKE '%does not have enough resources available%'\n      OR TO_JSON_STRING(proto_payload.audit_log.response.error.errors) LIKE '%ZONE_RESOURCE_POOL_EXHAUSTED%'\n    )\n  GROUP BY zone, machine_type, status_message\n  ORDER BY stockout_count DESC;\n  ```\n\n---\n\n## Step 2: Immediate Tactical Mitigations (Unblock Workload Now)\n\nExecute these five steps in priority order to provision the blocked workload\nimmediately:\n\n### 1. Discover Sibling Zones Supporting the Machine Shape or GPU\n\nIf a zone returns `ZONE_RESOURCE_POOL_EXHAUSTED` or `Machine type with name\n'...' does not exist in zone '...'`, check which sibling zones in `{region}`\noffer the target machine shape and (if applicable) GPU accelerator using\nCompute Engine MCP `list_machine_types` \/ `list_accelerator_types` or `gcloud`:\n\n```sh\n# List all zones in {region} that offer {machine_type}:\ngcloud compute machine-types list --project={project_id} \\\n    --filter=\"name={machine_type} AND zone ~ ^{region}-\" \\\n    --format=\"table(name, zone, guestCpus, memoryMb)\"\n# For GPU workloads (especially N1 with attached GPUs), verify accelerator zones:\ngcloud compute accelerator-types list --project={project_id} \\\n    --filter=\"name={accelerator_type} AND zone ~ ^{region}-\" \\\n    --format=\"table(name, zone, maximumCardsPerInstance)\"\n```\n\n### 2. Use Bulk Insert (`bulk create`) to Pick an Available Zone\n\nInstead of guessing and retrying individual zones manually, use `gcloud compute\ninstances bulk create` with `--region={region}` and\n`--target-distribution-shape=ANY_SINGLE_ZONE` (for colocated VMs or `--count=1`)\nor `--target-distribution-shape=BALANCED` (to spread across available zones).\nCompute Engine automatically selects zone(s) in `{region}` with capacity (see\n[Create VMs in bulk](https:\/\/docs.cloud.google.com\/compute\/docs\/instances\/multiple\/create-in-bulk.md.txt)):\n\n```sh\n# On instances bulk create, --target-distribution-shape is UPPERCASE (ANY, ANY_SINGLE_ZONE, BALANCED):\ngcloud compute instances bulk create \\\n    --project={project_id} --region={region} \\\n    --name-pattern=\"{vm_name}-#\" --count={vm_count} \\\n    --target-distribution-shape=ANY_SINGLE_ZONE \\\n    --machine-type={machine_type}\n```\n\n### 3. Check Spot VM Obtainability via Spot Capacity Advisor (`advice capacity`)\n\nWhen provisioning **Spot VMs**, use `gcloud beta compute advice capacity` (the\nSpot Capacity Advisor API) to compare real-time Spot obtainability scores and\nestimated uptime (`estimatedUptime`) across zones and machine types in\n`{region}` before creating instances (use\n`gcloud beta compute advice capacity-history` for 30-day historical preemption\nrates; see\n[View the availability of Spot VMs](https:\/\/docs.cloud.google.com\/compute\/docs\/instances\/view-vm-availability.md.txt)):\n\n- **Critical Scope & Flag Rules**:\n  1. `gcloud beta compute advice capacity` supports **only Spot VMs**\n     (`--provisioning-model=SPOT`, the only supported value; it cannot query\n     `STANDARD` on-demand capacity).\n  2. There is **no `--machine-type` flag** on `advice capacity`\u2014specify machine\n     types with\n     `--instance-selection-machine-types={machine_type_1},{machine_type_2}` or\n     `--instance-selection=\"name={selection_name},machine-type={machine_type}\"`.\n  3. On `advice capacity`, `--target-distribution-shape` choices are\n     **UPPERCASE** (`ANY`, `ANY_SINGLE_ZONE`, or `BALANCED`). Always include\n     `--provisioning-model=SPOT`, `--instance-selection-machine-types`, and\n     uppercase `--target-distribution-shape=ANY` (or `ANY_SINGLE_ZONE` \/\n     `BALANCED`):\n\n```sh\ngcloud beta compute advice capacity \\\n    --project={project_id} --region={region} \\\n    --provisioning-model=SPOT --size={vm_count} \\\n    --instance-selection-machine-types={machine_type_1},{machine_type_2} \\\n    --target-distribution-shape=ANY\n```\n\n### 4. Right-Size Large Shapes (> 32 vCPUs)\n\nPhysical host fragmentation makes large machine shapes (such as `*-standard-64`,\n`*-standard-96`, or `*-standard-128`) significantly scarcer than smaller shapes.\nIf the workload can scale horizontally, split a single 64-vCPU request into two\n32-vCPU VMs or four 16-vCPU VMs.\n\n### 5. Use Dynamic Workload Scheduler (DWS) Flex-Start for Scarce GPUs\n\nWhen scarce GPU shapes (`a4-highgpu-8g`, `a3-highgpu-8g`, `a2-highgpu-1g`, or\n`g2-standard-4`) fail immediate creation with `ZONE_RESOURCE_POOL_EXHAUSTED`,\nuse **Dynamic Workload Scheduler (DWS) Flex-Start** to queue and automatically\nprovision capacity when hardware frees up (see\n[About Dynamic Workload Scheduler](https:\/\/docs.cloud.google.com\/compute\/docs\/instances\/provisioning-models.md.txt)\nand\n[Create a standalone Flex-start VM](https:\/\/docs.cloud.google.com\/compute\/docs\/instances\/create-flex-start-vm.md.txt)):\n\n- **Mandatory CLI Rules for DWS Flex-Start Standalone VMs**:\n  1. **Machine Family Accelerator & Maintenance Rule**: For `G2` (`nvidia-l4`),\n     `G4`, `A2` (`nvidia-tesla-a100`), `A3`, and `A4` machine series, GPUs are\n     **automatically attached** by the machine type (omit `--accelerator` unless\n     attaching GPUs to `N1` or using vWS). Standalone Flex-Start GPU creation\n     requires `--reservation-affinity=none`, `--max-run-duration` (`10m` to\n     `7d`), `--instance-termination-action=DELETE` (or `STOP`),\n     `--maintenance-policy=TERMINATE`, and `--request-valid-for-duration`\n     (`90s` to `2h` to queue in a zone, or `0s` for immediate-only allocation).\n  2. For multi-instance GPU jobs or longer\/multi-zone queueing, use a **MIG\n     with a Flex-Start instance template and resize requests** (see\n     [Create resize requests in a MIG](https:\/\/docs.cloud.google.com\/compute\/docs\/instance-groups\/create-resize-requests-mig.md.txt)).\n     The MIG requires autoscaling disabled,\n     `--default-action-on-vm-failure=do-nothing`, and (on a Regional MIG)\n     `--target-distribution-shape=any-single-zone` with\n     `--instance-redistribution-type=none`.\n\n```sh\n# Option A: Standalone VM with DWS Flex-Start (queues up to 2h via --request-valid-for-duration):\ngcloud compute instances create {vm_name} \\\n    --project={project_id} --zone={zone} \\\n    --machine-type=g2-standard-4 \\\n    --provisioning-model=FLEX_START \\\n    --reservation-affinity=none \\\n    --request-valid-for-duration=2h \\\n    --max-run-duration=7d \\\n    --instance-termination-action=DELETE \\\n    --maintenance-policy=TERMINATE\n# Option B: Instance Template + Zonal or Regional MIG Resize Request (longer queueing):\ngcloud compute instance-templates create {template_name} \\\n    --project={project_id} --machine-type=g2-standard-4 \\\n    --provisioning-model=FLEX_START \\\n    --reservation-affinity=none \\\n    --max-run-duration=7d \\\n    --instance-termination-action=DELETE \\\n    --maintenance-policy=TERMINATE\n# Queue capacity on a MIG configured per bullet 2 (--zone={zone} or --region={region}):\ngcloud compute instance-groups managed resize-requests create {mig_name} \\\n    --project={project_id} --region={region} \\\n    --resize-request={request_name} --resize-by={vm_count}\n```\n\n---\n\n## Step 3: Long-Term Architectural Prevention\n\nTo permanently eliminate single-zone stockouts for production services,\nimplement one or more of the following patterns:\n\n### A. Configure Regional MIGs with `balanced` or `any` Distribution Shape\n\nA Regional MIG spreads instances across zones in a region. Configure its Target\nDistribution Shape (see\n[Regional MIG distribution shape documentation](https:\/\/docs.cloud.google.com\/compute\/docs\/instance-groups\/regional-mig-distribution-shape.md.txt)):\n\n- **`balanced` (`BALANCED`)**: Prioritizes even zonal distribution, but\n  automatically spills over to healthy sibling zones during a stockout.\n- **`any` (`ANY`)**: Provisions capacity in whichever zone has available\n  hardware fastest, maximizing obtainability under regional pressure.\n- **`any-single-zone` (`ANY_SINGLE_ZONE`)**: Colocates all VMs in one healthy\n  zone with sufficient capacity (ideal for low-latency inter-node workloads).\n\n**Critical Operational Rule (`--instance-redistribution-type`)**:\n- Regional MIGs default to `even` (`EVEN`) + `proactive` (`PROACTIVE`), which\n  periodically **deletes running VMs in over-represented zones and recreates\n  them** in under-represented or recovering zones to enforce strict zonal\n  balance\u2014disrupting stateful workloads and failing during stockouts.\n- `balanced` (`BALANCED`), `any` (`ANY`), and `any-single-zone`\n  (`ANY_SINGLE_ZONE`) **all require** `--instance-redistribution-type=none`.\n  Compute Engine supports `proactive` redistribution **only** with `even` and\n  rejects `proactive` with `balanced`, `any`, or `any-single-zone` (see\n  [Set a target distribution shape](https:\/\/docs.cloud.google.com\/compute\/docs\/instance-groups\/regional-mig-set-target-distribution-shape.md.txt)).\n- **Calliope Flag Case Rule**: Unlike `instances bulk create` (uppercase),\n  `gcloud compute instance-groups managed update` requires **lowercase** values\n  for `--target-distribution-shape` (`any`, `any-single-zone`, `balanced`,\n  `even`) and `--instance-redistribution-type` (`none`, `proactive`):\n\n```sh\n# Allow spillover to healthy zones without proactively deleting running VMs:\ngcloud compute instance-groups managed update {mig_name} \\\n    --project={project_id} --region={region} \\\n    --instance-redistribution-type=none --target-distribution-shape=balanced\n# Or maximize obtainability in any zone (requires --instance-redistribution-type=none):\ngcloud compute instance-groups managed update {mig_name} \\\n    --project={project_id} --region={region} \\\n    --instance-redistribution-type=none --target-distribution-shape=any\n```\n\n### B. Enable MIG Instance Flexibility (Multi-Family Machine Type Fallback)\n\nConfigure the MIG with **Instance Flexibility** (`instanceFlexibilityPolicy`)\nso it can fall back across equivalent machine families (for example, rank 1\n`c3-standard-8`, rank 2 `n2-standard-8` or `n2d-standard-8`) when the primary\nfamily is exhausted (see\n[About instance flexibility](https:\/\/docs.cloud.google.com\/compute\/docs\/instance-groups\/about-instance-flexibility.md.txt)\nand\n[Add instance flexibility](https:\/\/docs.cloud.google.com\/compute\/docs\/instance-groups\/configure-instance-flexibility.md.txt)):\n\n- **Constraints & Disk\/Repair Rules**:\n  - Supported **only on Regional MIGs** (not Zonal MIGs) with\n    `--target-distribution-shape` set to `balanced`, `any`, or\n    `any-single-zone` (default `even` is rejected) and\n    `--instance-redistribution-type=none`. Configure with\n    `gcloud beta compute instance-groups managed update`\n    (`--instance-selection` \/ `--remove-instance-selections`) or REST\n    `instanceFlexibilityPolicy.instanceSelections`.\n  - Falling back across series with incompatible boot disk support (such as\n    Hyperdisk-only `n4-standard-8` to Persistent-Disk-only `n2-standard-8`)\n    requires per-selection disk overrides via `--instance-flexibility-policy`\n    (or `--flags-file`) rather than `--instance-selection` alone.\n  - Enable `--force-update-on-repair` so MIG VM repairs can fall back to\n    alternative machine types (and whenever using disk or CPU overrides).\n\n```sh\ngcloud beta compute instance-groups managed update {mig_name} \\\n    --project={project_id} --region={region} \\\n    --target-distribution-shape=balanced \\\n    --instance-redistribution-type=none \\\n    --instance-selection=\"name=primary-tier,machine-type=c3-standard-8,rank=1\" \\\n    --instance-selection=\"name=fallback-tier,machine-type=n2-standard-8,rank=2\"\n```\n\n### C. Purchase On-Demand Capacity Reservations\n\nFor mission-critical production workloads requiring 100% guaranteed zonal\ncapacity assurance, create an On-Demand Zonal Reservation (see\n[About reservations of zonal resources](https:\/\/docs.cloud.google.com\/compute\/docs\/instances\/reservations-overview.md.txt)\nand\n[Create a reservation for a single project](https:\/\/docs.cloud.google.com\/compute\/docs\/instances\/reservations-single-project.md.txt)):\n\n- **Operational & IAM Rules**:\n  1. Requires `roles\/compute.admin` (or custom `compute.reservations.*`) and\n     **succeeds only when physical capacity is currently available in\n     `{zone}`**\u2014if `{zone}` is actively stocked out, create the reservation in\n     an available sibling zone or wait until capacity replenishes.\n  2. For **N1 with GPUs** or **Local SSDs**, `--accelerator` and `--local-ssd`\n     flags must **exactly match** the consuming VM's properties.\n\n```sh\ngcloud compute reservations create {reservation_name} \\\n    --project={project_id} --zone={zone} \\\n    --vm-count={vm_count} --machine-type={machine_type}\n```\n\n---\n\n## Safe Rollback, Teardown & Cost Governance\n\n1. **Restore Regional MIG Distribution Settings**: To roll back from `any` to\n   opportunistic zonal balance (`balanced` requires\n   `--instance-redistribution-type=none` and converges on resizes), or to\n   return a stateless MIG to strict `even` + `proactive` distribution (after\n   [manually rebalancing](https:\/\/docs.cloud.google.com\/compute\/docs\/instance-groups\/regional-mig-rebalance-manually.md.txt)\n   if zone counts differ by more than 1 VM):\n   ```sh\n   # Option A: Converge opportunistically on resizes without deleting VMs:\n   gcloud compute instance-groups managed update {mig_name} \\\n       --project={project_id} --region={region} \\\n       --target-distribution-shape=balanced --instance-redistribution-type=none\n   # Option B: Stateless strict even + proactive (rebalance manually first if >1 VM diff):\n   gcloud compute instance-groups managed update {mig_name} \\\n       --project={project_id} --region={region} \\\n       --target-distribution-shape=even --instance-redistribution-type=none\n   gcloud compute instance-groups managed update {mig_name} \\\n       --project={project_id} --region={region} \\\n       --instance-redistribution-type=proactive\n   ```\n2. **Remove MIG Instance Selections**: To roll back fallback selections:\n   ```sh\n   gcloud beta compute instance-groups managed update {mig_name} \\\n       --project={project_id} --region={region} \\\n       --remove-instance-selections=fallback-tier\n   ```\n3. **Delete Unused Capacity Reservations & Temporary VMs**:\n   - **Cost Warning**: On-Demand Capacity Reservations are billed at standard\n     Compute Engine rates from creation **whether or not VMs run inside them**\n     (and count toward regional quota). Consult\n     [Google Cloud pricing](https:\/\/cloud.google.com\/pricing) and\n     [Compute Engine pricing](https:\/\/cloud.google.com\/compute\/all-pricing) for\n     current rates rather than quoting hardcoded prices.\n   - Omit `--quiet` on manual destructive commands so interactive confirmation\n     prevents accidental deletion in production:\n     ```sh\n     gcloud compute reservations delete {reservation_name} \\\n         --project={project_id} --zone={zone}\n     gcloud compute instances delete {vm_name} \\\n         --project={project_id} --zone={zone}\n     ```\n","use_cases":["Troubleshoot VM creation failures due to zonal hardware capacity exhaustion","Resolve MIG scale-out errors caused by GPU\/TPU stockouts","Diagnose stopped instance startup failures from resource pool exhaustion"],"limitations":[],"compatibility":[],"setup_tip":null,"sample_input":null,"sample_output":null,"source_url":"https:\/\/github.com\/google\/skills\/blob\/c413c1fdc1714f2e4ae44a449b9744348197119c\/skills\/cloud\/compute-resource-availability-troubleshooting\/SKILL.md","source_commit":"c413c1fdc1714f2e4ae44a449b9744348197119c","license":null,"version":null,"listing_approved_at":"2026-11-27","created_at":"2026-11-26T10:56:42.000000Z","updated_at":"2026-11-27T07:43:08.000000Z","seo_title":"Compute Engine Resource Stockout Diagnosis","seo_description":"Diagnose and resolve Compute Engine resource stockout errors for VM creation and MIG scale-out failures. Identify and mitigate ZONE_RESOURCE_POOL_EXHAUSTED errors.","seo_keywords":["Compute Engine resource stockout","ZONE_RESOURCE_POOL_EXHAUSTED troubleshooting","Compute Engine capacity exhaustion","VM creation failure diagnosis","MIG scale-out error resolution"]}}