kubernetes/kops · error

error deleting autoscaling group

Error message

error deleting autoscaling group %q: %v

What it means

Thrown when the Auto Scaling DeleteAutoScalingGroup API fails for reasons other than a dependency violation (which is returned unwrapped so callers can retry). Wraps the ASG name and the underlying error during cluster teardown.

Solutions

  1. Confirm the ASG exists in the correct region: `aws autoscaling describe-auto-scaling-groups --auto-scaling-group-names <id>`.
  2. If it doesn't exist, it's already deleted — re-run kops delete cluster; check for stale state.
  3. Fix IAM permissions (autoscaling:DeleteAutoScalingGroup).
  4. Retry on throttling after backoff.
Defensive patterns

Strategy: type-guard

Validate before calling

groups, err := asgClient.DescribeAutoScalingGroups(ctx, &autoscaling.DescribeAutoScalingGroupsInput{AutoScalingGroupNames: []string{id}}); if err != nil || len(groups.AutoScalingGroups) == 0 { /* already deleted, skip */ }

Type guard

func isNotFound(err error) bool { return strings.Contains(err.Error(), "does not exist") || strings.Contains(err.Error(), "not found") }

Try / catch

err := DeleteAutoScalingGroup(cloud, r)
if err != nil {
	if isNotFound(err) { return nil } // already deleted
	return err
}

Prevention

When it happens

Trigger: DeleteAutoScalingGroup with ForceDelete on an ASG name that doesn't exist (ValidationError: AutoScalingGroup name not found), insufficient iam:DeleteAutoScalingGroup permission, or throttling.

Common situations: ASG already deleted by a concurrent/previous run but state cache is stale; IAM role missing autoscaling:DeleteAutoScalingGroup; ASG in a different region than the kops cloud client.

Related errors


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

Appendix: source

Thrown at pkg/resources/aws/aws.go:1247

func DeleteAutoScalingGroup(cloud fi.Cloud, r *resources.Resource) error {
	ctx := context.TODO()

	c := cloud.(awsup.AWSCloud)

	id := r.ID

	klog.V(2).Infof("Deleting autoscaling group %q", id)
	request := &autoscaling.DeleteAutoScalingGroupInput{
		AutoScalingGroupName: &id,
		ForceDelete:          aws.Bool(true),
	}
	_, err := c.Autoscaling().DeleteAutoScalingGroup(ctx, request)
	if err != nil {
		if IsDependencyViolation(err) {
			return err
		}
		return fmt.Errorf("error deleting autoscaling group %q: %v", id, err)
	}
	return nil
}

func ListAutoScalingGroups(cloud fi.Cloud, vpcID, clusterName string) ([]*resources.Resource, error) {
	c := cloud.(awsup.AWSCloud)

	tags := c.Tags()

	asgs, err := awsup.FindAutoscalingGroups(c, tags)
	if err != nil {
		return nil, err
	}

	var resourceTrackers []*resources.Resource

	for _, asg := range asgs {
		resourceTracker := &resources.Resource{

View on GitHub (pinned to 4c8573c808)