terragrunt icon indicating copy to clipboard operation
terragrunt copied to clipboard

Send ctrl+c one time but terragrunt send twice to terraform

Open baby3873575 opened this issue 2 years ago • 2 comments

Sorry that might be a stupid question. When I abort the apply when resource is being created via ctrl+c one time(want it to be gracefully shutdown), terragrunt send twice to terraform so there is no gracefully shutdown and result in state lock not being released and the hash value in the table would be mismatch even I run force-unlock. May I know is it the design or only my laptop encounter this issue.

^C
Interrupt received.
Please wait for Terraform to exit or data loss may occur.
Gracefully shutting down...


Two interrupts received. Exiting immediately. Note that data loss may have
occurred.

╷
│ Error: operation canceled

terragrunt version v0.37.1 Terraform v1.2.1 on darwin_amd64

  • provider registry.terraform.io/hashicorp/aws v4.15.1
  • provider registry.terraform.io/hashicorp/cloudinit v2.2.0
  • provider registry.terraform.io/hashicorp/kubernetes v2.11.0
  • provider registry.terraform.io/hashicorp/local v2.2.3
  • provider registry.terraform.io/hashicorp/tls v3.4.0

baby3873575 avatar May 24 '22 13:05 baby3873575

I've experienced the same issue several times.

terragrunt version v0.36.7 on linux

amkartashov avatar Jun 14 '22 12:06 amkartashov

I also experience this. terragrunt version 0.36.10, terraform version 1.1.9

I see this in both VS Code terminal and Windows terminal. I'm using zsh in both places, and the underlying system is Ubuntu 2004 on amd64.

spilliams avatar Jun 21 '22 00:06 spilliams

Terragrunt v0.39.0 Terraform v1.3.1 darwin_arm64

oatmealb avatar Nov 04 '22 06:11 oatmealb

Still happening for me. Terragrunt: v0.42.2 Terraform: v1.3.6 OSX: 12.6.1

cw0 avatar Dec 09 '22 18:12 cw0

Ctrl-C sends a SIGINT to all processes in the process group (terragrunt, terraform, etc), terragrunt's signal forwarding causes a second SIGINT to the child process: https://github.com/gruntwork-io/terragrunt/blob/c85212fe2dc1bfb524396d08caca69f9124057e8/shell/run_shell_cmd.go#L178-L198

kill -SIGINT $PID works as expected. (one SIGINT, forwarded by the terragrunt process)

https://unix.stackexchange.com/a/149756

mschfh avatar Mar 10 '23 11:03 mschfh

To workaround this issue, we leverage the terraform_binary configuration option to use a script that puts the Terraform invocation into a new process group. This prevents the Ctrl+C SIGINT from the terminal being sent to the Terraform command. Perhaps a similar behaviour is needed within the command exec invocation inside Terragrunt?

andyprinceuk avatar Apr 03 '23 14:04 andyprinceuk

Issue resolved in v0.45.11 release.

levkohimins avatar May 10 '23 21:05 levkohimins