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

Backport 1.3.x: Guard against using Raft as a seperate HA Storage #8356

Merged
merged 1 commit into from
Feb 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions command/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -1073,6 +1073,12 @@ func (c *ServerCommand) Run(args []string) int {
// Initialize the separate HA storage backend, if it exists
var ok bool
if config.HAStorage != nil {
// TODO: Remove when Raft can server as the ha_storage backend.
// See https://github.com/hashicorp/vault/issues/8206
if config.HAStorage.Type == "raft" {
c.UI.Error("Raft cannot be used as seperate HA storage at this time")
return 1
}
factory, exists := c.PhysicalBackends[config.HAStorage.Type]
if !exists {
c.UI.Error(fmt.Sprintf("Unknown HA storage type %s", config.HAStorage.Type))
Expand Down
7 changes: 7 additions & 0 deletions physical/raft/raft.go
Original file line number Diff line number Diff line change
Expand Up @@ -963,6 +963,13 @@ func (l *RaftLock) Lock(stopCh <-chan struct{}) (<-chan struct{}, error) {
// Cache the notifyCh locally
leaderNotifyCh := l.b.raftNotifyCh

// TODO: Remove when Raft can server as the ha_storage backend. The internal
// raft pointer should not be nil here, but the nil check is a guard against
// https://github.com/hashicorp/vault/issues/8206
if l.b.raft == nil {
return nil, errors.New("attempted to grab a lock on a nil raft backend")
}

// Check to see if we are already leader.
if l.b.raft.State() == raft.Leader {
err := l.b.applyLog(context.Background(), &LogData{
Expand Down
8 changes: 7 additions & 1 deletion website/source/docs/configuration/storage/raft.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,13 @@ storage "raft" {
cluster_addr = "http://127.0.0.1:8201"
```

**Note:** When using the Raft storage backend, it is required to provide `cluster_addr` to indicate the address and port to be used for communication between the nodes in the Raft cluster.
~> **Note:** When using the Raft storage backend, it is required to provide
`cluster_addr` to indicate the address and port to be used for communication
between the nodes in the Raft cluster.

~> **Note:** Raft cannot be used as the configured `ha_storage` backend at this
time. To use Raft for HA coordination users must also use Raft for storage and
set `ha_enabled = true`.

## `raft` Parameters

Expand Down