{"record":{"id":"564abcaa508fe9ae","repo":"kubernetes/kops","slug":"subnet-s-and-s-have-the-same-zone","errorCode":null,"errorMessage":"subnet %s and %s have the same zone","messagePattern":"subnet (.+?) and (.+?) have the same zone","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/new_cluster.go","lineNumber":928,"sourceCode":"\t}\n\tvpcInfo, err := awsCloud.FindVPCInfo(VPCID)\n\tif err != nil {\n\t\treturn res, fmt.Errorf(\"error describing VPC: %v\", err)\n\t}\n\tif vpcInfo == nil {\n\t\treturn res, fmt.Errorf(\"VPC %q not found\", VPCID)\n\t}\n\tsubnetByID := make(map[string]*fi.SubnetInfo)\n\tfor _, subnetInfo := range vpcInfo.Subnets {\n\t\tsubnetByID[subnetInfo.ID] = subnetInfo\n\t}\n\tfor _, subnetID := range subnetIDs {\n\t\tsubnet, ok := subnetByID[subnetID]\n\t\tif !ok {\n\t\t\treturn res, fmt.Errorf(\"subnet %s not found in VPC %s\", subnetID, VPCID)\n\t\t}\n\t\tif res[subnet.Zone] != \"\" {\n\t\t\treturn res, fmt.Errorf(\"subnet %s and %s have the same zone\", subnetID, res[subnet.Zone])\n\t\t}\n\t\tres[subnet.Zone] = subnetID\n\t}\n\treturn res, nil\n}\n\nfunc getOpenstackZoneToSubnetProviderID(cluster *api.Cluster, zones []string, subnetIDs []string) (map[string]string, error) {\n\tres := make(map[string]string)\n\tosCloud, err := openstack.NewOpenstackCloud(cluster, \"new-cluster-zone-to-subnet\")\n\tif err != nil {\n\t\treturn res, fmt.Errorf(\"error loading cloud: %v\", err)\n\t}\n\tosCloud.UseZones(zones)\n\n\tnetworkInfo, err := osCloud.FindVPCInfo(cluster.Spec.Networking.NetworkID)\n\tif err != nil {\n\t\treturn res, fmt.Errorf(\"error describing Network: %v\", err)\n\t}","sourceCodeStart":910,"sourceCodeEnd":946,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/new_cluster.go#L910-L946","documentation":"kOps maps each provided subnet to its availability zone (subnet.Zone) and requires a 1:1 zone-to-subnet mapping — two subnets in the same AZ cannot both back the cluster's zone subnets. When a second subnet resolves to an AZ already claimed by an earlier subnet, \"subnet %s and %s have the same zone\" is returned.","triggerScenarios":"`kops create cluster --cloud aws --zones us-east-1a,us-east-1b --subnets subnet-1,subnet-2` where both subnet-1 and subnet-2 are in the same AZ (e.g. both us-east-1a), or more subnets than zones are supplied and two land in one AZ.","commonSituations":"Selecting several subnets from one AZ for extra CIDR space while only listing one zone; mismatched ordering/count between --zones and --subnets; assuming any subnet works with any zone.","solutions":["Pick one subnet per availability zone: --zones us-east-1a,us-east-1b with one subnet in each.","Verify each subnet's AZ via `aws ec2 describe-subnets --subnet-ids ...` and deduplicate.","If you need extra CIDRs in the same AZ, use kOps' utility subnets / multiple NetworkCIDR handling instead of duplicating zone subnets."],"exampleFix":"// before\n--zones us-east-1a,us-east-1b --subnets subnet-aaa1(1a),subnet-aaa2(1a)\n// after\n--zones us-east-1a,us-east-1b --subnets subnet-aaa1(1a),subnet-bbb1(1b)","handlingStrategy":"validation","validationCode":"out, _ := exec.Command(\"aws\", \"ec2\", \"describe-subnets\", \"--subnet-ids\",\n    strings.Join(subnets, \" \"), \"--region\", region,\n    \"--query\", \"Subnets[].AvailabilityZone\", \"--output\", \"json\").Output()\nif hasDuplicateAZ(out) {\n    return fmt.Errorf(\"duplicate AZ among requested subnets: %s\", out)\n}","typeGuard":null,"tryCatchPattern":"if strings.Contains(err.Error(), \"have the same zone\") {\n    // parse the two subnet IDs from the message, look up their AZs, drop one and retry\n}","preventionTips":["Enforce one subnet per AZ in your subnet-selection script.","Check each subnet's AvailabilityZone via describe-subnets before composing flags.","Keep --zones and --subnets counts aligned, one per zone."],"tags":["aws","subnet","availability-zone","validation","cluster-creation"],"backgroundTag":"subnet-zone-mismatch","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"}