kubernetes/kops · error

unexpected form of resource path: %q

Error message

unexpected form of resource path: %q

What it means

toAzureVMName parses an Azure providerID of the form /subscriptions/<sub>/resourceGroups/<rg>/providers/Microsoft.Compute/virtualMachineScaleSets/<vmss>/virtualMachines/<idx> and expects exactly 13 slash-separated segments. If the providerID does not match the VMSS resource path shape, it returns this error with the offending value.

Source

Thrown at pkg/cloudinstances/cloud_instance_group.go:130

		}
		return nodeMap
	}

	for i := range nodes {
		node := &nodes[i]
		providerIDs := strings.Split(node.Spec.ProviderID, "/")
		instanceID := providerIDs[len(providerIDs)-1]
		nodeMap[instanceID] = node
	}

	return nodeMap
}

// toAzureVMName returns a VM name from the resource path stored in the provider ID.
func toAzureVMName(providerID string) (string, error) {
	l := strings.Split(providerID, "/")
	if len(l) != 13 {
		return "", fmt.Errorf("unexpected form of resource path: %q", providerID)
	}
	vmssName := l[10]
	idx := l[12]
	return fmt.Sprintf("%s_%s", vmssName, idx), nil
}

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Skip nodes whose providerID does not start with the Azure VMSS prefix instead of mapping them.
  2. Verify the node's spec.providerID on the cluster and re-register misconfigured nodes.
  3. Handle both VMSS and standalone-VM Azure providerID shapes before calling toAzureVMName.

Example fix

// before
name, err := toAzureVMName(node.Spec.ProviderID)
// after
if !strings.HasPrefix(node.Spec.ProviderID, "/subscriptions/") || !strings.Contains(node.Spec.ProviderID, "virtualMachineScaleSets/") {
  continue // not an Azure VMSS instance
}
name, err := toAzureVMName(node.Spec.ProviderID)
Defensive patterns

Strategy: validation

Validate before calling

func isAzureVMSSProviderID(id string) bool {
  return strings.HasPrefix(id, "/subscriptions/") && strings.Contains(id, "virtualMachineScaleSets/") && len(strings.Split(id, "/")) == 13
}

Type guard

func isAzureVMSSNode(n *v1.Node) bool {
  return n != nil && isAzureVMSSProviderID(n.Spec.ProviderID)
}

Try / catch

name, err := toAzureVMName(node.Spec.ProviderID)
if err != nil {
  klog.V(2).Infof("not an Azure VMSS node (%v); skipping", err)
  continue
}

Prevention

When it happens

Trigger: Calling GetNodeMap or the anonymous node-mapping helper with a node whose providerID is not a 13-segment Azure VMSS path — e.g. a standalone VM providerID, a providerID from another cloud (aws://, gce://), or an empty/malformed spec.providerID.

Common situations: Hybrid clusters with nodes from other providers registered in the cluster; nodes created outside VMSS (availability-set VMs); nil/unset providerID on a NotReady node; kops upgraded clusters where node registration produced a different ID format.

Related errors


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