kubernetes/kops · error

failed to parse subnet ID %s

Error message

failed to parse subnet ID %s

What it means

After Find confirms the IP config has a subnet ID, it parses the ARM resource ID string with azure.ParseSubnetID to extract the resource group, virtual network name, and subnet name. This error is returned when the ID string does not match the expected /subscriptions/{sub}/resourceGroups/{rg}/providers/Microsoft.Network/virtualNetworks/{vnet}/subnets/{subnet} shape.

Source

Thrown at upup/pkg/fi/cloudup/azuretasks/vmscaleset.go:151

		return nil, fmt.Errorf("found VMSS without network interface config properties")
	}
	ipConfigs := nwConfig.Properties.IPConfigurations
	if len(ipConfigs) != 1 {
		return nil, fmt.Errorf("expecting exactly 1 network interface IP config for %q, found %d: %+v", *s.Name, len(ipConfigs), ipConfigs)
	}
	ipConfig := ipConfigs[0]
	if ipConfig.Properties == nil {
		return nil, fmt.Errorf("found VMSS without IP config properties")
	}
	if ipConfig.Properties.Subnet == nil {
		return nil, fmt.Errorf("found VMSS without IP config subnet")
	}
	if ipConfig.Properties.Subnet.ID == nil {
		return nil, fmt.Errorf("found VMSS without IP config subnet ID")
	}
	subnetID, err := azure.ParseSubnetID(*ipConfig.Properties.Subnet.ID)
	if err != nil {
		return nil, fmt.Errorf("failed to parse subnet ID %s", *ipConfig.Properties.Subnet.ID)
	}

	var loadBalancerID *azure.LoadBalancerID
	if ipConfig.Properties.LoadBalancerBackendAddressPools != nil {
		for _, i := range ipConfig.Properties.LoadBalancerBackendAddressPools {
			if !strings.Contains(*i.ID, "api") {
				continue
			}
			loadBalancerID, err = azure.ParseLoadBalancerID(*i.ID)
			if err != nil {
				return nil, fmt.Errorf("failed to parse loadbalancer ID %s", *i.ID)
			}
		}
	}

	osProfile := profile.OSProfile
	if osProfile.LinuxConfiguration == nil {
		return nil, fmt.Errorf("found VMSS without Linux config")

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Run `az vmss show -g <rg> -n <vmss> --query "virtualMachineProfile.networkProfile.networkInterfaceConfigurations[0].ipConfigurations[0].subnet.id"` and compare against the expected ARM format.
  2. Fix the scale set's subnet reference so it is a full, canonical ARM subnet ID (e.g. via `az network nic ip-config update` equivalent or recreating through kops).
  3. If parsing is too strict for a legitimate ID form, extend azure.ParseSubnetID to accept that form, then add a unit test.
  4. Confirm all clusters are managed by a single kops version; upgrade kops and run `kops update cluster --yes` to reconcile out-of-band changes.

Example fix

// before
"subnets/my-subnet"
// after
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/my-rg/providers/Microsoft.Network/virtualNetworks/my-vnet/subnets/my-subnet"
Defensive patterns

Strategy: validation

Validate before calling

re := regexp.MustCompile(`^/subscriptions/[^/]+/resourceGroups/[^/]+/providers/Microsoft\.Network/virtualNetworks/[^/]+/subnets/[^/]+$`)
if !re.MatchString(subnetID) { return fmt.Errorf("malformed subnet ID: %s", subnetID) }

Try / catch

subnetID, err := azure.ParseSubnetID(id)
if err != nil {
  return fmt.Errorf("kops: unusable subnet ID %q on VMSS: %w", id, err)
}

Prevention

When it happens

Trigger: Find() encounters a VMSS IP configuration whose subnet.ID is non-nil but is not a well-formed Azure subnet resource ID (wrong provider path, missing segments, or a truncated/relative ID).

Common situations: Scale sets built by other tooling or templates that reference subnets with non-standard IDs; manual edits in the Azure portal or via ARM templates; casing/path changes across Azure API profile versions.

Understand the failure class

Related errors


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