|
| 1 | +# VirtualMachine Troubleshooting Guide |
| 2 | + |
| 3 | +## VM: {{.Name}} (namespace: {{.Namespace}}) |
| 4 | + |
| 5 | +Follow these steps to diagnose issues with the VirtualMachine: |
| 6 | + |
| 7 | +--- |
| 8 | + |
| 9 | +## Step 1: Check VirtualMachine Status |
| 10 | + |
| 11 | +Use the `resources_get` tool to inspect the VirtualMachine: |
| 12 | +- **apiVersion**: `kubevirt.io/v1` |
| 13 | +- **kind**: `VirtualMachine` |
| 14 | +- **namespace**: `{{.Namespace}}` |
| 15 | +- **name**: `{{.Name}}` |
| 16 | + |
| 17 | +**What to look for:** |
| 18 | +- `status.printableStatus` - Should be "Running" for a healthy VM |
| 19 | +- `status.ready` - Should be `true` |
| 20 | +- `status.conditions` - Look for conditions with `status: "False"` or error messages |
| 21 | +- `spec.runStrategy` - Check if it's "Always", "Manual", "Halted", or "RerunOnFailure" |
| 22 | + |
| 23 | +--- |
| 24 | + |
| 25 | +## Step 2: Check VirtualMachineInstance Status |
| 26 | + |
| 27 | +If the VM exists but isn't running, check if a VirtualMachineInstance was created: |
| 28 | + |
| 29 | +Use the `resources_get` tool: |
| 30 | +- **apiVersion**: `kubevirt.io/v1` |
| 31 | +- **kind**: `VirtualMachineInstance` |
| 32 | +- **namespace**: `{{.Namespace}}` |
| 33 | +- **name**: `{{.Name}}` |
| 34 | + |
| 35 | +**What to look for:** |
| 36 | +- `status.phase` - Should be "Running" for a healthy VMI |
| 37 | +- `status.conditions` - Check for "Ready" condition with `status: "True"` |
| 38 | +- `status.guestOSInfo` - Confirms guest agent is running |
| 39 | +- If VMI doesn't exist and VM runStrategy is "Always", this indicates a problem |
| 40 | + |
| 41 | +--- |
| 42 | + |
| 43 | +## Step 3: Check DataVolume Status (if applicable) |
| 44 | + |
| 45 | +If the VM uses DataVolumeTemplates, check their status: |
| 46 | + |
| 47 | +Use the `resources_list` tool: |
| 48 | +- **apiVersion**: `cdi.kubevirt.io/v1beta1` |
| 49 | +- **kind**: `DataVolume` |
| 50 | +- **namespace**: `{{.Namespace}}` |
| 51 | + |
| 52 | +Look for DataVolumes with names starting with `{{.Name}}-` |
| 53 | + |
| 54 | +**What to look for:** |
| 55 | +- `status.phase` - Should be "Succeeded" when ready |
| 56 | +- `status.progress` - Shows import/clone progress (e.g., "100.0%") |
| 57 | +- Common issues: |
| 58 | + - Phase "Pending" - Waiting for resources |
| 59 | + - Phase "ImportScheduled" or "ImportInProgress" - Still importing |
| 60 | + - Phase "Failed" - Check `status.conditions` for error details |
| 61 | + |
| 62 | +--- |
| 63 | + |
| 64 | +## Step 4: Check virt-launcher Pod |
| 65 | + |
| 66 | +The virt-launcher pod runs the actual VM. Find and inspect it: |
| 67 | + |
| 68 | +Use the `pods_list_in_namespace` tool: |
| 69 | +- **namespace**: `{{.Namespace}}` |
| 70 | +- **labelSelector**: `kubevirt.io=virt-launcher,vm.kubevirt.io/name={{.Name}}` |
| 71 | + |
| 72 | +**What to look for:** |
| 73 | +- Pod should be in "Running" phase |
| 74 | +- All containers should be ready (e.g., "2/2") |
| 75 | +- Check pod events and conditions for errors |
| 76 | + |
| 77 | +If pod exists, get detailed status with `pods_get`: |
| 78 | +- **namespace**: `{{.Namespace}}` |
| 79 | +- **name**: `virt-launcher-{{.Name}}-xxxxx` (use actual pod name from list) |
| 80 | + |
| 81 | +Get pod logs with `pods_log`: |
| 82 | +- **namespace**: `{{.Namespace}}` |
| 83 | +- **name**: `virt-launcher-{{.Name}}-xxxxx` |
| 84 | +- **container**: `compute` (main VM container) |
| 85 | + |
| 86 | +--- |
| 87 | + |
| 88 | +## Step 5: Check Events |
| 89 | + |
| 90 | +Events provide crucial diagnostic information: |
| 91 | + |
| 92 | +Use the `events_list` tool: |
| 93 | +- **namespace**: `{{.Namespace}}` |
| 94 | + |
| 95 | +Filter output for events related to `{{.Name}}` - look for warnings or errors. |
| 96 | + |
| 97 | +--- |
| 98 | + |
| 99 | +## Step 6: Check Instance Type and Preference (if used) |
| 100 | + |
| 101 | +If the VM uses instance types or preferences, verify they exist: |
| 102 | + |
| 103 | +For instance types, use `resources_get`: |
| 104 | +- **apiVersion**: `instancetype.kubevirt.io/v1beta1` |
| 105 | +- **kind**: `VirtualMachineClusterInstancetype` |
| 106 | +- **name**: (check VM spec for instancetype name) |
| 107 | + |
| 108 | +For preferences, use `resources_get`: |
| 109 | +- **apiVersion**: `instancetype.kubevirt.io/v1beta1` |
| 110 | +- **kind**: `VirtualMachineClusterPreference` |
| 111 | +- **name**: (check VM spec for preference name) |
| 112 | + |
| 113 | +--- |
| 114 | + |
| 115 | +## Common Issues and Solutions |
| 116 | + |
| 117 | +### VM stuck in "Stopped" or "Halted" |
| 118 | +- Check `spec.runStrategy` - if "Halted", the VM is intentionally stopped |
| 119 | +- Change runStrategy to "Always" to start the VM |
| 120 | + |
| 121 | +### VMI doesn't exist |
| 122 | +- Check VM conditions for admission errors |
| 123 | +- Verify instance type and preference exist |
| 124 | +- Check resource quotas in the namespace |
| 125 | + |
| 126 | +### DataVolume stuck in "ImportInProgress" |
| 127 | +- Check CDI controller pods in `cdi` namespace |
| 128 | +- Verify source image is accessible |
| 129 | +- Check PVC storage class exists and has available capacity |
| 130 | + |
| 131 | +### virt-launcher pod in CrashLoopBackOff |
| 132 | +- Check pod logs for container `compute` |
| 133 | +- Common causes: |
| 134 | + - Insufficient resources (CPU/memory) |
| 135 | + - Invalid VM configuration |
| 136 | + - Storage issues (PVC not available) |
| 137 | + |
| 138 | +### VM starts but guest doesn't boot |
| 139 | +- Check virt-launcher logs for QEMU errors |
| 140 | +- Verify boot disk is properly configured |
| 141 | +- Check if guest agent is installed (for cloud images) |
| 142 | +- Ensure correct architecture (amd64 vs arm64) |
| 143 | + |
| 144 | +--- |
| 145 | + |
| 146 | +## Additional Resources |
| 147 | + |
| 148 | +For more detailed diagnostics: |
| 149 | +- Check KubeVirt components: `pods_list` in `kubevirt` namespace |
| 150 | +- Check CDI components: `pods_list` in `cdi` namespace (if using DataVolumes) |
| 151 | +- Review resource consumption: `pods_top` for the virt-launcher pod |
0 commit comments