Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove stale locks/Ability to add timeout to locks #25776

Open
abergmeier opened this issue Aug 7, 2020 · 5 comments
Open

Remove stale locks/Ability to add timeout to locks #25776

abergmeier opened this issue Aug 7, 2020 · 5 comments
Labels
enhancement new new issue not yet triaged

Comments

@abergmeier
Copy link

Terraform Version

0.12.28

Expected Behavior

There should be a mechanism to get rid of the Lock even if the Process dies suddenly.

Actual Behavior

Lock persists and nobody can use Terraform anymore. Developer needs to manually remove lock.
This is fine as long CI is stable - but gets really annoying if CI is terminating Terraform very frequently.

Steps to Reproduce

Kill -9 terraform when it it is planning.

Fix to this

The most elegant IMO would be to add a (optional) timeout option to backends. This way there could be a timeout set to 2 minutes. Terraform could then touch the lock every minute to ensure it does not time out.
If the Lock is present and older than 2 minutes, other Terraforms are allowed to remove it.

@abergmeier abergmeier added bug new new issue not yet triaged labels Aug 7, 2020
@abergmeier abergmeier changed the title Ability to add timeout to locks Remove stale locks/Ability to add timeout to locks Aug 7, 2020
@danieldreier
Copy link
Contributor

@abergmeier I think you're looking for the force-unlock command described in https://www.terraform.io/docs/commands/force-unlock.html - is that what you're looking for?

@danieldreier danieldreier added question waiting-response An issue/pull request is waiting for a response from the community and removed bug new new issue not yet triaged labels Aug 13, 2020
@danieldreier danieldreier self-assigned this Aug 13, 2020
@abergmeier
Copy link
Author

I think you're looking for the force-unlock command

One the contrary, I am looking for a mechanism to make force-unlock mostly unnecessary if the terraform machine is not that stable.

@ghost ghost removed the waiting-response An issue/pull request is waiting for a response from the community label Sep 6, 2020
@aweingarten
Copy link

This is a very real concern on our project too. We worry about an unstable provision infrastructure acquiring a lock dying and never releasing the lock.

Since we are using terraform as part of an existing automation workflow force-unlock would represent a support escalation.

For now we are planning to write a bash script that will delete a lock that exceeds n minutes before running apply. We would like this to be a first class capability.

@danieldreier danieldreier removed their assignment Oct 1, 2021
@Nadavpe
Copy link

Nadavpe commented Feb 7, 2022

We're facing similar issues, mostly when killing a github-action workflow, which happens every now and then.

The 2 minutes suggested above must be parametric, as some resources may have a longer response time, so it should be in the state's configuration, thus allowing admins to set the desired lock timeout.

@SathishKumarRamasamy
Copy link

+1
We would need this feature to avoid infinite locks when the process gets killed.

@crw crw added enhancement new new issue not yet triaged and removed question labels Aug 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement new new issue not yet triaged
Projects
None yet
Development

No branches or pull requests

6 participants