kubernetes/kops · error
getting VM
Error message
getting VM: %w
What it means
When the parsed providerID identifies a standalone virtual machine (Microsoft.Compute/virtualMachines), getVMTags calls the VMs client Get API to fetch the VM (including its tags). If the Azure API call fails, the error is wrapped with 'getting VM'.
Solutions
- Check the wrapped error: if it is a 404, the VM no longer exists — delete the stale Node object (kubectl delete node <name>)
- Verify the credential has at least Reader role on the VM / its resource group
- Confirm the VM exists in the portal or with az vm show -g <rg> -n <vm-name>
- For 429/throttling or transient network errors, retry; check Azure status
Defensive patterns
Strategy: retry
Validate before calling
// verify the VM exists before the call az vm show -g <resource-group> -n <vm-name> -o none # exit 0 means it exists
Try / catch
resp, err := c.vmClient.Get(ctx, rg, name, nil)
if err != nil {
var respErr *azcore.ResponseError
if errors.As(err, &respErr) && respErr.StatusCode == 404 {
// VM deleted; clean up the Node object instead of retrying
} else if respErr != nil && (respErr.StatusCode == 429 || respErr.StatusCode >= 500) {
// transient: retry with backoff
}
return fmt.Errorf("getting VM: %w", err)
} Prevention
- Grant the managed identity at least Reader on the resource group
- Delete Node objects for deleted VMs promptly
- Handle azcore.ResponseError to distinguish 404 from transient failures
- Use retry/backoff for 429/5xx responses
When it happens
Trigger: c.vmClient.Get(ctx, resourceGroup, vmName, nil) returns an error — VM not found (ResourceNotFoundError), deleted VM whose Node object still exists, authz failure (no Reader role for the identity), or network/API errors.
Common situations: Node object orphaned after VM deletion or VMSS scale-in; managed identity lacking Reader on the VM's resource group; wrong subscription context (cluster moved between subscriptions); transient Azure API outages or throttling (429).
Related errors
- getting VMSS VM
- error on getting VM ScaleSet
- removing file
- attested document expired at
- attested vmId does not match (API vmId )
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/b3017dbd49c517bb.
Report an issue: GitHub.
Appendix: source
Thrown at pkg/nodeidentity/azure/client.go:84
vmssClient: vmssClient,
}, nil
}
func (c *client) getVMTags(ctx context.Context, providerID string) (map[string]*string, error) {
if !strings.HasPrefix(providerID, "azure://") {
return nil, fmt.Errorf("unknown providerID : %s", providerID)
}
res, err := arm.ParseResourceID(strings.TrimPrefix(providerID, "azure://"))
if err != nil {
return nil, fmt.Errorf("error parsing providerID: %v", err)
}
switch res.ResourceType.String() {
case "Microsoft.Compute/virtualMachines":
resp, err := c.vmClient.Get(ctx, res.ResourceGroupName, res.Name, nil)
if err != nil {
return nil, fmt.Errorf("getting VM: %w", err)
}
return resp.VirtualMachine.Tags, nil
case "Microsoft.Compute/virtualMachineScaleSets/virtualMachines":
resp, err := c.vmssClient.Get(ctx, res.ResourceGroupName, res.Parent.Name, res.Name, nil)
if err != nil {
return nil, fmt.Errorf("getting VMSS VM: %w", err)
}
return resp.VirtualMachineScaleSetVM.Tags, nil
default:
return nil, fmt.Errorf("unsupported resource type %q for %q", res.ResourceType, providerID)
}
}
View on GitHub (pinned to 4c8573c808)