kubernetes/kops · error

InstanceGroup name is missing

Error message

InstanceGroup name is missing

What it means

ConfigBuilder.GetInstanceGroup requires b.InstanceGroupName to identify which instance group to fetch from the cluster. This sentinel error means the builder was used without that field set, so no group can be selected.

Source

Thrown at pkg/commands/toolbox_enroll.go:552

	if err != nil {
		return nil, fmt.Errorf("building full cluster spec: %w", err)
	}
	b.fullCluster = fullCluster
	return fullCluster, nil
}

func (b *ConfigBuilder) GetInstanceGroup(ctx context.Context) (*kops.InstanceGroup, error) {
	if b.InstanceGroup != nil {
		return b.InstanceGroup, nil
	}

	instanceGroups, err := b.GetInstanceGroups(ctx)
	if err != nil {
		return nil, err
	}

	if b.InstanceGroupName == "" {
		return nil, fmt.Errorf("InstanceGroup name is missing")
	}

	// Build full IG spec to ensure we end up with a valid IG
	for i := range instanceGroups.Items {
		ig := &instanceGroups.Items[i]
		if ig.Name == b.InstanceGroupName {
			b.InstanceGroup = ig
			return ig, nil
		}
	}
	return nil, fmt.Errorf("instance group %q not found", b.InstanceGroupName)
}

func (b *ConfigBuilder) GetFullInstanceGroup(ctx context.Context) (*kops.InstanceGroup, error) {
	if b.fullInstanceGroup != nil {
		return b.fullInstanceGroup, nil
	}

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Set InstanceGroupName on the ConfigBuilder before calling GetInstanceGroup/GetFullInstanceGroup
  2. Pass the instance-group flag through from the CLI invocation
  3. Guard callers: check InstanceGroupName != "" and report a usage error early

Example fix

// before
b := ConfigBuilder{ClusterName: "c1.example.com"}
ig, err := b.GetInstanceGroup(ctx) // "InstanceGroup name is missing"
// after
b := ConfigBuilder{ClusterName: "c1.example.com", InstanceGroupName: "nodes"}
Defensive patterns

Strategy: validation

Validate before calling

if b.InstanceGroupName == "" {
    return errors.New("--instance-group is required")
}

Type guard

func (b *ConfigBuilder) HasInstanceGroupName() bool { return b.InstanceGroupName != "" }

Prevention

When it happens

Trigger: Calling GetInstanceGroup (directly or via GetFullInstanceGroup) on a ConfigBuilder whose InstanceGroupName field was never set.

Common situations: Programmatic use of toolbox enroll/config builder where the --name/-ig flag wasn't wired into the builder; tests constructing a partial builder; a code path that only sets ClusterName but not InstanceGroupName.

Understand the failure class

Background: "X is required", "must be set", "cannot be empty": the missing-required-config error family, from Vertex AI project/location to WeChat keys — this error's family across 18 libraries.

Related errors


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