kubernetes/kops · error

timed out waiting for volume to detach

Error message

timed out waiting for volume to detach

What it means

Wraps a failure of ec2 DescribeLaunchTemplates inside findAutoscalingGroupLaunchTemplate. When the ASG specifies version "", "$Default", or "$Latest", kOps must resolve the actual version via DescribeLaunchTemplates; any SDK error is wrapped here (%q on the error prints it quoted).

Source

Thrown at pkg/resources/digitalocean/resources.go:335

func deleteLoadBalancer(cloud fi.Cloud, t *resources.Resource) error {
	c := cloud.(do.DOCloud)
	lb := t.Obj.(godo.LoadBalancer)
	_, err := c.LoadBalancersService().Delete(context.TODO(), lb.ID)
	if err != nil {
		return fmt.Errorf("failed to delete load balancer with name %s %v", lb.Name, err)
	}

	return nil
}

func waitForDetach(cloud do.DOCloud, action *godo.Action) error {
	timeout := time.After(10 * time.Second)
	ticker := time.NewTicker(500 * time.Millisecond)
	defer ticker.Stop()
	for {
		select {
		case <-timeout:
			return errors.New("timed out waiting for volume to detach")
		case <-ticker.C:
			updatedAction, _, err := cloud.ActionsService().Get(context.TODO(), action.ID)
			if err != nil {
				return err
			}

			if updatedAction.Status == godo.ActionCompleted {
				return nil
			}
		}
	}
}

func dumpDroplet(op *resources.DumpOperation, r *resources.Resource) error {
	data := make(map[string]interface{})
	data["id"] = r.ID
	data["type"] = godo.DropletResourceType
	data["raw"] = r.Obj

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Re-create the deleted launch template or re-run `kops update cluster` to generate a new one attached to the ASG
  2. Grant ec2:DescribeLaunchTemplates to the kOps IAM role
  3. Verify the launch template exists in the same region/account: `aws ec2 describe-launch-templates --launch-template-ids <id>`
  4. Retry on throttling errors
Defensive patterns

Strategy: retry

Validate before calling

ltOut, err := cloud.EC2().DescribeLaunchTemplates(ctx, &ec2.DescribeLaunchTemplatesInput{LaunchTemplateIds: []string{ltID}})
if err != nil || len(ltOut.LaunchTemplates) == 0 { return fmt.Errorf("launch template %q missing", ltID) }

Try / catch

err := rollingUpdate(ctx, cluster)
var invalidLT *ec2types.InvalidLaunchTemplateId
if errors.As(err, &invalidLT) {
  // launch template deleted: recreate via kops update cluster, then retry
  recreateLaunchTemplates()
} else if strings.Contains(err.Error(), "error describing launch templates") {
  retryWithBackoff()
}

Prevention

When it happens

Trigger: DescribeLaunchTemplates fails: launch template deleted while ASG still references it (returns InvalidLaunchTemplateId-type errors), missing ec2:DescribeLaunchTemplates permission, throttling, or region mismatch.

Common situations: Launch template manually deleted or Terraform-pruned; cross-account/cross-region template references; IAM policy missing ec2 describe permissions during rolling update.

Understand the failure class

Related errors


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