{"record":{"id":"d268916fa5945b71","repo":"kubernetes/kops","slug":"error-building-subnets-v","errorCode":null,"errorMessage":"error building subnets: %v","messagePattern":"error building subnets: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/model/awsmodel/spotinst.go","lineNumber":329,"sourceCode":"\t\treturn fmt.Errorf(\"error building load balancers: %v\", err)\n\t}\n\n\t// User data.\n\tgroup.UserData, err = b.BootstrapScriptBuilder.ResourceNodeUp(c, ig)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error building user data: %v\", err)\n\t}\n\n\t// Public IP.\n\tgroup.AssociatePublicIPAddress, err = b.buildPublicIPOpts(ig)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error building public ip options: %v\", err)\n\t}\n\n\t// Subnets.\n\tgroup.Subnets, err = b.buildSubnets(ig)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error building subnets: %v\", err)\n\t}\n\n\t// Capacity.\n\tgroup.MinSize, group.MaxSize = b.buildCapacity(ig)\n\n\t// Monitoring.\n\tgroup.Monitoring = ig.Spec.DetailedInstanceMonitoring\n\n\t// Tags.\n\tgroup.Tags, err = b.buildTags(ig)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error building cloud tags: %v\", err)\n\t}\n\n\t// Auto Scaler.\n\tgroup.AutoScalerOpts, err = b.buildAutoScalerOpts(b.ClusterName(), ig)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error building auto scaler options: %v\", err)","sourceCodeStart":311,"sourceCodeEnd":347,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/model/awsmodel/spotinst.go#L311-L347","documentation":"buildElastigroup calls b.buildSubnets(ig), which gathers the subnets for the instance group via b.GatherSubnets and errors if none are found. This wrapper fires when the group cannot be mapped to any subnet, aborting Elastigroup creation.","triggerScenarios":"`kops update cluster` with Spotinst where GatherSubnets returns an error (IG references unknown subnets / topology mismatch) or returns zero subnets — the inner message is 'could not determine any subnets for SpotInstanceGroup %q'.","commonSituations":"Instance group created without spec.subnets; subnet names misspelled; cluster migrated from public to private topology leaving stale IG subnet references; Spotinst-hybrid IGs copied from templates of another cluster.","solutions":["Read the inner error: it names the instance group and its spec.subnets.","Set spec.subnets on the instance group to names present in cluster.spec.subnets.","Verify cluster.spec.subnets and topology (public/private) are defined for every zone the IG spans.","Re-run `kops update cluster`."],"exampleFix":"// before\nmetadata:\n  name: nodes\nspec: {}\n// after\nspec:\n  subnets:\n  - us-east-1a\n  - us-east-1b","handlingStrategy":"validation","validationCode":"if len(ig.Spec.Subnets) == 0 {\n  return fmt.Errorf(\"instance group %s must define spec.subnets\", ig.Name)\n}","typeGuard":null,"tryCatchPattern":"if err := kopsUpdate(); err != nil {\n  if strings.Contains(err.Error(), \"error building subnets\") {\n    // set spec.subnets to valid cluster subnet names and retry\n  }\n}","preventionTips":["Never create instance groups without spec.subnets.","Validate subnet names against `kops get cluster -oyaml` before apply.","Keep IG subnet references in sync when changing cluster topology."],"tags":["aws","subnets","spotinst","networking"],"backgroundTag":"no-subnets-found","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"}