kubernetes/kops · error

getting machine type info: %w

Error message

getting machine type info: %w

What it means

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').

Source

Thrown at upup/pkg/fi/cloudup/gcetasks/instance.go:195

	}
	return s
}

func scopeToShortForm(s string) string {
	for k, v := range scopeAliases {
		if v == s {
			return k
		}
	}
	return s
}

func (e *Instance) mapToGCE(project string, ipAddressResolver func(*Address) (*string, error)) (*compute.Instance, error) {
	zone := *e.Zone

	machineTypeInfo, err := guessMachineTypeInfo(fi.ValueOf(e.MachineType))
	if err != nil {
		return nil, fmt.Errorf("getting machine type info: %w", err)
	}

	scheduling := buildScheduling(machineTypeInfo, e.Preemptible, nil /* e.GCPProvisioningModel */, nil /* e.GuestAccelerators*/)

	var disks []*compute.AttachedDisk
	disks = append(disks, &compute.AttachedDisk{
		InitializeParams: &compute.AttachedDiskInitializeParams{
			SourceImage: BuildImageURL(project, *e.Image),
		},
		Boot:       true,
		DeviceName: "persistent-disks-0",
		Index:      0,
		AutoDelete: true,
		Mode:       "READ_WRITE",
		Type:       "PERSISTENT",
	})

	for name, disk := range e.Disks {

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Set an explicit, valid machineType on the GCE instance group spec, e.g. machineType: n1-standard-2
  2. Verify the machine type: `gcloud compute machine-types list --filter="name=<type>"`
  3. If using a newer family (e2/n2/c2), upgrade kops to a version whose guessMachineTypeInfo recognizes it

Example fix

// before (instance group spec)
machineType: "standard-2"
// after
machineType: "n1-standard-2"
Defensive patterns

Strategy: validation

Validate before calling

// Validate machineType before mapToGCE
func validateMachineType(mt string) error {
	if mt == "" { return fmt.Errorf("machineType must be set") }
	parts := strings.Split(mt, "-")
	if len(parts) < 3 { return fmt.Errorf("machineType %q must look like family-series-size, e.g. n1-standard-2", mt) }
	if _, err := strconv.Atoi(parts[len(parts)-1]); err != nil { return fmt.Errorf("machineType %q size must be numeric", mt) }
	return nil
}

Type guard

func isKnownMachineType(mt string) bool {
	_, err := guessMachineTypeInfo(fi.ValueOf(mt))
	return err == nil
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05). Data as JSON: /api/errors/a68b6bc588ee6dae. Report an issue: GitHub.