kubernetes/kops · error

error detaching instance %q: %v

Error message

error detaching instance %q: %v

What it means

Same detach failure as its sibling error, but for instances with no associated Kubernetes node (nodeName == ""), e.g. control-plane or bastion instances identified only by cloud ID. It wraps the cloud provider DetachInstance error with just the instance ID.

Source

Thrown at pkg/instancegroups/instancegroups.go:640

// detachInstance detaches a Cloud Instance
func (c *RollingUpdateCluster) detachInstance(u *cloudinstances.CloudInstance) error {
	id := u.ID
	nodeName := ""
	if u.Node != nil {
		nodeName = u.Node.Name
	}
	if nodeName != "" {
		klog.Infof("Detaching instance %q, node %q, in group %q.", id, nodeName, u.CloudInstanceGroup.HumanName)
	} else {
		klog.Infof("Detaching instance %q, in group %q.", id, u.CloudInstanceGroup.HumanName)
	}

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

	return nil
}

// 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)
	}

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Re-run rolling update to refresh group membership
  2. Verify IAM permissions for detaching instances
  3. Check the instance still exists and belongs to the group in the cloud console
  4. Retry after transient cloud API errors
Defensive patterns

Strategy: try-catch

Validate before calling

// verify the instance exists in the cloud provider before detaching
inst, err := ec2Client.DescribeInstances(&ec2.DescribeInstancesInput{InstanceIds: []*string{&u.ID}})
// if not found or not in the expected group, refresh group state first

Type guard

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

Try / catch

if err := c.Cloud.DetachInstance(u); err != nil {
    if isNotFound(err) { return nil } // instance already gone
    return fmt.Errorf("error detaching instance %q: %v", id, err)
}

Prevention

When it happens

Trigger: c.Cloud.DetachInstance(u) fails and nodeName == "": detach of a control-plane/bastion instance rejected by the cloud API — instance not in group, permission denied, throttling, or instance already terminated.

Common situations: Rolling the control-plane of a cluster whose instances were modified out-of-band; IAM misconfiguration; transient cloud API errors during etcd member replacement rolls.

Related errors


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