{"record":{"id":"999ccaca9b8feab6","repo":"kubernetes/kops","slug":"subnet-q-has-unknown-type-q-999cca","errorCode":null,"errorMessage":"subnet %q has unknown type %q","messagePattern":"subnet %q has unknown type %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/subnets.go","lineNumber":155,"sourceCode":"\t\tif subnet.CIDR != \"\" {\n\t\t\t_, cidrSubnet, err := net.ParseCIDR(subnet.CIDR)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"invalid subnet %q CIDR: %q\", subnet.Name, subnet.CIDR)\n\t\t\t}\n\t\t\t// Skip additional subnets\n\t\t\tif !cidr.Contains(cidrSubnet.IP) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\t\tswitch subnet.Type {\n\t\tcase kops.SubnetTypeDualStack, kops.SubnetTypePublic, kops.SubnetTypePrivate:\n\t\t\tbigSubnets = append(bigSubnets, subnet)\n\n\t\tcase kops.SubnetTypeUtility:\n\t\t\tlittleSubnets = append(littleSubnets, subnet)\n\n\t\tdefault:\n\t\t\treturn fmt.Errorf(\"subnet %q has unknown type %q\", subnet.Name, subnet.Type)\n\t\t}\n\n\t\tif subnet.CIDR != \"\" {\n\t\t\t_, subnetCIDR, err := net.ParseCIDR(subnet.CIDR)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"subnet %q has unexpected CIDR %q\", subnet.Name, subnet.CIDR)\n\t\t\t}\n\n\t\t\treserved = append(reserved, subnetCIDR)\n\t\t}\n\t}\n\n\t// Assign a consistent order\n\tsort.Sort(ByZone(bigSubnets))\n\tsort.Sort(ByZone(littleSubnets))\n\n\t// Check how many subnet slices are needed\n\tcidrCount := len(bigSubnets)","sourceCodeStart":137,"sourceCodeEnd":173,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/subnets.go#L137-L173","documentation":"During CIDR assignment, kOps classifies each subnet by its type (Public/Private/Internal/Utility/DualStack variants). This error is thrown when a subnet's type does not match any known kops.SubnetType, so kOps cannot decide whether to treat it as a 'big' or 'little' subnet for CIDR allocation.","triggerScenarios":"cluster.spec.networking.subnets[i].type set to a value other than Public, Private, Utility, Internal, DualStack-Legacy, DualStack-Public, etc. — typically a misspelling or a type dropped in a kOps version upgrade.","commonSituations":"Typo like 'pubic' or 'private' (wrong case) in cluster.yaml; specs written for an older kOps version using a removed type name; hand-generated manifests from custom tooling.","solutions":["Set the subnet type to a valid kops.SubnetType value (Public, Private, Utility, Internal) in the cluster spec","Run `kops edit cluster` instead of hand-editing so enum values are constrained","Check the kops API version in the manifest and upgrade/downgrade kops so the type names match the API version"],"exampleFix":"// before\nsubnets:\n- name: us-east-1a\n  type: privte\n// after\nsubnets:\n- name: us-east-1a\n  type: Private","handlingStrategy":"validation","validationCode":"validTypes := map[string]bool{\"Public\":true,\"Private\":true,\"Utility\":true,\"Internal\":true}\nfor _, s := range subnets {\n\tif !validTypes[s.Type] { return fmt.Errorf(\"subnet %q: unknown type %q\", s.Name, s.Type) }\n}","typeGuard":"func knownSubnetType(t kops.SubnetType) bool {\n\tswitch t {\n\tcase kops.SubnetTypePublic, kops.SubnetTypePrivate, kops.SubnetTypeUtility, kops.SubnetTypeInternal:\n\t\treturn true\n\t}\n\treturn false\n}","tryCatchPattern":"if err := PerformAssignments(c, cloud); err != nil {\n\tif strings.Contains(err.Error(), \"unknown type\") { /* correct subnet Type in manifest */ }\n\treturn err\n}","preventionTips":["Always set subnet type via `kops edit cluster`, not free-text editing","Keep kops CLI and cluster manifest apiVersion in sync","grep manifests against kops.SubnetType constants before upgrade"],"tags":["network","subnet","configuration","kops"],"backgroundTag":"invalid-enum-value","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"}