mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-10-30 18:17:55 +00:00
Check if storage should be updated during invalidation (#28059)
* check if storage should be updated during invalidation * add changelog * add other tests and fix for auth move * fix changelog * fix comment * remove ent tests --------- Co-authored-by: davidadeleon <56207066+davidadeleon@users.noreply.github.com>
This commit is contained in:
3
changelog/28059.txt
Normal file
3
changelog/28059.txt
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
```release-note:bug
|
||||||
|
command: The `vault secrets move` and `vault auth move` command will no longer attempt to write to storage on performance standby nodes.
|
||||||
|
```
|
||||||
@@ -485,15 +485,17 @@ func (c *Core) remountCredential(ctx context.Context, src, dst namespace.MountPa
|
|||||||
srcMatch.Path = strings.TrimPrefix(dst.MountPath, credentialRoutePrefix)
|
srcMatch.Path = strings.TrimPrefix(dst.MountPath, credentialRoutePrefix)
|
||||||
|
|
||||||
// Update the mount table
|
// Update the mount table
|
||||||
if err := c.persistAuth(ctx, c.auth, &srcMatch.Local); err != nil {
|
if updateStorage {
|
||||||
srcMatch.Path = srcPath
|
if err := c.persistAuth(ctx, c.auth, &srcMatch.Local); err != nil {
|
||||||
srcMatch.Tainted = true
|
srcMatch.Path = srcPath
|
||||||
c.authLock.Unlock()
|
srcMatch.Tainted = true
|
||||||
if err == logical.ErrReadOnly && c.perfStandby {
|
c.authLock.Unlock()
|
||||||
return err
|
if err == logical.ErrReadOnly && c.perfStandby {
|
||||||
}
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
return fmt.Errorf("failed to update auth table with error %+v", err)
|
return fmt.Errorf("failed to update auth table with error %+v", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remount the backend, setting the existing route entry
|
// Remount the backend, setting the existing route entry
|
||||||
|
|||||||
@@ -1189,15 +1189,17 @@ func (c *Core) remountSecretsEngine(ctx context.Context, src, dst namespace.Moun
|
|||||||
srcMatch.Path = dst.MountPath
|
srcMatch.Path = dst.MountPath
|
||||||
|
|
||||||
// Update the mount table
|
// Update the mount table
|
||||||
if err := c.persistMounts(ctx, c.mounts, &srcMatch.Local); err != nil {
|
if updateStorage {
|
||||||
srcMatch.Path = srcPath
|
if err := c.persistMounts(ctx, c.mounts, &srcMatch.Local); err != nil {
|
||||||
srcMatch.Tainted = true
|
srcMatch.Path = srcPath
|
||||||
c.mountsLock.Unlock()
|
srcMatch.Tainted = true
|
||||||
if err == logical.ErrReadOnly && c.perfStandby {
|
c.mountsLock.Unlock()
|
||||||
return err
|
if err == logical.ErrReadOnly && c.perfStandby {
|
||||||
}
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
return fmt.Errorf("failed to update mount table with error %+v", err)
|
return fmt.Errorf("failed to update mount table with error %+v", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remount the backend
|
// Remount the backend
|
||||||
|
|||||||
@@ -652,6 +652,23 @@ func GenerateRandBytes(length int) ([]byte, error) {
|
|||||||
return buf, nil
|
return buf, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestWaitPerfStandby(t testing.TB, core *Core) {
|
||||||
|
t.Helper()
|
||||||
|
start := time.Now()
|
||||||
|
var perfStandby bool
|
||||||
|
for time.Now().Sub(start) < 30*time.Second {
|
||||||
|
perfStandby = core.PerfStandby()
|
||||||
|
|
||||||
|
if perfStandby {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !perfStandby {
|
||||||
|
err := errors.New("core not in perf standby mode")
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestWaitActive(t testing.TB, core *Core) {
|
func TestWaitActive(t testing.TB, core *Core) {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
if err := TestWaitActiveWithError(core); err != nil {
|
if err := TestWaitActiveWithError(core); err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user