Hi CircleCI Support,
I’m reaching out regarding an issue where Terraform jobs don’t gracefully shut down after a new commit when the Auto-Cancel Redundant Workflows feature is enabled. This issue is causing problems with our Terraform state, as the jobs are being abruptly terminated before they have a chance to finalize the state properly.
To address this, I attempted to capture and handle the termination signals by using a signal trap in the pipeline to catch TERM
, KILL
, and other signals. Despite this, I’m unsure about the exact timing needed to allow Terraform to complete its cleanup and finalize the state before the job is canceled.
It seems that the default auto-cancel behavior may not give Terraform enough time to cleanly shut down, resulting in broken states. I would like to pass the necessary time for graceful shutdown directly into the steps themselves, allowing Terraform to handle the termination more effectively and avoid state corruption.
Could you assist us with this or provide guidance on how to better manage the shutdown process for Terraform within this new auto-cancel workflow configuration?