update kv plugin

This commit is contained in:
Brian Kassouf 2019-03-15 12:49:31 -07:00
parent c83564b57f
commit c38a7af05d
2 changed files with 18 additions and 6 deletions

View File

@ -18,6 +18,15 @@ import (
"github.com/hashicorp/vault/logical/framework" "github.com/hashicorp/vault/logical/framework"
) )
func (b *versionedKVBackend) perfSecondaryCheck() bool {
replState := b.System().ReplicationState()
if (!b.System().LocalMount() && replState.HasState(consts.ReplicationPerformanceSecondary)) ||
replState.HasState(consts.ReplicationPerformanceStandby) {
return true
}
return false
}
func (b *versionedKVBackend) upgradeCheck(next framework.OperationFunc) framework.OperationFunc { func (b *versionedKVBackend) upgradeCheck(next framework.OperationFunc) framework.OperationFunc {
return func(ctx context.Context, req *logical.Request, data *framework.FieldData) (*logical.Response, error) { return func(ctx context.Context, req *logical.Request, data *framework.FieldData) (*logical.Response, error) {
if atomic.LoadUint32(b.upgrading) == 1 { if atomic.LoadUint32(b.upgrading) == 1 {
@ -28,7 +37,11 @@ func (b *versionedKVBackend) upgradeCheck(next framework.OperationFunc) framewor
time.Sleep(15 * time.Millisecond) time.Sleep(15 * time.Millisecond)
if atomic.LoadUint32(b.upgrading) == 1 { if atomic.LoadUint32(b.upgrading) == 1 {
return logical.ErrorResponse("Upgrading from non-versioned to versioned data. This backend will be unavailable for a brief period and will resume service shortly."), logical.ErrInvalidRequest if b.perfSecondaryCheck() {
return logical.ErrorResponse("Waiting for the primary to upgrade from non-versioned to versioned data. This backend will be unavailable for a brief period and will resume service when the primary is finished."), logical.ErrInvalidRequest
} else {
return logical.ErrorResponse("Upgrading from non-versioned to versioned data. This backend will be unavailable for a brief period and will resume service shortly."), logical.ErrInvalidRequest
}
} }
} }
@ -74,8 +87,7 @@ func (b *versionedKVBackend) Upgrade(ctx context.Context, s logical.Storage) err
// If we are a replication secondary or performance standby, wait until the primary has finished // If we are a replication secondary or performance standby, wait until the primary has finished
// upgrading. // upgrading.
if (!b.System().LocalMount() && replState.HasState(consts.ReplicationPerformanceSecondary)) || if b.perfSecondaryCheck() {
replState.HasState(consts.ReplicationPerformanceStandby) {
b.Logger().Info("upgrade not running on performance replication secondary or performance standby") b.Logger().Info("upgrade not running on performance replication secondary or performance standby")
go func() { go func() {

6
vendor/vendor.json vendored
View File

@ -1481,10 +1481,10 @@
"revisionTime": "2019-01-16T16:49:38Z" "revisionTime": "2019-01-16T16:49:38Z"
}, },
{ {
"checksumSHA1": "z4IHCgxIAMCZls4JLY08wYe2wwU=", "checksumSHA1": "MW8Ju+DGO9JhWsRgL1bahDv2b2w=",
"path": "github.com/hashicorp/vault-plugin-secrets-kv", "path": "github.com/hashicorp/vault-plugin-secrets-kv",
"revision": "e0dca442917fcb1a060f942c19d0d6d87408ae7c", "revision": "dccffee64925e322daef806ae9df1aef002de225",
"revisionTime": "2019-03-15T18:52:46Z" "revisionTime": "2019-03-15T19:27:09Z"
}, },
{ {
"checksumSHA1": "ldkAQ1CpiAaQ9sti0qIch+UyRsI=", "checksumSHA1": "ldkAQ1CpiAaQ9sti0qIch+UyRsI=",