{"record":{"id":"53f6f6ffaf097857","repo":"kubernetes/kops","slug":"unhandled-role-q-53f6f6","errorCode":null,"errorMessage":"unhandled role %q","messagePattern":"unhandled role %q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/openstack/utils.go","lineNumber":98,"sourceCode":"\t\t\t}\n\t\t}\n\n\tcase ig.Spec.Role.HasNode():\n\t\tfor _, flavor := range fList {\n\t\t\tif flavor.RAM >= 4096 && flavor.VCPUs >= 2 {\n\t\t\t\tcandidates = append(candidates, flavor)\n\t\t\t}\n\t\t}\n\n\tcase ig.Spec.Role.HasBastion():\n\t\tfor _, flavor := range fList {\n\t\t\tif flavor.RAM >= 1024 {\n\t\t\t\tcandidates = append(candidates, flavor)\n\t\t\t}\n\t\t}\n\n\tdefault:\n\t\treturn \"\", fmt.Errorf(\"unhandled role %q\", ig.Spec.Role)\n\t}\n\tif len(candidates) == 0 {\n\t\treturn \"\", fmt.Errorf(\"No suitable flavor for role %q\", ig.Spec.Role)\n\t}\n\treturn candidates[0].Name, nil\n}\n\nfunc GetServerFixedIP(server *servers.Server, interfaceName string) (poolAddress string, err error) {\n\tif localAddr, ok := server.Addresses[interfaceName]; ok {\n\t\tif localAddresses, ok := localAddr.([]interface{}); ok {\n\t\t\tfor _, addr := range localAddresses {\n\t\t\t\taddrMap := addr.(map[string]interface{})\n\t\t\t\tif addrType, ok := addrMap[openstackExternalIPType]; ok && addrType == openstackAddressFixed {\n\t\t\t\t\tif fixedIP, ok := addrMap[openstackAddress]; ok {\n\t\t\t\t\t\tif fixedIPStr, ok := fixedIP.(string); ok {\n\t\t\t\t\t\t\tpoolAddress = fixedIPStr\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\terr = fmt.Errorf(\"Fixed IP was not a string: %v\", fixedIP)","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/openstack/utils.go#L80-L116","documentation":"Thrown by defaultInstanceType's switch when ig.Spec.Role does not match any handled case in the flavor-selection switch. The role value is outside the set of OpenStack instance group roles kOps knows how to size, so it refuses to guess a flavor.","triggerScenarios":"Calling DefaultInstanceType with an InstanceGroup whose Spec.Role falls into the switch's default branch — e.g. a role type added in a newer kOps, an invalid role string in hand-edited YAML, or the bare 'node' role not matching the HasControlPlane()/specific-case predicates handled above.","commonSituations":"Cluster specs created by newer kOps versions with roles this build doesn't recognize; typos in instance group YAML role fields; applying a spec produced for another cloud provider's role naming.","solutions":["Check the instance group's spec.role value and correct it (valid values: control-plane/master, node, bastion).","Regenerate/inspect the instance group with `kops get ig -o yaml` using a matching kOps version.","Upgrade kOps if the role was introduced in a newer release than the binary in use."],"exampleFix":"// before\ncsvD.spec.Role = \"Node\" // invalid casing/string\n// after\nig.Spec.Role = kopsapi.InstanceGroupRoleNode","handlingStrategy":"validation","validationCode":"switch ig.Spec.Role {\ncase kopsapi.InstanceGroupRoleControlPlane, kopsapi.InstanceGroupRoleNode, kopsapi.InstanceGroupRoleBastion:\n    // ok\ndefault:\n    return fmt.Errorf(\"unsupported role %q\", ig.Spec.Role)\n}","typeGuard":"func isValidRole(r kopsapi.InstanceGroupRole) bool {\n    switch r {\n    case kopsapi.InstanceGroupRoleControlPlane, kopsapi.InstanceGroupRoleNode, kopsapi.InstanceGroupRoleBastion:\n        return true\n    }\n    return false\n}","tryCatchPattern":null,"preventionTips":["Always create instance groups via `kops create ig` rather than hand-editing YAML","Use the kops API constants for roles instead of string literals","Match kOps binary version to the cluster spec version"],"tags":["openstack","instance-group","validation","role"],"backgroundTag":"unhandled-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"}