mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-10-30 18:17:55 +00:00
Stub for namespace cache warming fix (#25688)
This commit is contained in:
@@ -659,6 +659,12 @@ func (c *Core) loadCredentials(ctx context.Context) error {
|
|||||||
}
|
}
|
||||||
entry.namespace = ns
|
entry.namespace = ns
|
||||||
|
|
||||||
|
// Subtle: in `loadMounts` there is a call to namespaceManager.Register in
|
||||||
|
// the equivalent place to here. It's non-obvious why that is needed (see
|
||||||
|
// the large comment there) but it's equally subtle why it better NOT to do
|
||||||
|
// the same here. For more rationale see
|
||||||
|
// https://github.com/hashicorp/vault-enterprise/pull/5437#issuecomment-1954434213.
|
||||||
|
|
||||||
// Sync values to the cache
|
// Sync values to the cache
|
||||||
entry.SyncCache()
|
entry.SyncCache()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1309,6 +1309,24 @@ func (c *Core) loadMounts(ctx context.Context) error {
|
|||||||
}
|
}
|
||||||
entry.namespace = ns
|
entry.namespace = ns
|
||||||
|
|
||||||
|
// Subtle/hacky: re-register ns with namespaceManager to ensure that in the
|
||||||
|
// case where duplicate namespaces existed due to historical race bugs, we
|
||||||
|
// still ensure the correct namespaces are the ones that "win" the path
|
||||||
|
// registrations. This became an issue when we added Core.warmNamespaceCache
|
||||||
|
// and subsequently discovered customers had latent corruption where there
|
||||||
|
// were multiple namespace IDs with the same path in the namespaces config
|
||||||
|
// entry and loading them into cache made it non-deterministic which one won
|
||||||
|
// the slot in the path index due to map iteration randomness. By explicitly
|
||||||
|
// re-registering them here we enforce the same consistent order of
|
||||||
|
// registration into the path index that we had before warming and so
|
||||||
|
// prevent any apparent regressions. Note that mount entries are a slice not
|
||||||
|
// a map so consistent even if we ever did allow duplicates to be stored. We
|
||||||
|
// want to fix all the root causes of those duplicates but also want to
|
||||||
|
// restore the previous behavior that masked them as a problem. They will
|
||||||
|
// likely be there for a long time to come as they are persistent now even
|
||||||
|
// if we find all the bugs that allowed it to get in that state.
|
||||||
|
NamespaceRegister(ctx, ns, c)
|
||||||
|
|
||||||
// Sync values to the cache
|
// Sync values to the cache
|
||||||
entry.SyncCache()
|
entry.SyncCache()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,3 +17,9 @@ func namespaceByID(ctx context.Context, nsID string, c *Core) (*namespace.Namesp
|
|||||||
}
|
}
|
||||||
return nil, namespace.ErrNoNamespace
|
return nil, namespace.ErrNoNamespace
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var NamespaceRegister func(context.Context, *namespace.Namespace, *Core) error = namespaceRegister
|
||||||
|
|
||||||
|
func namespaceRegister(ctx context.Context, ns *namespace.Namespace, c *Core) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user