kubernetes/kops · error

InstanceGroups::DeleteCollection not supported for server-si

Error message

InstanceGroups::DeleteCollection not supported for server-side client

What it means

The kops-controller server-side clientset intentionally does not implement InstanceGroups collection deletion. The instanceGroups resource wrapper returns this sentinel error from DeleteCollection because the controller clientset only supports the subset of methods kops-controller actually needs. Calling an unimplemented method on the server-side client always returns this fixed error; nothing is sent to the API server.

Source

Thrown at cmd/kops-controller/pkg/controllerclientset/instancegroups.go:112

		c.addLabels(&list.Items[i])
	}
	return list, nil
}

func (c *instanceGroups) Create(ctx context.Context, g *kopsapi.InstanceGroup, opts metav1.CreateOptions) (*kopsapi.InstanceGroup, error) {
	return nil, fmt.Errorf("InstanceGroups::Create not supported for server-side client")
}

func (c *instanceGroups) Update(ctx context.Context, g *kopsapi.InstanceGroup, opts metav1.UpdateOptions) (*kopsapi.InstanceGroup, error) {
	return nil, fmt.Errorf("InstanceGroups::Update not supported for server-side client")
}

func (c *instanceGroups) Delete(ctx context.Context, name string, options metav1.DeleteOptions) error {
	return fmt.Errorf("InstanceGroups::Delete not supported for server-side client")
}

func (r *instanceGroups) DeleteCollection(ctx context.Context, options metav1.DeleteOptions, listOptions metav1.ListOptions) error {
	return fmt.Errorf("InstanceGroups::DeleteCollection not supported for server-side client")
}

func (r *instanceGroups) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) {
	return nil, fmt.Errorf("InstanceGroups::Watch not supported for server-side client")
}

func (r *instanceGroups) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *kopsapi.InstanceGroup, err error) {
	return nil, fmt.Errorf("InstanceGroups::Patch not supported for server-side client")
}

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Avoid DeleteCollection on this clientset: list InstanceGroups and delete each item individually via Delete(name) — but note Delete is also unsupported, so instead delete via the standard Kubernetes clientset or apply an empty/desired state server-side
  2. Use a standard Kubernetes typed clientset (client-go) built from the controller's REST config for deletion operations
  3. Restructure logic to not require deleting instance group collections (e.g. manage desired state with server-side apply and let garbage collection remove objects)
  4. If the method is genuinely needed, contribute an implementation to cmd/kops-controller/pkg/controllerclientset/instancegroups.go

Example fix

// before
err := client.InstanceGroups().DeleteCollection(ctx, metav1.DeleteOptions{}, metav1.ListOptions{})
// after
groups, err := client.InstanceGroups().List(ctx, metav1.ListOptions{})
if err != nil {
	return err
}
for _, ig := range groups.Items {
	klog.Infof("instance group %s must be removed out-of-band", ig.Name)
}
Defensive patterns

Strategy: fallback

Validate before calling

if _, ok := igClient.(interface{ DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error }); ok {
	// only safe if implemented; controllerclientset returns sentinel error, so skip
}
// Prefer: restrict deletion logic to the standard client-go clientset.

Type guard

func supportsDeleteCollection(v interface{}) bool {
	_, ok := v.(interface {
		DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error
	})
	return ok
}

Try / catch

if err := igClient.DeleteCollection(ctx, metav1.DeleteOptions{}, metav1.ListOptions{}); err != nil {
	if strings.Contains(err.Error(), "not supported for server-side client") {
		return handleOutOfBandDeletion(ctx) // fallback path via kubectl/standard clientset
	}
	return err
}

Prevention

When it happens

Trigger: Any code path that calls ctxClient.InstanceGroups().DeleteCollection(ctx, metav1.DeleteOptions{}, metav1.ListOptions{}) on the server-side controller clientset, e.g. bulk-cleanup code or generic reconcile logic written against the full kops clientset interface.

Common situations: Refactoring code that previously used the legacy kops clientset (which supports DeleteCollection) to the controller server-side clientset; writing a controller helper that assumes interface parity; generic code that iterates and deletes collections of resources.

Related errors


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