Installation

Install as Agent Plugin Recommended
copilot plugin marketplace add samueltauil/skills-hub
copilot plugin install gke-ai-troubleshooting-tpu-vbar-oom@skills-hub

Works with GitHub Copilot CLI and VS Code (enable chat.plugins.enabled). Plugin gke-ai-troubleshooting-tpu-vbar-oom v1.0.0 follows the Agent Plugins spec.

Install with the gh extension
gh skills-hub install gke-ai-troubleshooting-tpu-vbar-oom

Don't have the extension? Run gh extension install samueltauil/skills-hub first.

Download and extract to your repository:

.github/skills/gke-ai-troubleshooting-tpu-vbar-oom/

Extract the ZIP to .github/skills/ in your repo. The folder name must match gke-ai-troubleshooting-tpu-vbar-oom for Copilot to auto-discover it.

Skill Files (4)

SKILL.md 6.7 KB
---
name: gke-ai-troubleshooting-tpu-vbar-oom
description: >-
  Diagnoses and prevents vbar_control_agent segfaults, out-of-memory (OOM) errors,
  and TPU device initialization failures on TPU v6e nodes in GKE caused by race
  conditions during TPU device resets or high-frequency metrics polling. Use when
  troubleshooting vbar_control_agent crashes, memory cgroup OOMs in serial console
  logs, tpu-device-plugin metrics checksum corruption errors, or custom TPU metrics
  collection conflicts on GKE TPU v6e nodes. Don't use for general non-TPU container
  OOM troubleshooting or standard GKE node lifecycle operations.
metadata:
  version: "1.0.1"
  category: CloudObservabilityAndMonitoring
---

# TPU Connection Failure and VBAR OOM Troubleshooting

Use this skill to systematically diagnose and prevent `vbar_control_agent`
segfaults and Out-Of-Memory (OOM) errors on TPU v6e nodes.

## Attribution

**MUST READ**: Before executing any `gcloud`, REST API, or MCP command, you
MUST read [Usage Attribution](references/attribution.md). For commands executed
directly in the terminal (never in generated scripts, Terraform, or user code),
prefix `gcloud` with
`CLOUDSDK_METRICS_REQUEST_ATTRIBUTION="agent-skills/1.0 (skill:gke-ai-troubleshooting-tpu-vbar-oom)"`
and append `agent-skills/1.0 (skill:gke-ai-troubleshooting-tpu-vbar-oom)` to `User-Agent` headers.

## ⚠️ Prerequisites

-   Cloud Logging must be enabled for the project.
-   Access to the project and cluster via `gcloud` or equivalent tool.

## 🔍 Diagnostic Workflow

### Step 0: Context Acquisition & Time Window Definition

Independently gather required context using available GCP/GKE tools or use the
provided `{variable}` placeholders:

-   `{project_id}`: The GCP Project ID (e.g., `customer-ai-project-123`).
-   `{cluster_name}`: The GKE Cluster Name (e.g., `tpu-cluster-prod`).
-   `{node_name}`: The Node Name or Instance ID (e.g., `tpu-node-1`).
-   `{workload_name}`: The Workload Name / JobSet Name (e.g.,
    `my-training-job-456`).
-   `{namespace}`: The Workload Namespace.
-   `{issue_time}`: The timestamp of the issue (e.g., `2026-04-14T20:00:00Z`).

#### Time Handling & Execution Rules

1.  **Window Calculation**: If an issue timestamp `{issue_time}` is provided,
    calculate the query time window as `[{issue_time} - 30m]` to
    `[{issue_time} + 30m]`.
    -   Let `{start_time}` = `{issue_time} - 30m`
    -   Let `{end_time}` = `{issue_time} + 30m`
2.  **Informational vs. Live Execution**: If the user request is informational
    or query-formulation (e.g. "How can I check...", "How do I determine..."),
    or if live GCP project resources are not actively targetable, directly
    output the calculated time window, log names, and Cloud Logging filter
    templates without attempting live log execution commands.

### Step 1: Check for `vbar_control_agent` OOMs

Look for specific `out of memory` messages from `vbar_control_agent` in serial
console logs (`serialconsole.googleapis.com%2fserial_port_1_output`).

-   **Tool to use**: `query_logs` (for live diagnostics)
-   **Filter Templates**:

**Serial Console Logs (OOMs):**

```sql
logName="projects/{project_id}/logs/serialconsole.googleapis.com%2fserial_port_1_output"
AND labels."compute.googleapis.com/resource_name"="{node_name}"
AND SEARCH(text_payload, "Memory cgroup out of memory: Killed process .* (vbar_control_ag)")
AND timestamp >= "{start_time}"
AND timestamp <= "{end_time}"
```

-   **Logic**: Presence of `Memory cgroup out of memory` messages related to
    `vbar_control_agent`. Stack traces pointing to
    `libtpu::tpunetd::VBARControlHelper::MetricsReadFromVBAR` are a strong
    indicator.
-   **Automation**: Proceed to next step automatically after reporting findings.
-   **Reference**: See `references/failure_signatures.md` for example log
    patterns.

### Step 2: Investigate `tpu-device-plugin` Metrics Fetch Failures [Low Risk]

Check if `tpu-device-plugin` is reporting metric fetch failures.

-   **Tool to use**: `query_logs`
-   **Filter Template**:

```sql
resource.type="k8s_container"
AND resource.labels.project_id="{project_id}"
AND resource.labels.cluster_name="{cluster_name}"
AND resource.labels.container_name="tpu-device-plugin"
AND severity=ERROR
AND textPayload:"metrics fetch failed for .* deviceID and .* device path with error: checksum didn't match with the metrics data. Corrupt data found"
AND timestamp >= "{start_time}"
AND timestamp <= "{end_time}"
```

-   **Logic**: Errors indicating "metrics fetch failed" with "checksum didn't
    match" suggest vBAR memory corruption.
-   **Automation**: Proceed to next step automatically after reporting findings.

### Step 3: Check for Custom Metrics Collection Usage [Low Risk]

Inspect cluster configurations, workloads, or container specs to determine if
custom TPU metrics collection mechanisms are deployed.

-   **Action**: Check if custom scripts or agents (e.g., using
    `libtpu.sdk.tpumonitoring`) are deployed that frequently query
    `GetHostMetrics` from `vBAR Control Agent`.
-   **Verification Commands**:

    -   **Kubectl Search (Inspect workload env/specs)**:

    ```bash
    kubectl get pods -A -o jsonpath='{range .items[*]}{.metadata.namespace}{"/"}{.metadata.name}{"\t"}{.spec.containers[*].image}{"\n"}{end}'
    ```

    -   **Log Search Filter (`query_logs`)**:

    ```sql
    resource.type="k8s_container"
    AND resource.labels.project_id="{project_id}"
    AND resource.labels.cluster_name="{cluster_name}"
    AND textPayload:"libtpu.sdk.tpumonitoring"
    AND timestamp >= "{start_time}"
    AND timestamp <= "{end_time}"
    ```

-   **Logic**: Confirmation of custom metrics collection helps confirm the race
    condition hypothesis.

## 🛠️ Resolution Workflow

### Resolution 1: Temporarily Disable Custom Metrics Collection [High Risk]

If a custom metrics collection agent is identified, recommend disabling it.

-   **Action**: Recommend disabling the custom metrics collector.
-   **Justification**: Prevents reads from vBAR during device resets, stopping
    crashes and OOMs.

### Resolution 2: Await `vbar_control_agent` Resiliency Update [Low Risk]

Advise that a permanent fix will be available in a future GKE version.

-   **Action**: Recommend upgrading GKE when the fix is available.
-   **Justification**: The updated agent will be resilient to memory corruption
    and gracefully handle reads from unbound vBARs.

## 📋 copypaste checklist

-   [ ] Acquire context and compute `[{start_time}, {end_time}]` window.
-   [ ] Check for `vbar_control_agent` segfaults and OOMs using `query_logs`.
-   [ ] Investigate `tpu-device-plugin` failures using `query_logs`.
-   [ ] Inspect for custom metrics collection usage.
-   [ ] Advise disabling custom metrics collection if applicable.
-   [ ] Advise awaiting resiliency update.
references/
attribution.md 1.9 KB
# Usage Attribution

**MUST READ**: Before executing any `gcloud`, REST API, or MCP command with
this skill, follow these usage attribution instructions. Tag every command you
execute directly in the terminal so usage can be attributed. The tag identifies
only the skill and its version; it carries no user data.

-   **`gcloud` CLI Commands**: Prefix every `gcloud` invocation, whatever the
    subcommand, with the metrics environment variable. Set it inline on each
    command because shell state may not persist between commands:

    ```bash
    CLOUDSDK_METRICS_REQUEST_ATTRIBUTION="agent-skills/1.0 (skill:gke-ai-troubleshooting-tpu-vbar-oom)" \
    gcloud <command> [flags]
    ```

    Do not use `gcloud config set` for this: it would persist beyond the current
    task and mislabel unrelated usage.

-   **Direct HTTP, REST, and MCP Requests**: On direct HTTP calls to Google
    Cloud APIs (for example with `curl`) or HTTP requests to a remote MCP
    server, include `agent-skills/1.0 (skill:gke-ai-troubleshooting-tpu-vbar-oom)` in the `User-Agent`
    header. If a `User-Agent` header is already specified, append this string to
    the end of it rather than overwriting existing `User-Agent` data — the
    collection pipeline parses the `agent-skills/<version>` and `skill:<name>`
    tokens, so any rewording breaks attribution:

    ```
    User-Agent: <existing_user_agent> agent-skills/1.0 (skill:gke-ai-troubleshooting-tpu-vbar-oom)
    ```

-   **Constraint for Generated Code**: The tracking prefix is strictly for
    commands you execute directly in the terminal. Do NOT include this tracking
    prefix in generated scripts, Terraform templates, or code provided to the
    user for their own repositories.

-   **User Opt-Out**: If the user asks to disable or remove tracking or
    attribution tags, omit the `CLOUDSDK_METRICS_REQUEST_ATTRIBUTION` variable
    and custom `User-Agent` suffix from all commands.
failure_signatures.md 1.4 KB
# TPU vBAR Failure Signatures

This document provides anonymized examples of logs and signals associated with
the `vbar_control_agent` race condition and OOMs on TPU v6e nodes.

## 1. Serial Console: `vbar_control_agent` OOM/Segfault

When the agent crashes, the serial console often contains process death messages
followed by a stack trace.

**Example Log:**

```text
[ 1234.567890] Memory cgroup out of memory: Killed process 5678 (vbar_control_ag) total-vm:4194304kB, anon-rss:2097152kB, file-rss:0kB, shmem-rss:0kB, UID:0 pgtables:8192kB oom_score_adj:0
```

## 2. Container Logs: Deserialize Failures

The `tpu-device-plugin` will report errors when it receives corrupt data from
the control agent.

**Example Log (LQL Filter Match):**

```sql
resource.type="k8s_container"
resource.labels.container_name="tpu-device-plugin"
severity=ERROR

"metrics fetch failed for 3 deviceID and /sys/bus/pci/devices/0000:00:08.0 device path with error: checksum didn't match with the metrics data. Corrupt data found"
```

## 3. High-Frequency Polling (Custom Scripts)

If the user is running `tpumonitoring` in a loop, you may see frequent
successful calls followed by a sudden gap and the crash.

**Observation Pattern:**

-   Successful `GetHostMetrics` calls (e.g. every 3s).
-   Device reset event (Node reboot or maintenance).
-   `vbar_control_agent` crash during next polling cycle.
scripts/
validate_queries.sh 1.0 KB
#!/bin/bash
# Validate Cloud Logging LQL queries used in SKILL.md

set -e

PROJECT_ID="${PROJECT_ID:-$(gcloud config get-value project 2>/dev/null)}"
if [[ -z "${PROJECT_ID}" ]]; then
  echo "Error: PROJECT_ID is not set and could not be determined from gcloud." >&2
  exit 1
fi
echo "Using project: ${PROJECT_ID}"

# Step 1: vbar_control_agent OOMs
FILTER_1="logName=\"projects/${PROJECT_ID}/logs/serialconsole.googleapis.com%2fserial_port_1_output\" AND SEARCH(\"Memory cgroup out of memory: Killed process\")"
echo "Validating Step 1 filter..."
gcloud logging read "${FILTER_1}" --limit=1 > /dev/null

# Step 2: tpu-device-plugin metrics fetch failures
FILTER_2="resource.type=\"k8s_container\" AND resource.labels.container_name=\"tpu-device-plugin\" AND severity=ERROR AND \"checksum didn't match with the metrics data\""
echo "Validating Step 2 filter..."
gcloud logging read "${FILTER_2}" --limit=1 > /dev/null

echo "✅ All LQL filters validated against Cloud Logging API (dry-run)."

License (Apache-2.0)

View full license text
Licensed under the Apache License, Version 2.0. See https://github.com/google/skills/blob/main/LICENSE