Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Enable state locking for plan/apply/destroy/refresh/taint/untaint #11686
This enables the locking of state through the command UI.
This does change the behavior of 2 tests. Previously when running a plan with no existing state, the plan would be written out and then backed up on the next WriteState by another BackupState instance. Since we now maintain a single State instance throughout an operation, the backup happens before any state exists so no backup file is created. This shouldn't be a problem, as there really was nothing that required backing up. Now those tests will create the state file before running.
The lock/unlock terraform commands will be added in another PR. Only local state is supported so far, so the commands aren't yet required.
I think this is good. One thing I want to just leave as a note here but shouldn't block this merge: we should think through a UX if locking is taking awhile (for whatever reason, the network).
In Otto I had created a package that was basically "do this, but if it takes longer than N (time.Duration) then show this message". I think bringing that as a helper package here and using that for cases like this would be ideal. In the average case, state locking should be fast enough, if its taking longer than 100ms or something we should probably inform the user that we're trying to acquire a state lock. I could see some users
terraform <op> hanging and being curious why.