Skip to content
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

Merged
merged 4 commits into from Jul 11, 2023

Conversation

austingebauer
Copy link
Member

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.

@austingebauer austingebauer added this to the 1.15 milestone Jul 10, 2023
@austingebauer austingebauer requested a review from a team July 10, 2023 23:57
@github-actions github-actions bot added the hashicorp-contributed-pr If the PR is HashiCorp (i.e. not-community) contributed label Jul 10, 2023
// 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 {
Copy link
Member Author

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!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer WriteSafeReplicationState.

Copy link
Contributor

@fairclothjm fairclothjm left a 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!

@austingebauer austingebauer merged commit bf19846 into main Jul 11, 2023
99 checks passed
@austingebauer austingebauer deleted the replication-state-helper branch July 11, 2023 22:22
sebinjohn pushed a commit to sebinjohn/vault that referenced this pull request Aug 11, 2023
* Adds replication state helper to framework.Backend

* Fix test

* adds changelog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hashicorp-contributed-pr If the PR is HashiCorp (i.e. not-community) contributed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants