kubernetes/kops · error

error parsing providerID: %v

Error message

error parsing providerID: %v

What it means

After confirming the 'azure://' prefix, getVMTags strips it and parses the remainder as an Azure Resource Manager resource ID using arm.ParseResourceID. If the string is not a valid fully-qualified ARM ID, the parse error is wrapped with 'error parsing providerID'.

Source

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

	vmssClient, err := compute.NewVirtualMachineScaleSetVMsClient(metadata.SubscriptionID, cred, nil)
	if err != nil {
		return nil, fmt.Errorf("creating VMSS VMs client: %w", err)
	}

	return &client{
		vmClient:   vmClient,
		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)

Solutions

  1. Set the providerID to the full ARM URI: azure:///subscriptions/<sub-id>/resourceGroups/<rg>/providers/Microsoft.Compute/virtualMachines/<vm-name>
  2. Check for legacy short providerID formats (e.g. azure://<vm-name>) and re-register/replace the node so CCM writes the canonical form
  3. Validate the ID with arm.ParseResourceID locally to see the exact parse failure
  4. Confirm matching kubernetes and cloud-provider-azure versions so providerID format expectations align

Example fix

// before
providerID = "azure://k8s-agent-1"  // bare name, not parseable

// after
providerID = "azure:///subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg/providers/Microsoft.Compute/virtualMachines/k8s-agent-1"
Defensive patterns

Strategy: validation

Validate before calling

rest := strings.TrimPrefix(providerID, "azure://")
if !strings.Contains(rest, "/subscriptions/") {
    return fmt.Errorf("providerID %q is not a full ARM resource ID", providerID)
}
if _, err := arm.ParseResourceID(rest); err != nil {
    return fmt.Errorf("malformed providerID %q: %w", providerID, err)
}

Type guard

func isParseableARMID(pid string) bool {
    _, err := arm.ParseResourceID(strings.TrimPrefix(pid, "azure://"))
    return err == nil
}

Try / catch

tags, err := getVMTags(ctx, pid)
if err != nil && strings.HasPrefix(err.Error(), "error parsing providerID") {
    // fall back to matching node by name or skip this node
}

Prevention

When it happens

Trigger: The providerID is 'azure://' + a string that fails ARM ID parsing — e.g. 'azure://vmname' (bare hostname), missing segments like subscriptions/resourceGroups, or URL-encoded/truncated IDs.

Common situations: Older kops/Azure CCM formats that stored short VM names instead of full ARM URIs; manually edited node providerIDs; kubernetes/azure cloud provider versions emitting 'azure:///...' variants with missing segments; copy-paste truncation of the providerID.

Related errors


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