-
Notifications
You must be signed in to change notification settings - Fork 910
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
Add force-lock command #1124
Comments
Hey @jjshanks thank you for this RFC. There are some concerns around the ability to hold a lock with OpenTofu exiting on backends, such as Consul as documented here. Could you expand your RFC and address how this would work with regards to specific backends? |
Thanks for the link @janosdebugs. To summarize the other discussions the potential options are
I don't have any experience using backends that aren't s3/dynamo so I'm not sure I'm the best person to say how other backends should behave. But my gut reaction would be to give an error for anything that needs to keep running for the lock, because users of those backends already don't use I'll update the RFC to reflect the above for now until there is more feedback. |
The current API for locking is the Right now that doesn't have any way to distinguish between a lock that can safely be dropped automatically when the process exits vs. a lock that must survive beyond the end of the current process (or return an error if that's not possible). It seems like the smallest change to the existing API would be to extend It's a awkward that the default behavior for an unmodified backend would be to disregard the new hint field and acquire a useless lock that will immediately be dropped, but thankfully since we have all of the backends in-tree right now we can make sure they all get updated to support the new hint field (if needed) as part of the same PR. This is perhaps an example of something that would be a little harder if we waited until after #382, because we'd no longer be able to update all existing backends to support this new capability. (Though I think we could still do it, just that we'd need to take a different API design strategy such as having |
Cross-posting to share the knowledge once
|
@klongmitre tagging you here, this is the issue we've discussed at KubeCon recently. If you are interested in this feature, please make sure to upvote the original issue, as we rely on the upvotes to determine community demand |
Summary
This proposal is to add a new force-lock command.
Problem Statement
There is no way to manually lock a state via the CLI, only unlock one.
User-facing description
Usage would be similar to
force-unlock
except it wouldn't take a lock id it would return oneTechnical Description
force-lock
which will be just likeforce-unlock
except it won't take a lock id and will callLock()
instead ofUnlock()
on the state managerRationale and alternatives
Teams can have multiple reasons to want to lock state such as deployment freezes and refactoring.
Currently the only way to lock state is either editing the metadata of the state file by hand or using a utility like https://github.com/minamijoyo/tflock
An implementation over a subset of backends meets a need from the community. Expanding to other backends can be delayed until users of those backends request it.
Downsides
Unresolved Questions
If a state is already locked should an error be returned or just return the existing lock id?
Related Issues
No response
Proof of Concept
No response
The text was updated successfully, but these errors were encountered: