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
Adds replication state helper to framework.Backend #21743
Conversation
// WriteSafeReplicationState returns true if this backend instance is capable of writing | ||
// to storage without receiving an ErrReadOnly error. The active instance in a primary | ||
// cluster or a local mount on a performance secondary is capable of writing to storage. | ||
func (b *Backend) WriteSafeReplicationState() bool { |
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.
We could also invert this to something like HasReadOnlyStorage()
. This PKI conditional backend.go#L454 is an example of what that could look like.
I'm open either way. Lmk your thoughts!
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.
I prefer WriteSafeReplicationState.
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! Thanks for doing this!
* Adds replication state helper to framework.Backend * Fix test * adds changelog
This PR adds a helper method to
framework.Backend
to DRY up some commonly repeated and easy to mess up replication state checking logic. The logic is used to prevent backends from attempting to write on a Vault instance with read-only storage.There are at least a few more backends where we can begin using this helper method. I've included a couple of plugin backends to show what the usage looks like. Follow-up PRs can be made after this is merged.