{"record":{"id":"1296384f2ac4279e","repo":"kubernetes/kops","slug":"could-not-determine-any-subnets-for-spotinstancegr","errorCode":null,"errorMessage":"could not determine any subnets for SpotInstanceGroup %q; subnets was %s","messagePattern":"could not determine any subnets for SpotInstanceGroup %q; subnets was (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/model/awsmodel/spotinst.go","lineNumber":716,"sourceCode":"\t\t\tLifecycle: b.SecurityLifecycle,\n\t\t\tID:        new(id),\n\t\t\tName:      new(id),\n\t\t\tShared:    new(true),\n\t\t}\n\t\tc.EnsureTask(sg)\n\t\tsecurityGroups = append(securityGroups, sg)\n\t}\n\n\treturn securityGroups, nil\n}\n\nfunc (b *SpotInstanceGroupModelBuilder) buildSubnets(ig *kops.InstanceGroup) ([]*awstasks.Subnet, error) {\n\tsubnets, err := b.GatherSubnets(ig)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif len(subnets) == 0 {\n\t\treturn nil, fmt.Errorf(\"could not determine any subnets for SpotInstanceGroup %q; subnets was %s\", ig.ObjectMeta.Name, ig.Spec.Subnets)\n\t}\n\n\tout := make([]*awstasks.Subnet, len(subnets))\n\tfor i, subnet := range subnets {\n\t\tout[i] = b.LinkToSubnet(subnet)\n\t}\n\n\treturn out, nil\n}\n\nfunc (b *SpotInstanceGroupModelBuilder) buildPublicIPOpts(ig *kops.InstanceGroup) (*bool, error) {\n\tsubnetMap := make(map[string]*kops.ClusterSubnetSpec)\n\tfor i := range b.Cluster.Spec.Networking.Subnets {\n\t\tsubnet := &b.Cluster.Spec.Networking.Subnets[i]\n\t\tsubnetMap[subnet.Name] = subnet\n\t}\n\n\tvar subnetType kops.SubnetType","sourceCodeStart":698,"sourceCodeEnd":734,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/model/awsmodel/spotinst.go#L698-L734","documentation":"Raised by buildSubnets when GatherSubnets returns zero subnets for a SpotInstanceGroup: kops cannot map the instance group to any cluster subnet, so no launch spec can be built. The message includes the IG name and its configured subnets string for diagnosis.","triggerScenarios":"kops create/update where a Spotinst instance group has an empty spec.subnets, or names that match no subnet in the cluster spec (GatherSubnets filters out unknown names).","commonSituations":"Copy-pasting an instance group between clusters with different subnet names, deleting subnets from the cluster spec but leaving them on the IG, or leaving spec.subnets empty.","solutions":["List spec.subnets names on the IG and match them exactly against the cluster spec subnets","Add at least one valid subnet name to spec.subnets","Run kops get cluster to confirm the cluster's subnet names","Re-run kops update --yes"],"exampleFix":"// before\nspec:\n  subnets: [old-name]\n// after\nspec:\n  subnets: [private-a]","handlingStrategy":"validation","validationCode":"if len(ig.Spec.Subnets) == 0 {\n  return fmt.Errorf(\"IG %s must list at least one cluster subnet\", ig.ObjectMeta.Name)\n}\nvalid := map[string]bool{}\nfor _, s := range cluster.Spec.Subnets { valid[s.Name] = true }\nfor _, n := range ig.Spec.Subnets {\n  if !valid[n] { return fmt.Errorf(\"IG %s: subnet %q not found in cluster\", ig.ObjectMeta.Name, n) }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never ship instance groups with an empty subnets list","Re-validate IGs after renaming cluster subnets","Keep IG subnet names generated from the same source as the cluster spec"],"tags":["aws","spotinst","subnets","network"],"backgroundTag":"no-subnets-resolved","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T07:17:12.445Z"}