kubernetes/kops · error

unsupported resource type %q for %q

Error message

unsupported resource type %q for %q

What it means

getVMTags only supports two Azure resource types: standalone virtualMachines and virtualMachineScaleSets/virtualMachines. If the parsed providerID points at any other ARM resource type (disks, NICs, availability sets, AKS-managed resources, etc.), this error names the unsupported type and the offending providerID.

Source

Thrown at pkg/nodeidentity/azure/client.go:94

	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)

Solutions

  1. Print/verify res.ResourceType.String() for the offending providerID and correct the node's providerID to point at the actual VM resource
  2. Check providerID casing — Azure ARM type names are case-sensitive here; normalize to 'Microsoft.Compute/...' form
  3. Upgrade kops if a newer Azure CCM emits a resource type not yet handled in this switch
  4. Extend the switch in client.go:94 to handle the new resource type if you maintain a fork

Example fix

// before
switch res.ResourceType.String() {
case "Microsoft.Compute/virtualMachines":
    ...

// after (tolerate case variations)
switch strings.ToLower(res.ResourceType.String()) {
case "microsoft.compute/virtualmachines":
    ...
Defensive patterns

Strategy: type-guard

Validate before calling

res, err := arm.ParseResourceID(strings.TrimPrefix(providerID, "azure://"))
if err != nil {
    return err
}
t := res.ResourceType.String()
if t != "Microsoft.Compute/virtualMachines" && t != "Microsoft.Compute/virtualMachineScaleSets/virtualMachines" {
    return fmt.Errorf("unsupported resource type %q", t)
}

Type guard

func isSupportedVMResourceType(res *arm.ResourceID) bool {
    t := strings.ToLower(res.ResourceType.String())
    return t == "microsoft.compute/virtualmachines" || t == "microsoft.compute/virtualmachinescalesets/virtualmachines"
}

Try / catch

tags, err := getVMTags(ctx, pid)
if err != nil && strings.Contains(err.Error(), "unsupported resource type") {
    // providerID points at a non-VM resource; fix the node's providerID
}

Prevention

When it happens

Trigger: arm.ParseResourceID succeeds but res.ResourceType.String() is neither 'Microsoft.Compute/virtualMachines' nor 'Microsoft.Compute/virtualMachineScaleSets/virtualMachines' — the providerID points at a non-VM resource, or uses an unexpected casing/casing-normalized type string.

Common situations: ProviderID manually set to a NIC or disk ID; newer azure SDK versions changing ResourceType string formatting (casing like 'microsoft.compute/virtualmachines'); third-party controllers writing custom azure:// IDs; future Azure resource kinds not yet handled by kops.

Related errors


AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05). Data as JSON: /api/errors/d1d79f912be3ae59. Report an issue: GitHub.