kubernetes/kops · error

error deleting instance %q: %v

Error message

error deleting instance %q: %v

What it means

Same DeleteInstance failure as the sibling error but formatted without a node name (nodeName == ""), typically for control-plane or bastion instances. The cloud provider refused or failed the instance termination request.

Source

Thrown at pkg/instancegroups/instancegroups.go:663

// deleteInstance deletes an Cloud Instance.
func (c *RollingUpdateCluster) deleteInstance(u *cloudinstances.CloudInstance) error {
	id := u.ID
	nodeName := ""
	if u.Node != nil {
		nodeName = u.Node.Name
	}
	if nodeName != "" {
		klog.Infof("Stopping instance %q, node %q, in group %q (this may take a while).", id, nodeName, u.CloudInstanceGroup.HumanName)
	} else {
		klog.Infof("Stopping instance %q, in group %q (this may take a while).", id, u.CloudInstanceGroup.HumanName)
	}

	if err := c.Cloud.DeleteInstance(u); err != nil {
		if nodeName != "" {
			return fmt.Errorf("error deleting instance %q, node %q: %v", id, nodeName, err)
		}
		return fmt.Errorf("error deleting instance %q: %v", id, err)
	}

	return nil
}

// drainNode drains a K8s node.
func (c *RollingUpdateCluster) drainNode(ctx context.Context, u *cloudinstances.CloudInstance) error {
	if c.K8sClient == nil {
		return fmt.Errorf("K8sClient not set")
	}

	if u.Node == nil {
		return fmt.Errorf("node not set")
	}

	if u.Node.Name == "" {
		return fmt.Errorf("node name not set")
	}

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Re-run rolling update to reconcile state
  2. Verify IAM permissions for terminating instances
  3. Check instance state in the cloud console (may already be terminated)
  4. Retry after transient cloud API issues
Defensive patterns

Strategy: try-catch

Validate before calling

// confirm control-plane instance exists before terminating
out, _ := ec2Client.DescribeInstances(&ec2.DescribeInstancesInput{InstanceIds: []*string{&u.ID}})
// refresh group membership if DescribeInstances returns invalid-instance-id

Type guard

func deleteTarget(u *cloudinstances.CloudInstance) bool { return u != nil && u.ID != "" }

Try / catch

if err := c.Cloud.DeleteInstance(u); err != nil {
    if isNotFound(err) { return nil }
    return fmt.Errorf("error deleting instance %q: %v", id, err)
}

Prevention

When it happens

Trigger: c.Cloud.DeleteInstance(u) fails and nodeName == "": terminate call rejected — instance already gone, IAM denial, dependency error (e.g. volume detach in progress), or throttling.

Common situations: Rolling control-plane instances that were modified out-of-band; transient cloud API errors; missing ec2:TerminateInstances permission.

Related errors


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