{"record":{"id":"1908db5d0d97dbf1","repo":"kubernetes/kops","slug":"subnet-q-has-configured-cidr-q-but-the-actual-c","errorCode":null,"errorMessage":"Subnet %q has configured CIDR %q, but the actual CIDR found was %q","messagePattern":"Subnet %q has configured CIDR %q, but the actual CIDR found was %q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/subnets.go","lineNumber":95,"sourceCode":"\t\tsubnetByID := make(map[string]*fi.SubnetInfo)\n\t\tfor _, subnetInfo := range vpcInfo.Subnets {\n\t\t\tsubnetByID[subnetInfo.ID] = subnetInfo\n\t\t}\n\t\tfor i := range c.Spec.Networking.Subnets {\n\t\t\tsubnet := &c.Spec.Networking.Subnets[i]\n\t\t\tif subnet.ID != \"\" {\n\t\t\t\tcloudSubnet := subnetByID[subnet.ID]\n\t\t\t\tif cloudSubnet == nil {\n\t\t\t\t\treturn fmt.Errorf(\"Subnet %q not found in VPC %q\", subnet.ID, c.Spec.Networking.NetworkID)\n\t\t\t\t}\n\t\t\t\tif subnet.CIDR == \"\" {\n\t\t\t\t\tsubnet.CIDR = cloudSubnet.CIDR\n\t\t\t\t\t// IPv6-only private subnets do not have an IPv4 CIDR\n\t\t\t\t\tif subnet.CIDR == \"\" && (subnet.IPv6CIDR == \"\" || subnet.Type != kops.SubnetTypePrivate) {\n\t\t\t\t\t\treturn fmt.Errorf(\"Subnet %q did not have CIDR\", subnet.ID)\n\t\t\t\t\t}\n\t\t\t\t} else if subnet.CIDR != cloudSubnet.CIDR {\n\t\t\t\t\treturn fmt.Errorf(\"Subnet %q has configured CIDR %q, but the actual CIDR found was %q\", subnet.ID, subnet.CIDR, cloudSubnet.CIDR)\n\t\t\t\t}\n\n\t\t\t\tif needZones && subnet.Zone == \"\" {\n\t\t\t\t\tsubnet.Zone = cloudSubnet.Zone\n\t\t\t\t} else if subnet.Zone != cloudSubnet.Zone {\n\t\t\t\t\treturn fmt.Errorf(\"Subnet %q has configured Zone %q, but the actual Zone found was %q\", subnet.ID, subnet.Zone, cloudSubnet.Zone)\n\t\t\t\t}\n\n\t\t\t}\n\t\t}\n\t}\n\n\tif needZones {\n\t\tfor i := range c.Spec.Networking.Subnets {\n\t\t\tsubnet := &c.Spec.Networking.Subnets[i]\n\t\t\tif subnet.ID != \"\" && subnet.Zone == \"\" {\n\t\t\t\treturn fmt.Errorf(\"could not determine the zone of subnet %q; specify the zone in the cluster spec\", subnet.Name)\n\t\t\t}","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/subnets.go#L77-L113","documentation":"The cluster spec declares an explicit CIDR for a subnet referenced by ID, but the CIDR actually configured on that cloud subnet differs. kOps treats the cloud as the source of truth for existing subnets and refuses to proceed with a conflicting spec value.","triggerScenarios":"Cluster spec has both `id: subnet-xxxx` and `cidr: 10.0.1.0/24` where the real AWS subnet CIDR is something else — usually after the subnet was resized/changed out-of-band or the spec was written for a different subnet.","commonSituations":"Subnet CIDR changed by another team after the cluster spec was generated; copying a cluster.yaml between environments; typo in the configured CIDR.","solutions":["Read the real CIDR (`aws ec2 describe-subnets --subnet-ids subnet-xxxx`) and set the spec's `cidr` to match, or simply remove the `cidr` field so kOps adopts the cloud value.","Re-run `kops update cluster`.","If you intended a different CIDR, create/point to a subnet that actually has it."],"exampleFix":"// before\nsubnets:\n- id: subnet-0abc\n  cidr: 10.0.1.0/24   # actual: 10.0.16.0/20\n// after\nsubnets:\n- id: subnet-0abc   # cidr omitted; inherited from cloud\n","handlingStrategy":"validation","validationCode":"actual := describeSubnetCIDR(subnetID, region)\nif subnet.CIDR != \"\" && subnet.CIDR != actual {\n    return fmt.Errorf(\"cidr %s != cloud cidr %s for %s\", subnet.CIDR, actual, subnetID)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Omit the explicit `cidr` field for ID-referenced subnets and let kOps inherit it from the cloud.","Re-generate cluster specs after any manual subnet CIDR change.","Diff the spec against live cloud state in CI."],"tags":["subnet","cidr","aws","config-validation"],"backgroundTag":"subnet-cidr-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"}