{"record":{"id":"39a49ab13d5313ea","repo":"kubernetes/kops","slug":"error-searching-for-detached-instances-for-autosca","errorCode":null,"errorMessage":"error searching for detached instances for autoscaling group %q: %v","messagePattern":"error searching for detached instances for autoscaling group %q: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/awsup/aws_cloud.go","lineNumber":401,"sourceCode":"\n\treturn deleteGroup(ctx, c, g)\n}\n\nfunc deleteGroup(ctx context.Context, c AWSCloud, g *cloudinstances.CloudInstanceGroup) error {\n\tasg := g.Raw.(*autoscalingtypes.AutoScalingGroup)\n\n\tname := aws.ToString(asg.AutoScalingGroupName)\n\ttemplate := aws.ToString(asg.LaunchConfigurationName)\n\tlaunchTemplate := \"\"\n\tif asg.LaunchTemplate != nil {\n\t\tlaunchTemplate = aws.ToString(asg.LaunchTemplate.LaunchTemplateName)\n\t}\n\n\t// Delete detached instances\n\t{\n\t\tdetached, err := findDetachedInstances(ctx, c, asg)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"error searching for detached instances for autoscaling group %q: %v\", name, err)\n\t\t}\n\t\tif len(detached) > 0 {\n\t\t\tklog.V(2).Infof(\"Deleting detached instances for autoscaling group %q\", name)\n\t\t\treq := &ec2.TerminateInstancesInput{\n\t\t\t\tInstanceIds: detached,\n\t\t\t}\n\t\t\tif _, err := c.EC2().TerminateInstances(ctx, req); err != nil {\n\t\t\t\treturn fmt.Errorf(\"error deleting detached instances for autoscaling group %q: %v\", name, err)\n\t\t\t}\n\t\t}\n\t}\n\n\t// Delete ASG\n\t{\n\t\tklog.V(2).Infof(\"Deleting autoscaling group %q\", name)\n\t\trequest := &autoscaling.DeleteAutoScalingGroupInput{\n\t\t\tAutoScalingGroupName: aws.String(name),\n\t\t\tForceDelete:          aws.Bool(true),","sourceCodeStart":383,"sourceCodeEnd":419,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/awsup/aws_cloud.go#L383-L419","documentation":"During ASG deletion, findDetachedInstances failed to list instances tagged as detached from the autoscaling group; the EC2 describe call errored and the wrapped AWS error explains the failure.","triggerScenarios":"Thrown at upup/pkg/fi/cloudup/awsup/aws_cloud.go:401 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check EC2 describe permissions for the credentials in use","Retry the delete operation for transient API errors"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}