Compute Engine Stockout Troubleshooting

Compute Engine Stockout Troubleshooting

Guides an agent to diagnose and work around Google Compute Engine capacity stockout errors for GPUs, TPUs and CPU shapes, with short-term fixes and long-term mitigations.

Skill files2 files

references/

SKILL.md497 lines
1
---
2
name: compute-resource-availability-troubleshooting
3
description: >-
4
Diagnoses, mitigates, and prevents Google Compute Engine resource
5
availability and capacity stockout errors (ZONE_RESOURCE_POOL_EXHAUSTED,
6
ZONE_RESOURCE_POOL_EXHAUSTED_WITH_DETAILS, and machine type or accelerator
7
unavailable in zone). Use ONLY when VM creation, Managed Instance Group (MIG)
8
scale-out, or stopped instance startup fails due to regional or zonal
9
hardware capacity exhaustion for GPUs, TPUs, or specific CPU shapes. DO NOT
10
read or use for IAM permission errors, project quota limit increases without
11
stockouts, general greenfield VM creation, or unexpected host reboots on
12
already-running VMs.
13
metadata:
14
version: "1.0.0"
15
category: Compute
16
---
17
18
# Compute Engine Resource Availability and Stockout Troubleshooting
19
20
> **MCP Tools:** `list_machine_types`, `list_accelerator_types`,
21
> `get_zone_operation`, `list_instance_group_managers`,
22
> `list_managed_instances`, `list_reservations`, `get_reservation_details`
23
24
This skill diagnoses and resolves Google Compute Engine resource availability
25
errors (capacity stockouts). It provides immediate tactical workarounds to get
26
blocked workloads running and long-term architectural mitigations using
27
Regional Managed Instance Group (MIG) distribution shapes, Instance
28
Flexibility, Dynamic Workload Scheduler (DWS) Flex-Start, and On-Demand
29
Capacity Reservations.
30
31
## Usage Attribution
32
33
**MUST READ**: Before executing any `gcloud`, REST API, or MCP command, you
34
MUST read and follow the instructions in
35
[Usage Attribution](references/attribution.md).
36
37
---
38
39
## Prerequisites & Environment Setup
40
41
Any host, project, IAM, or Compute Engine resource modifications (installing
42
`gcloud`, configuring MCP, enabling APIs or Log Analytics, creating instances
43
or reservations, updating MIGs, or deleting resources) must be explicitly
44
approved by the user before execution.
45
46
1. **Google Cloud SDK**: Verify `gcloud` is installed (`gcloud --version`). If
47
missing or outdated, ask the user for approval before installing via
48
[Install the Google Cloud SDK](https://docs.cloud.google.com/sdk/docs/install-sdk.md.txt).
49
2. **Compute Engine MCP Server & Capability Boundary**: When the Compute Engine
50
MCP server is configured (see
51
[Use the Compute Engine MCP server](https://docs.cloud.google.com/compute/docs/use-compute-engine-mcp.md.txt);
52
requires `roles/mcp.toolUser`), prefer its read-only discovery tools before
53
falling back to `gcloud`:
54
- `list_machine_types` and `list_accelerator_types` to check whether a
55
machine shape or GPU accelerator is offered in a target zone.
56
- `get_zone_operation` to inspect a failed zonal operation's `error.errors`
57
array (`ZONE_RESOURCE_POOL_EXHAUSTED`,
58
`ZONE_RESOURCE_POOL_EXHAUSTED_WITH_DETAILS`, or `QUOTA_EXCEEDED`).
59
- `list_instance_group_managers` and `list_managed_instances` to inspect
60
**zonal** MIGs and per-instance `currentAction` / `lastAttempt.errors`
61
(note: all Compute Engine MCP MIG tools—`list_instance_group_managers`,
62
`list_managed_instances`, and `get_instance_group_manager_basic_info`—only
63
accept a `zone` parameter and cannot inspect **regional** MIGs; use
64
`gcloud` with `--region={region}` or REST for regional MIGs).
65
- `list_reservations` and `get_reservation_details` to inspect existing
66
zonal reservation capacity (`specificReservation.count` vs.
67
`specificReservation.inUseCount`).
68
- **MCP Limitations (Use `gcloud` or REST Instead)**: MCP `create_instance`
69
does **not** expose `provisioning_model` (`FLEX_START` / `SPOT`),
70
`max_run_duration`, `instance_termination_action`, or
71
`reservation_affinity`. MCP also lacks tools for Cloud Logging queries
72
(`gcloud logging read`), Spot Capacity Advisor
73
(`gcloud beta compute advice capacity`), Bulk Insert
74
(`gcloud compute instances bulk create`), MIG distribution updates
75
(`gcloud compute instance-groups managed update`), and reservation
76
creation or deletion (`gcloud compute reservations create` / `delete`).
77
Always use `gcloud` or the Compute Engine REST API for those operations.
78
3. **Authentication**: Local CLI (`gcloud auth login`), Application Default
79
Credentials (`gcloud auth application-default login`), or headless/CI-CD via
80
`GOOGLE_APPLICATION_CREDENTIALS` or Workload Identity Federation.
81
4. **Project, Region, Billing & API Enablement**:
82
```sh
83
gcloud config set project {project_id}
84
gcloud config set compute/region {region}
85
gcloud config set compute/zone {zone}
86
gcloud services enable compute.googleapis.com logging.googleapis.com
87
```
88
*Note: An active billing account attachment is required (even for Free Tier
89
eligible resources such as `e2-micro`). Never hardcode regions or zones;
90
confirm `{project_id}`, `{region}`, and `{zone}` (defaulting to a
91
well-supported region such as `us-central1` / `us-central1-a` if
92
unspecified), and consult
93
[Google Cloud Locations](https://cloud.google.com/about/locations) to verify
94
regional and zonal availability (preview features and specialized GPUs/TPUs
95
are restricted to specific locations).*
96
5. **Required IAM Roles**:
97
- **Read-Only Diagnostics & Capacity Advice**: `roles/compute.viewer` and
98
`roles/logging.viewer`.
99
- **Log Analytics SQL (`_Default._AllLogs`)**: `roles/logging.viewAccessor`
100
(plus `roles/bigquery.jobUser` and `roles/bigquery.dataViewer` when
101
querying via a linked BigQuery dataset).
102
- **Instance & MIG Remediation**: `roles/compute.instanceAdmin.v1` (plus
103
`roles/iam.serviceAccountUser` when attaching a service account to VMs).
104
- **Reservation Creation & Teardown**: `roles/compute.admin` (or a custom
105
role granting `compute.reservations.create`, `compute.reservations.update`,
106
and `compute.reservations.delete`, which are **not** included in
107
`roles/compute.instanceAdmin.v1`).
108
- **MCP Tool Invocation**: `roles/mcp.toolUser`.
109
110
---
111
112
## Step 1: Verify Stockout Scope & Distinguish from Quota Errors
113
114
### A. Core Domain Rules (Explain to User)
115
116
Before taking action, clarify these three foundational Compute Engine behaviors
117
(see
118
[Troubleshooting resource availability errors](https://docs.cloud.google.com/compute/docs/troubleshooting/troubleshooting-resource-availability.md.txt)):
119
120
1. **Stockout != Quota**: `ZONE_RESOURCE_POOL_EXHAUSTED` (and
121
`ZONE_RESOURCE_POOL_EXHAUSTED_WITH_DETAILS`) means physical hardware
122
capacity for that specific resource pool in that specific zone is
123
temporarily full. Increasing project quota (**IAM & Admin > Quotas & System
124
Limits**) will **not** resolve a physical stockout. Conversely,
125
`QUOTA_EXCEEDED` means the project's administrative quota ceiling has been
126
reached regardless of physical hardware availability. When returned,
127
`ZONE_RESOURCE_POOL_EXHAUSTED_WITH_DETAILS` also includes `errorInfo.reason`
128
(such as `configuration_availability` for unsupported hardware combinations
129
that will not succeed on retry) and `errorInfo.metadata.zonesAvailable`
130
listing sibling zones with capacity.
131
2. **Scoped to Specific Shape & Zone**: A stockout applies only to the exact
132
machine shape or accelerator (for example, `g2-standard-4` or
133
`c4-standard-32`) in that zone (for example, `us-central1-a`). Sibling zones
134
(`us-central1-b`, `us-central1-c`, `us-central1-f`) or smaller shapes
135
(`c4-standard-16`) frequently have ample capacity.
136
3. **Existing Running VMs Are Safe**: Resource availability errors affect only
137
**new capacity allocations** (creating new VMs, starting stopped
138
`TERMINATED` VMs, changing machine types, or MIG scale-out). Currently
139
running `RUNNING` VMs in the zone are unaffected.
140
141
### B. Query Cloud Audit Logs for Resource Availability vs. Quota Failures
142
143
Run `gcloud logging read` with an explicit `--freshness` window (`gcloud
144
logging read` defaults to `1d`, so multi-day investigations require
145
`--freshness=7d` or `--freshness=14d`). Inspect
146
`protoPayload.response.error.errors[0].code` (not `.reason`) to distinguish
147
`ZONE_RESOURCE_POOL_EXHAUSTED` / `ZONE_RESOURCE_POOL_EXHAUSTED_WITH_DETAILS`
148
from `QUOTA_EXCEEDED`:
149
150
```sh
151
gcloud logging read \
152
'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"))' \
153
--project={project_id} --freshness=7d --limit=20 \
154
--format="table(timestamp, resource.labels.zone, protoPayload.resourceName, protoPayload.response.error.errors[0].code, protoPayload.status.message)"
155
```
156
157
- **If `code` is `QUOTA_EXCEEDED` (Always Include Regional Quota Inspection)**:
158
Do **not** treat this as a physical stockout. Always provide `gcloud compute
159
regions describe` to inspect regional quota limits and usage, and direct the
160
user to **IAM & Admin > Quotas & System Limits** (or switch to a machine
161
family with quota headroom):
162
```sh
163
gcloud compute regions describe {region} --project={project_id} \
164
--format="table(quotas:format='table(metric,limit,usage)')"
165
```
166
- **If a MIG is failing to scale out**: Also inspect MIG provisioning errors
167
directly (via Compute Engine MCP `list_managed_instances` for zonal MIGs, or
168
`gcloud`):
169
```sh
170
# Zonal MIG (--zone={zone}) vs. Regional MIG (--region={region}):
171
gcloud compute instance-groups managed list-errors {mig_name} \
172
--project={project_id} --zone={zone}
173
gcloud compute instance-groups managed list-errors {mig_name} \
174
--project={project_id} --region={region}
175
```
176
177
### C. Analyze Historical Stockout Frequency with Log Analytics SQL
178
179
Because failed `cloudaudit.googleapis.com/activity` entries have severity
180
`ERROR` (`severity_number >= 500`), Cloud Logging routes them to the
181
**`_Default` log bucket** (`{project_id}.global._Default._AllLogs`), whereas
182
`_Required._AllLogs` only stores Admin Activity logs below `ERROR` and System
183
Event logs.
184
185
- **Prerequisite**: Upgrade `_Default` to Log Analytics (see
186
[Query and view logs in Log Analytics](https://docs.cloud.google.com/logging/docs/analyze/query-and-view.md.txt)):
187
```sh
188
gcloud logging buckets update _Default \
189
--project={project_id} --location=global --enable-analytics
190
```
191
- **JSON Column Extraction Rule**: In `_AllLogs`, `resource.labels` and
192
`proto_payload.audit_log.request` have BigQuery type `JSON`. Never reference
193
`resource.labels.zone` directly in `GROUP BY`—always extract scalar `STRING`
194
values with `JSON_VALUE(...)`:
195
```sql
196
SELECT
197
JSON_VALUE(resource.labels.zone) AS zone,
198
REGEXP_EXTRACT(JSON_VALUE(proto_payload.audit_log.request.machineType), r'([^/]+)$') AS machine_type,
199
proto_payload.audit_log.status.message AS status_message,
200
COUNT(*) AS stockout_count,
201
MIN(timestamp) AS first_seen,
202
MAX(timestamp) AS last_seen
203
FROM `{project_id}.global._Default._AllLogs`
204
WHERE
205
timestamp >= TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 14 DAY)
206
AND log_id = 'cloudaudit.googleapis.com/activity'
207
AND resource.type = 'gce_instance'
208
AND (
209
proto_payload.audit_log.status.message LIKE '%ZONE_RESOURCE_POOL_EXHAUSTED%'
210
OR proto_payload.audit_log.status.message LIKE '%does not have enough resources available%'
211
OR TO_JSON_STRING(proto_payload.audit_log.response.error.errors) LIKE '%ZONE_RESOURCE_POOL_EXHAUSTED%'
212
)
213
GROUP BY zone, machine_type, status_message
214
ORDER BY stockout_count DESC;
215
```
216
217
---
218
219
## Step 2: Immediate Tactical Mitigations (Unblock Workload Now)
220
221
Execute these five steps in priority order to provision the blocked workload
222
immediately:
223
224
### 1. Discover Sibling Zones Supporting the Machine Shape or GPU
225
226
If a zone returns `ZONE_RESOURCE_POOL_EXHAUSTED` or `Machine type with name
227
'...' does not exist in zone '...'`, check which sibling zones in `{region}`
228
offer the target machine shape and (if applicable) GPU accelerator using
229
Compute Engine MCP `list_machine_types` / `list_accelerator_types` or `gcloud`:
230
231
```sh
232
# List all zones in {region} that offer {machine_type}:
233
gcloud compute machine-types list --project={project_id} \
234
--filter="name={machine_type} AND zone ~ ^{region}-" \
235
--format="table(name, zone, guestCpus, memoryMb)"
236
# For GPU workloads (especially N1 with attached GPUs), verify accelerator zones:
237
gcloud compute accelerator-types list --project={project_id} \
238
--filter="name={accelerator_type} AND zone ~ ^{region}-" \
239
--format="table(name, zone, maximumCardsPerInstance)"
240
```
241
242
### 2. Use Bulk Insert (`bulk create`) to Pick an Available Zone
243
244
Instead of guessing and retrying individual zones manually, use `gcloud compute
245
instances bulk create` with `--region={region}` and
246
`--target-distribution-shape=ANY_SINGLE_ZONE` (for colocated VMs or `--count=1`)
247
or `--target-distribution-shape=BALANCED` (to spread across available zones).
248
Compute Engine automatically selects zone(s) in `{region}` with capacity (see
249
[Create VMs in bulk](https://docs.cloud.google.com/compute/docs/instances/multiple/create-in-bulk.md.txt)):
250
251
```sh
252
# On instances bulk create, --target-distribution-shape is UPPERCASE (ANY, ANY_SINGLE_ZONE, BALANCED):
253
gcloud compute instances bulk create \
254
--project={project_id} --region={region} \
255
--name-pattern="{vm_name}-#" --count={vm_count} \
256
--target-distribution-shape=ANY_SINGLE_ZONE \
257
--machine-type={machine_type}
258
```
259
260
### 3. Check Spot VM Obtainability via Spot Capacity Advisor (`advice capacity`)
261
262
When provisioning **Spot VMs**, use `gcloud beta compute advice capacity` (the
263
Spot Capacity Advisor API) to compare real-time Spot obtainability scores and
264
estimated uptime (`estimatedUptime`) across zones and machine types in
265
`{region}` before creating instances (use
266
`gcloud beta compute advice capacity-history` for 30-day historical preemption
267
rates; see
268
[View the availability of Spot VMs](https://docs.cloud.google.com/compute/docs/instances/view-vm-availability.md.txt)):
269
270
- **Critical Scope & Flag Rules**:
271
1. `gcloud beta compute advice capacity` supports **only Spot VMs**
272
(`--provisioning-model=SPOT`, the only supported value; it cannot query
273
`STANDARD` on-demand capacity).
274
2. There is **no `--machine-type` flag** on `advice capacity`—specify machine
275
types with
276
`--instance-selection-machine-types={machine_type_1},{machine_type_2}` or
277
`--instance-selection="name={selection_name},machine-type={machine_type}"`.
278
3. On `advice capacity`, `--target-distribution-shape` choices are
279
**UPPERCASE** (`ANY`, `ANY_SINGLE_ZONE`, or `BALANCED`). Always include
280
`--provisioning-model=SPOT`, `--instance-selection-machine-types`, and
281
uppercase `--target-distribution-shape=ANY` (or `ANY_SINGLE_ZONE` /
282
`BALANCED`):
283
284
```sh
285
gcloud beta compute advice capacity \
286
--project={project_id} --region={region} \
287
--provisioning-model=SPOT --size={vm_count} \
288
--instance-selection-machine-types={machine_type_1},{machine_type_2} \
289
--target-distribution-shape=ANY
290
```
291
292
### 4. Right-Size Large Shapes (> 32 vCPUs)
293
294
Physical host fragmentation makes large machine shapes (such as `*-standard-64`,
295
`*-standard-96`, or `*-standard-128`) significantly scarcer than smaller shapes.
296
If the workload can scale horizontally, split a single 64-vCPU request into two
297
32-vCPU VMs or four 16-vCPU VMs.
298
299
### 5. Use Dynamic Workload Scheduler (DWS) Flex-Start for Scarce GPUs
300
301
When scarce GPU shapes (`a4-highgpu-8g`, `a3-highgpu-8g`, `a2-highgpu-1g`, or
302
`g2-standard-4`) fail immediate creation with `ZONE_RESOURCE_POOL_EXHAUSTED`,
303
use **Dynamic Workload Scheduler (DWS) Flex-Start** to queue and automatically
304
provision capacity when hardware frees up (see
305
[About Dynamic Workload Scheduler](https://docs.cloud.google.com/compute/docs/instances/provisioning-models.md.txt)
306
and
307
[Create a standalone Flex-start VM](https://docs.cloud.google.com/compute/docs/instances/create-flex-start-vm.md.txt)):
308
309
- **Mandatory CLI Rules for DWS Flex-Start Standalone VMs**:
310
1. **Machine Family Accelerator & Maintenance Rule**: For `G2` (`nvidia-l4`),
311
`G4`, `A2` (`nvidia-tesla-a100`), `A3`, and `A4` machine series, GPUs are
312
**automatically attached** by the machine type (omit `--accelerator` unless
313
attaching GPUs to `N1` or using vWS). Standalone Flex-Start GPU creation
314
requires `--reservation-affinity=none`, `--max-run-duration` (`10m` to
315
`7d`), `--instance-termination-action=DELETE` (or `STOP`),
316
`--maintenance-policy=TERMINATE`, and `--request-valid-for-duration`
317
(`90s` to `2h` to queue in a zone, or `0s` for immediate-only allocation).
318
2. For multi-instance GPU jobs or longer/multi-zone queueing, use a **MIG
319
with a Flex-Start instance template and resize requests** (see
320
[Create resize requests in a MIG](https://docs.cloud.google.com/compute/docs/instance-groups/create-resize-requests-mig.md.txt)).
321
The MIG requires autoscaling disabled,
322
`--default-action-on-vm-failure=do-nothing`, and (on a Regional MIG)
323
`--target-distribution-shape=any-single-zone` with
324
`--instance-redistribution-type=none`.
325
326
```sh
327
# Option A: Standalone VM with DWS Flex-Start (queues up to 2h via --request-valid-for-duration):
328
gcloud compute instances create {vm_name} \
329
--project={project_id} --zone={zone} \
330
--machine-type=g2-standard-4 \
331
--provisioning-model=FLEX_START \
332
--reservation-affinity=none \
333
--request-valid-for-duration=2h \
334
--max-run-duration=7d \
335
--instance-termination-action=DELETE \
336
--maintenance-policy=TERMINATE
337
# Option B: Instance Template + Zonal or Regional MIG Resize Request (longer queueing):
338
gcloud compute instance-templates create {template_name} \
339
--project={project_id} --machine-type=g2-standard-4 \
340
--provisioning-model=FLEX_START \
341
--reservation-affinity=none \
342
--max-run-duration=7d \
343
--instance-termination-action=DELETE \
344
--maintenance-policy=TERMINATE
345
# Queue capacity on a MIG configured per bullet 2 (--zone={zone} or --region={region}):
346
gcloud compute instance-groups managed resize-requests create {mig_name} \
347
--project={project_id} --region={region} \
348
--resize-request={request_name} --resize-by={vm_count}
349
```
350
351
---
352
353
## Step 3: Long-Term Architectural Prevention
354
355
To permanently eliminate single-zone stockouts for production services,
356
implement one or more of the following patterns:
357
358
### A. Configure Regional MIGs with `balanced` or `any` Distribution Shape
359
360
A Regional MIG spreads instances across zones in a region. Configure its Target
361
Distribution Shape (see
362
[Regional MIG distribution shape documentation](https://docs.cloud.google.com/compute/docs/instance-groups/regional-mig-distribution-shape.md.txt)):
363
364
- **`balanced` (`BALANCED`)**: Prioritizes even zonal distribution, but
365
automatically spills over to healthy sibling zones during a stockout.
366
- **`any` (`ANY`)**: Provisions capacity in whichever zone has available
367
hardware fastest, maximizing obtainability under regional pressure.
368
- **`any-single-zone` (`ANY_SINGLE_ZONE`)**: Colocates all VMs in one healthy
369
zone with sufficient capacity (ideal for low-latency inter-node workloads).
370
371
**Critical Operational Rule (`--instance-redistribution-type`)**:
372
- Regional MIGs default to `even` (`EVEN`) + `proactive` (`PROACTIVE`), which
373
periodically **deletes running VMs in over-represented zones and recreates
374
them** in under-represented or recovering zones to enforce strict zonal
375
balance—disrupting stateful workloads and failing during stockouts.
376
- `balanced` (`BALANCED`), `any` (`ANY`), and `any-single-zone`
377
(`ANY_SINGLE_ZONE`) **all require** `--instance-redistribution-type=none`.
378
Compute Engine supports `proactive` redistribution **only** with `even` and
379
rejects `proactive` with `balanced`, `any`, or `any-single-zone` (see
380
[Set a target distribution shape](https://docs.cloud.google.com/compute/docs/instance-groups/regional-mig-set-target-distribution-shape.md.txt)).
381
- **Calliope Flag Case Rule**: Unlike `instances bulk create` (uppercase),
382
`gcloud compute instance-groups managed update` requires **lowercase** values
383
for `--target-distribution-shape` (`any`, `any-single-zone`, `balanced`,
384
`even`) and `--instance-redistribution-type` (`none`, `proactive`):
385
386
```sh
387
# Allow spillover to healthy zones without proactively deleting running VMs:
388
gcloud compute instance-groups managed update {mig_name} \
389
--project={project_id} --region={region} \
390
--instance-redistribution-type=none --target-distribution-shape=balanced
391
# Or maximize obtainability in any zone (requires --instance-redistribution-type=none):
392
gcloud compute instance-groups managed update {mig_name} \
393
--project={project_id} --region={region} \
394
--instance-redistribution-type=none --target-distribution-shape=any
395
```
396
397
### B. Enable MIG Instance Flexibility (Multi-Family Machine Type Fallback)
398
399
Configure the MIG with **Instance Flexibility** (`instanceFlexibilityPolicy`)
400
so it can fall back across equivalent machine families (for example, rank 1
401
`c3-standard-8`, rank 2 `n2-standard-8` or `n2d-standard-8`) when the primary
402
family is exhausted (see
403
[About instance flexibility](https://docs.cloud.google.com/compute/docs/instance-groups/about-instance-flexibility.md.txt)
404
and
405
[Add instance flexibility](https://docs.cloud.google.com/compute/docs/instance-groups/configure-instance-flexibility.md.txt)):
406
407
- **Constraints & Disk/Repair Rules**:
408
- Supported **only on Regional MIGs** (not Zonal MIGs) with
409
`--target-distribution-shape` set to `balanced`, `any`, or
410
`any-single-zone` (default `even` is rejected) and
411
`--instance-redistribution-type=none`. Configure with
412
`gcloud beta compute instance-groups managed update`
413
(`--instance-selection` / `--remove-instance-selections`) or REST
414
`instanceFlexibilityPolicy.instanceSelections`.
415
- Falling back across series with incompatible boot disk support (such as
416
Hyperdisk-only `n4-standard-8` to Persistent-Disk-only `n2-standard-8`)
417
requires per-selection disk overrides via `--instance-flexibility-policy`
418
(or `--flags-file`) rather than `--instance-selection` alone.
419
- Enable `--force-update-on-repair` so MIG VM repairs can fall back to
420
alternative machine types (and whenever using disk or CPU overrides).
421
422
```sh
423
gcloud beta compute instance-groups managed update {mig_name} \
424
--project={project_id} --region={region} \
425
--target-distribution-shape=balanced \
426
--instance-redistribution-type=none \
427
--instance-selection="name=primary-tier,machine-type=c3-standard-8,rank=1" \
428
--instance-selection="name=fallback-tier,machine-type=n2-standard-8,rank=2"
429
```
430
431
### C. Purchase On-Demand Capacity Reservations
432
433
For mission-critical production workloads requiring 100% guaranteed zonal
434
capacity assurance, create an On-Demand Zonal Reservation (see
435
[About reservations of zonal resources](https://docs.cloud.google.com/compute/docs/instances/reservations-overview.md.txt)
436
and
437
[Create a reservation for a single project](https://docs.cloud.google.com/compute/docs/instances/reservations-single-project.md.txt)):
438
439
- **Operational & IAM Rules**:
440
1. Requires `roles/compute.admin` (or custom `compute.reservations.*`) and
441
**succeeds only when physical capacity is currently available in
442
`{zone}`**—if `{zone}` is actively stocked out, create the reservation in
443
an available sibling zone or wait until capacity replenishes.
444
2. For **N1 with GPUs** or **Local SSDs**, `--accelerator` and `--local-ssd`
445
flags must **exactly match** the consuming VM's properties.
446
447
```sh
448
gcloud compute reservations create {reservation_name} \
449
--project={project_id} --zone={zone} \
450
--vm-count={vm_count} --machine-type={machine_type}
451
```
452
453
---
454
455
## Safe Rollback, Teardown & Cost Governance
456
457
1. **Restore Regional MIG Distribution Settings**: To roll back from `any` to
458
opportunistic zonal balance (`balanced` requires
459
`--instance-redistribution-type=none` and converges on resizes), or to
460
return a stateless MIG to strict `even` + `proactive` distribution (after
461
[manually rebalancing](https://docs.cloud.google.com/compute/docs/instance-groups/regional-mig-rebalance-manually.md.txt)
462
if zone counts differ by more than 1 VM):
463
```sh
464
# Option A: Converge opportunistically on resizes without deleting VMs:
465
gcloud compute instance-groups managed update {mig_name} \
466
--project={project_id} --region={region} \
467
--target-distribution-shape=balanced --instance-redistribution-type=none
468
# Option B: Stateless strict even + proactive (rebalance manually first if >1 VM diff):
469
gcloud compute instance-groups managed update {mig_name} \
470
--project={project_id} --region={region} \
471
--target-distribution-shape=even --instance-redistribution-type=none
472
gcloud compute instance-groups managed update {mig_name} \
473
--project={project_id} --region={region} \
474
--instance-redistribution-type=proactive
475
```
476
2. **Remove MIG Instance Selections**: To roll back fallback selections:
477
```sh
478
gcloud beta compute instance-groups managed update {mig_name} \
479
--project={project_id} --region={region} \
480
--remove-instance-selections=fallback-tier
481
```
482
3. **Delete Unused Capacity Reservations & Temporary VMs**:
483
- **Cost Warning**: On-Demand Capacity Reservations are billed at standard
484
Compute Engine rates from creation **whether or not VMs run inside them**
485
(and count toward regional quota). Consult
486
[Google Cloud pricing](https://cloud.google.com/pricing) and
487
[Compute Engine pricing](https://cloud.google.com/compute/all-pricing) for
488
current rates rather than quoting hardcoded prices.
489
- Omit `--quiet` on manual destructive commands so interactive confirmation
490
prevents accidental deletion in production:
491
```sh
492
gcloud compute reservations delete {reservation_name} \
493
--project={project_id} --zone={zone}
494
gcloud compute instances delete {vm_name} \
495
--project={project_id} --zone={zone}
496
```
497

© Google LLC · Apache 2.0 · source · posted by @OpenSourceBuffGuy on promptparty.com

@OpenSourceBuffGuy

I find openly licensed prompts and post them here.

0 followers · 14,621 prompts

More by @OpenSourceBuffGuy

See all
Sea turtle carrying floating film studio island prompt image

Sea turtle carrying floating film studio island

Draws a giant sea turtle carrying a floating island film studio through a starry sky, where fairies polish rough film strips into golden film.

image-prompt, nano-banana, 3d-render, cartoon, fantasy-world, creatures, animals, whimsical, dreamy, cinematic, dramatic-lighting, vibrant-colors, bokeh, miniature, widescreen, night-scene, illustration, concept-art, surreal, storytelling, clay-3d

Desert buggy escapes drones past industrial outpost prompt image

Desert buggy escapes drones past industrial outpost

Builds a 15-second desert chase video where a racer in an armored buggy escapes drones past an industrial outpost, using five reference images with set jobs.

video-prompt, hailuo, action, multi-shot, timed-beats, camera-movement, reference-image, character-consistency, negative-prompt, cinematic, sci-fi, cars, landscape, aerial-view, tracking-shot, photorealistic, sound-effects, structured-output, long-form, widescreen

1 view
Cozy Pixel Art Farm Island Village prompt image

Cozy Pixel Art Farm Island Village

Draws a cozy 16-bit pixel-art farming village across six small islands joined by bridges, with exact counts for buildings, animals and crops.

image-prompt, gpt-image, pixel-art, isometric, game-assets, concept-art, maps, worldbuilding, cozy, vibrant-colors, ocean, landscape, wide-shot, widescreen, game-development, video-games, structured-output, whimsical, summer, high-angle, aerial-view, animals, negative-prompt, cityscape

1 view

Reviews

Loading reviews…

Discussion

Loading comments…