From b48bc61052081f7a17ae234f8792a6fbad141162 Mon Sep 17 00:00:00 2001 From: Violet Hynes Date: Thu, 13 Jun 2024 10:25:53 -0400 Subject: [PATCH] VAULT-25456 CE side of changes for snapshot restore namespace cache bug (#27474) * VAULT-25456 CE side of changes for snapshot restore namespace cache bug * Changelog * Unexport function --- changelog/27474.txt | 3 +++ vault/namespaces_oss.go | 2 ++ vault/raft.go | 4 ++++ 3 files changed, 9 insertions(+) create mode 100644 changelog/27474.txt diff --git a/changelog/27474.txt b/changelog/27474.txt new file mode 100644 index 0000000000..86c773517a --- /dev/null +++ b/changelog/27474.txt @@ -0,0 +1,3 @@ +```release-note:bug +storage/raft (enterprise): Fix issue with namespace cache not getting cleared on snapshot restore, resulting in namespaces not found in the snapshot being inaccurately represented by API responses. +``` diff --git a/vault/namespaces_oss.go b/vault/namespaces_oss.go index 902bea712e..245af6d015 100644 --- a/vault/namespaces_oss.go +++ b/vault/namespaces_oss.go @@ -18,3 +18,5 @@ func (c *Core) NamespaceByID(ctx context.Context, nsID string) (*namespace.Names func (c *Core) ListNamespaces(includePath bool) []*namespace.Namespace { return []*namespace.Namespace{namespace.RootNamespace} } + +func (c *Core) resetNamespaceCache() {} diff --git a/vault/raft.go b/vault/raft.go index 2d5969896b..fcbc3eb300 100644 --- a/vault/raft.go +++ b/vault/raft.go @@ -850,6 +850,10 @@ func (c *Core) raftSnapshotRestoreCallback(grabLock bool, sealNode bool) func(co return err } + // Reset the namespace cache so that any namespaces cached + // before the snapshot restore will no longer be present. + c.resetNamespaceCache() + return nil } }