{"record":{"id":"a68b6bc588ee6dae","repo":"kubernetes/kops","slug":"getting-machine-type-info-w","errorCode":null,"errorMessage":"getting machine type info: %w","messagePattern":"getting machine type info: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/gcetasks/instance.go","lineNumber":195,"sourceCode":"\t}\n\treturn s\n}\n\nfunc scopeToShortForm(s string) string {\n\tfor k, v := range scopeAliases {\n\t\tif v == s {\n\t\t\treturn k\n\t\t}\n\t}\n\treturn s\n}\n\nfunc (e *Instance) mapToGCE(project string, ipAddressResolver func(*Address) (*string, error)) (*compute.Instance, error) {\n\tzone := *e.Zone\n\n\tmachineTypeInfo, err := guessMachineTypeInfo(fi.ValueOf(e.MachineType))\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"getting machine type info: %w\", err)\n\t}\n\n\tscheduling := buildScheduling(machineTypeInfo, e.Preemptible, nil /* e.GCPProvisioningModel */, nil /* e.GuestAccelerators*/)\n\n\tvar disks []*compute.AttachedDisk\n\tdisks = append(disks, &compute.AttachedDisk{\n\t\tInitializeParams: &compute.AttachedDiskInitializeParams{\n\t\t\tSourceImage: BuildImageURL(project, *e.Image),\n\t\t},\n\t\tBoot:       true,\n\t\tDeviceName: \"persistent-disks-0\",\n\t\tIndex:      0,\n\t\tAutoDelete: true,\n\t\tMode:       \"READ_WRITE\",\n\t\tType:       \"PERSISTENT\",\n\t})\n\n\tfor name, disk := range e.Disks {","sourceCodeStart":177,"sourceCodeEnd":213,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/gcetasks/instance.go#L177-L213","documentation":"Instance.mapToGCE starts by calling guessMachineTypeInfo on e.MachineType to derive CPU/memory properties used to build the scheduling config. This error wraps any failure from that inference — most often an empty or unparseable machine type string (expected format like 'n1-standard-2').","triggerScenarios":"e.MachineType is nil/empty or doesn't match a recognizable GCE machine type family/size pattern, causing guessMachineTypeInfo to fail during RenderGCE or RenderTerraform.","commonSituations":"Cluster spec with a missing or misspelled machineType for a GCE instance group (e.g. 'standard-2' instead of 'n1-standard-2', or an E2/N2 type not recognized by an older kops version); machineType omitted from the IG manifest.","solutions":["Set an explicit, valid machineType on the GCE instance group spec, e.g. machineType: n1-standard-2","Verify the machine type: `gcloud compute machine-types list --filter=\"name=<type>\"`","If using a newer family (e2/n2/c2), upgrade kops to a version whose guessMachineTypeInfo recognizes it"],"exampleFix":"// before (instance group spec)\nmachineType: \"standard-2\"\n// after\nmachineType: \"n1-standard-2\"\n","handlingStrategy":"validation","validationCode":"// Validate machineType before mapToGCE\nfunc validateMachineType(mt string) error {\n\tif mt == \"\" { return fmt.Errorf(\"machineType must be set\") }\n\tparts := strings.Split(mt, \"-\")\n\tif len(parts) < 3 { return fmt.Errorf(\"machineType %q must look like family-series-size, e.g. n1-standard-2\", mt) }\n\tif _, err := strconv.Atoi(parts[len(parts)-1]); err != nil { return fmt.Errorf(\"machineType %q size must be numeric\", mt) }\n\treturn nil\n}","typeGuard":"func isKnownMachineType(mt string) bool {\n\t_, err := guessMachineTypeInfo(fi.ValueOf(mt))\n\treturn err == nil\n}","tryCatchPattern":null,"preventionTips":["Always set machineType explicitly in GCE instance group specs using standard forms (n1-standard-4, e2-medium, etc.)","Verify the type exists: gcloud compute machine-types list","Upgrade kops when adopting newer machine families the version may not recognize","Add machineType linting to cluster-spec CI"],"tags":["gce","machine-type","config"],"backgroundTag":"invalid-machine-type","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"}