1
---
2
name: gke-ai-troubleshooting-jobset-interruption
3
metadata:
4
version: "1.0.1"
5
category: Containers
6
description: >-
7
Diagnoses GKE JobSet interruptions, restarts, and preemptions for AI/ML training workloads autonomously.
8
Use when troubleshooting JobSet restart loops, spot VM preemptions, node readiness failures, host VM issues, or coordinator worker crashes.
9
Don't use for general GKE cluster creation, basic workload deployment, or non-JobSet application issues.
10
---
11
12
# GKE JobSet Interruption Troubleshooting
13
14
Use this skill to systematically diagnose and resolve JobSet interruptions,
15
restarts, and preemptions on GKE clusters hosting large-scale AI/ML workloads.
16
17
## Attribution
18
19
**MUST READ**: Before executing any `gcloud`, REST API, or MCP command, you
20
MUST read [Usage Attribution](references/attribution.md). For commands executed
21
directly in the terminal (never in generated scripts, Terraform, or user code),
22
prefix `gcloud` with
23
`CLOUDSDK_METRICS_REQUEST_ATTRIBUTION="agent-skills/1.0 (skill:gke-ai-troubleshooting-jobset-interruption)"`
24
and append `agent-skills/1.0 (skill:gke-ai-troubleshooting-jobset-interruption)` to `User-Agent` headers.
25
26
## ⚠️ Prerequisites & Sandbox Rules
27
28
- JobSet metrics package must be enabled in `kube-state-metrics` for your
29
cluster.
30
- Cloud Logging and Cloud Monitoring enabled for the Google Cloud Project.
31
- **Autonomous & Sandbox Execution Rule**: If API queries, tools, or commands
32
encounter `403 Permission Denied`, authentication errors, or network
33
isolation, **do NOT enter authentication or credential troubleshooting
34
loops**. Populate the query templates with the acquired variables
35
(`{project_id}`, `{cluster_name}`, `{workload_name}`, `{start_time}`,
36
`{end_time}`), inspect any locally staged telemetry or mock data files if
37
available, and complete the diagnostic workflow and resolution
38
recommendations autonomously.
39
40
## 🔍 Diagnostic Workflow
41
42
### Step 0: Context Acquisition & Time Window Definition
43
44
Independently gather context using tools, workspace files, environment details,
45
or user prompt context:
46
47
- **Project ID** (`{project_id}`)
48
- **Cluster Name** (`{cluster_name}`)
49
- **Workload Name (JobSet Name)** (`{workload_name}`)
50
- **Workload Namespace** (`{namespace}`)
51
- **Issue Time** (`{issue_time}`)
52
53
If specific variables are not explicitly provided by the user, inspect cluster
54
resources or logs to determine them, or use the `{variable}` placeholders
55
provided.
56
57
#### Time Handling Rules
58
59
1. **Autonomous Time Window**: If a relative time (e.g., "X minutes ago") or no
60
exact timestamp is provided, calculate the query window based on current
61
time or available log timestamps.
62
2. **Window Calculation**: If a timestamp `{issue_time}` is available (or
63
calculated as `T`), set `{start_time}` = `T - 30m` and `{end_time}` = `T +
64
30m`.
65
66
--------------------------------------------------------------------------------
67
68
### Step 1: Identify JobSet Restarts and Attempts [Low Risk]
69
70
Verify if the JobSet is experiencing restart loops and determine the frequency
71
of restarts.
72
73
#### Visual Chart / MQL Query - restarts
74
75
- **MQL Query Specification**:
76
77
```mql
78
fetch prometheus_target
79
| metric 'prometheus.googleapis.com/kube_jobset_restarts/gauge'
80
| filter resource.cluster_name == '{cluster_name}' && metric.jobset_name == '{workload_name}'
81
| align next_older(1m)
82
| every 1m
83
| group_by [metric.jobset_name], [val: max(value)]
84
```
85
86
#### PromQL Metric Query - restarts
87
88
- **PromQL Query Specification**:
89
90
```promql
91
kube_jobset_restarts{jobset_name="{workload_name}", cluster="{cluster_name}"}
92
```
93
94
- **Diagnostic Logic**: A non-zero or increasing value for restarts indicates
95
that the JobSet is being actively restarted by the controller due to worker
96
failure or interruption.
97
98
- **Automation**: Proceed to Step 2 automatically after reporting findings.
99
100
--------------------------------------------------------------------------------
101
102
### Step 2: Inspect Nodepool Interruptions [Low Risk]
103
104
Determine if the JobSet restarts were triggered by physical nodepool-level
105
events (such as spot preemptions, maintenance, or host terminations).
106
107
#### A. Metrics Query (Nodepool Interruption Counts)
108
109
##### Visual Chart / MQL Query - interruptions
110
111
- **MQL Query Specification**:
112
113
```mql
114
fetch k8s_node_pool
115
| metric 'kubernetes.io/node_pool/interruption_count'
116
| filter cluster_name == '{cluster_name}'
117
| align next_older(10m)
118
| every 10m
119
| group_by [metric.interruption_type, metric.interruption_reason, metadata.system.node_pool_name], [val: sum(value)]
120
```
121
122
##### PromQL Query - interruptions
123
124
- **PromQL Query Specification**:
125
126
```promql
127
sum by (interruption_type, interruption_reason, node_pool_name, cluster_name) (
128
avg_over_time(kubernetes_io:node_pool_interruption_count{cluster_name="{cluster_name}"}[10m])
129
)
130
```
131
132
#### B. Log Query (Nodepool Life Events)
133
134
- **LQL Log Filter Specification**:
135
136
```sql
137
resource.type="gke_nodepool"
138
AND resource.labels.cluster_name="{cluster_name}"
139
AND timestamp >= "{start_time}"
140
AND timestamp <= "{end_time}"
141
```
142
143
- **Diagnostic Logic**:
144
145
- **PreemptionEvent**: Spot VMs were preempted, or node was scale-down.
146
- **MaintenanceEvent**: Node pool updated or Google scheduled maintenance.
147
- **TerminationEvent**: Serious host failures. Check `interruption_reason`
148
or logs for host issues.
149
- See [Failure Signatures](references/failure_signatures.md) for examples
150
of node termination logs and preemption events.
151
152
- **Automation**: Proceed to Step 3 automatically.
153
154
--------------------------------------------------------------------------------
155
156
### Step 3: Inspect Nodes and Underlying Host VMs [Low Risk]
157
158
Correlate node readiness failures with physical host VMs to see if a single
159
faulty host repeatedly fails coordinator pods.
160
161
#### A. Metrics Query (Node Ready Status Check)
162
163
##### Visual Chart / MQL Query - node status
164
165
- **MQL Query Specification**:
166
167
```mql
168
fetch k8s_node
169
| metric 'kubernetes.io/node/status_condition'
170
| filter cluster_name == '{cluster_name}' && metric.condition == 'Ready' && metric.status == 'False'
171
| align next_older(1m)
172
| every 1m
173
| group_by [node_name, metadata.user.gke_nodepool], [val: max(value)]
174
```
175
176
##### PromQL Query - node status
177
178
- **PromQL Query Specification**:
179
180
```promql
181
sum by (status, condition, node_pool_name) (
182
kubernetes_io:node_status_condition{cluster_name="{cluster_name}", condition="Ready", status="False"}
183
)
184
```
185
186
#### B. Metrics Query (Node-to-Host Metadata Topology Correlation)
187
188
- **MQL Query Specification**:
189
190
```mql
191
fetch k8s_node
192
| metric 'kubernetes.io/node/cpu/total_cores'
193
| filter cluster_name == '{cluster_name}'
194
| align next_older(1m)
195
| every 1m
196
| group_by [node_name, metadata.user.gce_topology_host, metadata.user.gke_nodepool], [val: max(value)]
197
```
198
199
#### C. Log Query (Node Fault Logs)
200
201
- **LQL Log Filter Specification**:
202
203
```sql
204
resource.type="k8s_node"
205
AND resource.labels.cluster_name="{cluster_name}"
206
AND (textPayload:"host error" OR textPayload:"kernel panic" OR textPayload:"hardware failure" OR textPayload:"NodeNotReady")
207
AND timestamp >= "{start_time}"
208
AND timestamp <= "{end_time}"
209
```
210
211
- **Diagnostic Logic**: Identify if specific nodes are unhealthy
212
(`Ready=False` or `Unknown`) and correlate them to their GCE physical host
213
ID via `metadata.user.gce_topology_host`. Check if the same host is
214
repeatedly failing.
215
216
- **Automation**: Proceed to Step 4 automatically.
217
218
--------------------------------------------------------------------------------
219
220
### Step 4: Inspect Pod and Worker / Container Failures [Low Risk]
221
222
Analyze pod status phases and retrieve coordinator worker logs to identify
223
application-level crashes or network deadlocks.
224
225
> **Required Execution Order**: You MUST analyze pod status phases (Section A)
226
> and unschedulable pod metrics (Section B) to assess overall workload health
227
> before inspecting specific worker container logs (Section C).
228
229
#### A. Metrics Query (Pod Lifecycle Phases)
230
231
##### Visual Chart / MQL Query - pod phase
232
233
- **MQL Query Specification**:
234
235
```mql
236
fetch k8s_pod
237
| metric 'kubernetes.io/pod/status/phase'
238
| filter cluster_name == '{cluster_name}' && pod_name ==~ '{workload_name}.*'
239
| align next_older(10m)
240
| every 10m
241
| group_by [metric.phase], [val: count()]
242
```
243
244
##### PromQL Query - pod phase
245
246
- **PromQL Query Specification**:
247
248
```promql
249
sum by (phase) (
250
avg_over_time(kube_pod_status_phase{cluster="{cluster_name}", pod=~"{workload_name}.*"}[10m])
251
)
252
```
253
254
#### B. Metrics Query (Unschedulable Pod Count)
255
256
- **MQL Query Specification**:
257
258
```mql
259
fetch k8s_pod
260
| metric 'kubernetes.io/pod/status/unschedulable'
261
| filter cluster_name == '{cluster_name}' && pod_name ==~ '{workload_name}.*'
262
| align next_older(10m)
263
| every 10m
264
| group_by [pod_name], [val: max(value)]
265
```
266
267
#### C. Log Query (Worker Container Logs)
268
269
- **LQL Log Filter Specification**:
270
271
```sql
272
resource.type="k8s_container"
273
AND resource.labels.cluster_name="{cluster_name}"
274
AND labels."k8s-pod/jobset_sigs_k8s_io/jobset-name"="{workload_name}"
275
AND timestamp >= "{start_time}"
276
AND timestamp <= "{end_time}"
277
```
278
279
- **Diagnostic Logic**:
280
281
1. Check the pod timeline to spot pending or unschedulable pods.
282
2. Use worker container logs to analyze worker 0 in slice 0 (coordinator)
283
for NCCL timeouts, collective communication issues, or MegaScale hangs.
284
285
- **Automation**: Proceed to Resolution.
286
287
--------------------------------------------------------------------------------
288
289
## 🛠️ Resolution Workflow
290
291
### Resolution 1: Preemption & Autoscaling Optimizations [Low Risk]
292
293
If Step 2 showed high preemption counts on Spot VMs:
294
295
- **Action**: Suggest switching critical long-running training workloads to
296
**GKE Reserved/On-Demand VMs** or utilizing **Compact Placement Policies**
297
to minimize defragmentation interruptions.
298
- **Justification**: Eliminates spot-market preemptions and reduces training
299
restarts.
300
301
### Resolution 2: Quarantine Faulty Host VMs [High Risk]
302
303
If Step 3 identified a specific host ID (`gce-topology-host`) that consistently
304
fails or triggers restarts across multiple attempts:
305
306
- **Action**: Recommend cordoning/draining the GKE node, deleting the
307
underlying GCE VM instance to trigger instance recreation, and opening a
308
support ticket with Google Cloud Support specifying the physical host ID.
309
- **Justification**: GKE auto-repair will recreate the VM instance on healthy
310
physical hardware, preventing infinite restart loops.
311
312
--------------------------------------------------------------------------------
313
314
## 📋 Copypaste Checklist
315
316
- [ ] Gather context and compute `{start_time}` (`{issue_time} - 30m`) and
317
`{end_time}` (`{issue_time} + 30m`) window.
318
- [ ] Query JobSet restart attempts.
319
- [ ] Check Nodepool interruptions (spot preemptions vs. hardware
320
terminations).
321
- [ ] Query node-to-host mapping and check node logs for physical host errors.
322
- [ ] Inspect pod timeline status and coordinator worker container logs.
323
- [ ] Recommend appropriate scheduling strategy (On-demand vs Spot) or host VM
324
quarantining.
325