Backport of backend/remote: Fix broken state lock retry into v0.14 #27863
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Backport
This PR is auto-generated from #27845 to be assessed for backporting due to the inclusion of the label 0.14-backport.
The below text is copied from the body of the original PR.
When using the
-lock-timeout
option with the remote backend configured in local operations mode, Terraform would fail to retry acquiring the lock. This was caused by the lock error message having a missingInfo
field, which the state manager requires to be present in order to attempt retries:terraform/states/statemgr/locker.go
Lines 81 to 91 in 6871d0c
Other remote state storage backends attempt to fetch lock information to populate this field. Because the Terraform Cloud API doesn't really have any lock information exposed, we can't do that here, so we just round-trip the lock info we were passed in to make sure there's something non-nil in the
LockErr
.While I can't find anywhere to add test coverage for this, I've manually verified that this fixes the problem reported in #27844. Repro steps:
time_sleep
)terraform plan
: verify that it fails immediatelyterraform plan -lock-timeout=10s
: verify that it waits for 10s and then errorsterraform plan -lock-timeout=300s
: verify that it waits long enough for the apply to finish and then runsFixes #27844.