terraform-aws-gitlab-runner icon indicating copy to clipboard operation
terraform-aws-gitlab-runner copied to clipboard

Terraform destroy doesn't work

Open kovacslaszlonik opened this issue 1 year ago • 3 comments
trafficstars

Describe the bug

When we destroy the module, the requested spot instances are not canceled, and the terraform process timeouts on the following step:

We are using the currently latest stable, 7.2.2 version of this module. The issue is due to the fact, that the module.terminate_agent_hook is deleted before the aws_autoscaling_group.gitlab_runner_instance module, so the lambda function is not triggered in time.

It creates a loop that can be solved only with a manual interaction (terminate the spot instances) when we try to destroy the module.

To Reproduce

Steps to reproduce the behavior:

  1. Create your gitlab-runner from the 7.2.2 version
  2. Wait until it is initiated
  3. Run terraform destroy 4 You will see the timeout issue in this step since the spot runners are not terminated/canceled by the module itself:
module.spot_runner.aws_security_group.docker_machine[0]: Still destroying... [id=sg-04d8bdc6b45747c0c, 2m20s elapsed]
module.spot_runner.aws_security_group.docker_machine[0]: Still destroying... [id=sg-04d8bdc6b45747c0c, 2m30s elapsed]

Expected behavior

We can destroy the module without any issues or manual interaction.

Additional context

Our runner setup:

  • runner_worker_docker_machine_fleet is enabled
  • runner_worker_docker_machine_instance_spot is enabled
  • runner_worker is docker+machine

kovacslaszlonik avatar Jan 26 '24 12:01 kovacslaszlonik