kubernetes/kops · error

error reading InstanceGroup %q: %v

Error message

error reading InstanceGroup %q: %v

What it means

After resolving the cluster, the command fetches the InstanceGroup from the kOps API. If the Get call returns an error (network, API failure, or not-found surfaced as an error), the command wraps it with the group name. The %v carries the underlying client error.

Source

Thrown at cmd/kops/delete_instancegroup.go:142

	// TODO implement drain and validate logic
	groupName := options.GroupName
	if groupName == "" {
		return fmt.Errorf("GroupName is required")
	}

	cluster, err := GetCluster(ctx, f, options.ClusterName)
	if err != nil {
		return err
	}

	clientset, err := f.KopsClient()
	if err != nil {
		return err
	}

	group, err := clientset.InstanceGroupsFor(cluster).Get(ctx, groupName, metav1.GetOptions{})
	if err != nil {
		return fmt.Errorf("error reading InstanceGroup %q: %v", groupName, err)
	}
	if group == nil {
		return fmt.Errorf("InstanceGroup %q not found", groupName)
	}

	fmt.Fprintf(out, "InstanceGroup %q found for deletion\n", groupName)

	if group.Spec.Role.HasControlPlane() {
		groups, err := clientset.InstanceGroupsFor(cluster).List(ctx, metav1.ListOptions{})
		if err != nil {
			return fmt.Errorf("listing InstanceGroups: %v", err)
		}

		onlyMaster := true
		for _, ig := range groups.Items {
			if ig.Name != groupName && ig.Spec.Role.HasControlPlane() {
				onlyMaster = false
				break

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Run `kops get instancegroups --name <cluster>` to confirm the exact group name
  2. Check the wrapped %v message for the root cause (not-found vs connection vs auth)
  3. Verify --name/--state flags point at the intended cluster and state store

Example fix

// before
kops delete instancegroup node --name mycluster.k8s.local
// after (list to get exact name)
kops get instancegroups --name mycluster.k8s.local
kops delete instancegroup nodes --name mycluster.k8s.local
Defensive patterns

Strategy: try-catch

Validate before calling

kops get instancegroups --name mycluster.k8s.local  # verify group exists first

Try / catch

err := RunDeleteInstanceGroup(ctx, f, out, opts)
if err != nil && strings.Contains(err.Error(), "error reading InstanceGroup") {
    // inspect wrapped cause: not-found vs connection
    log.Printf("instance group lookup failed: %v", err)
}

Prevention

When it happens

Trigger: clientset.InstanceGroupsFor(cluster).Get(ctx, groupName, ...) fails: cluster unreachable, wrong --name, or the group does not exist and the backend returns an error rather than nil.

Common situations: Typo in the instance group name; pointing at the wrong cluster; kOps state store permission problems; offline/etcd issues in the admin cluster.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


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