-
Notifications
You must be signed in to change notification settings - Fork 9.7k
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
backend/remote: Fix broken state lock retry #27845
backend/remote: Fix broken state lock retry #27845
Conversation
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 missing Info field, which the state manager requires to be present in order to attempt retries.
Codecov Report
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fixing this! 🙇♂️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
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.