{"record":{"id":"2b7f42d4d42da138","repo":"kubernetes/kops","slug":"unexpected-desired-subnets-for-s-expected-1","errorCode":null,"errorMessage":"Unexpected desired subnets for `%s`.  Expected 1, got %d","messagePattern":"Unexpected desired subnets for `(.+?)`\\.  Expected 1, got (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/openstacktasks/lb.go","lineNumber":205,"sourceCode":"\t\tif changes.Name != nil {\n\t\t\treturn fi.CannotChangeField(\"Name\")\n\t\t}\n\t}\n\treturn nil\n}\n\nfunc (_ *LB) RenderOpenstack(t *openstack.OpenstackAPITarget, a, e, changes *LB) error {\n\tif a == nil {\n\t\tklog.V(2).Infof(\"Creating LB with Name: %q\", fi.ValueOf(e.Name))\n\n\t\tsubnets, err := t.Cloud.ListSubnets(subnets.ListOpts{\n\t\t\tName: fi.ValueOf(e.Subnet),\n\t\t})\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"Failed to retrieve subnet `%s` in loadbalancer creation: %v\", fi.ValueOf(e.Subnet), err)\n\t\t}\n\t\tif len(subnets) != 1 {\n\t\t\treturn fmt.Errorf(\"Unexpected desired subnets for `%s`.  Expected 1, got %d\", fi.ValueOf(e.Subnet), len(subnets))\n\t\t}\n\n\t\tlbopts := loadbalancers.CreateOpts{\n\t\t\tName:        fi.ValueOf(e.Name),\n\t\t\tVipSubnetID: subnets[0].ID,\n\t\t}\n\t\tif e.FlavorID != nil {\n\t\t\tlbopts.FlavorID = fi.ValueOf(e.FlavorID)\n\t\t}\n\t\tlb, err := t.Cloud.CreateLB(lbopts)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"error creating LB: %v\", err)\n\t\t}\n\t\te.ID = new(lb.ID)\n\t\te.PortID = new(lb.VipPortID)\n\t\te.VipSubnet = new(lb.VipSubnetID)\n\t\te.Provider = new(lb.Provider)\n\t\te.FlavorID = new(lb.FlavorID)","sourceCodeStart":187,"sourceCodeEnd":223,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/openstacktasks/lb.go#L187-L223","documentation":"kOps looks up the OpenStack Neutron subnet by name (e.Subnet) when creating an Octavia load balancer and requires the name to resolve to exactly one subnet. This error is thrown when zero subnets or more than one subnet match that name, since kOps cannot pick a VIP subnet deterministically.","triggerScenarios":"`kops update cluster` on an OpenStack cluster where the subnet name in the cluster config does not match any subnet in the tenant (0 matches), or matches multiple subnets because the same name exists in several networks/projects or regions (2+ matches).","commonSituations":"Typo or case mismatch in the cluster spec's subnet name; subnet created in a different project than the credentials used; subnet renamed or deleted after cluster creation; multiple networks created by automation with duplicate subnet names.","solutions":["Run `openstack subnet list --name <name>` with the same credentials/project kOps uses and confirm exactly one row matches","Correct the subnet name in the kops cluster spec (or delete/rename duplicate subnets so the name is unique)","Verify the OS_* environment variables / cloud config point at the correct project; use subnet ID semantics or unique names"],"exampleFix":"// before (duplicate subnet names in two networks)\nopenstack subnet create --network net-a --subnet-range 10.0.0.0/24 nodes\nopenstack subnet create --network net-b --subnet-range 10.0.1.0/24 nodes\n// after: rename so the kops-configured name is unique\nopenstack subnet set net-b-nodes-subnet --name nodes-net-b\n// kops spec references unique name 'nodes' which now matches exactly one","handlingStrategy":"validation","validationCode":"// Before running kops update cluster\nsubnets=$(openstack subnet list --name nodes-subnet -f value -c ID)\ncount=$(echo \"$subnets\" | grep -c . || true)\n[ \"$count\" -eq 1 ] || { echo \"expected exactly 1 subnet named nodes-subnet, got $count\"; exit 1; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use globally unique subnet names in your OpenStack project before wiring them into the kops cluster spec","Verify with `openstack subnet list` that the name matches exactly one subnet under the same OS_* credentials kOps uses","Prefer referencing subnets via a single network with deterministic naming in Heat/Terraform"],"tags":["openstack","loadbalancer","subnet","configuration"],"backgroundTag":"ambiguous-resource-name","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}