Skip to content

Commit

Permalink
(OSS Port) Restrict Quota Deletion to Primary Cluster [vault-2399] (#…
Browse files Browse the repository at this point in the history
…12339)

* oss part of vault 2399

* Update vault/quotas/quotas.go

Co-authored-by: Vishal Nayak <vishalnayak@users.noreply.github.com>

* use OSS PR number as changelog entry as indicated by the changelog guide

Co-authored-by: Vishal Nayak <vishalnayak@users.noreply.github.com>
  • Loading branch information
HridoyRoy and vishalnayak committed Aug 17, 2021
1 parent 9cc94fe commit 032aa5d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
3 changes: 3 additions & 0 deletions changelog/12339.txt
@@ -0,0 +1,3 @@
```release-note:bug
core (enterprise): Only delete quotas on primary cluster.
```
10 changes: 6 additions & 4 deletions vault/auth.go
Expand Up @@ -339,10 +339,12 @@ func (c *Core) disableCredentialInternal(ctx context.Context, path string, updat

removePathCheckers(c, entry, viewPath)

if c.quotaManager != nil {
if err := c.quotaManager.HandleBackendDisabling(ctx, ns.Path, path); err != nil {
c.logger.Error("failed to update quotas after disabling auth", "path", path, "error", err)
return err
if !c.IsPerfSecondary() {
if c.quotaManager != nil {
if err := c.quotaManager.HandleBackendDisabling(ctx, ns.Path, path); err != nil {
c.logger.Error("failed to update quotas after disabling auth", "path", path, "error", err)
return err
}
}
}

Expand Down
5 changes: 3 additions & 2 deletions vault/quotas/quotas.go
Expand Up @@ -765,7 +765,7 @@ func (m *Manager) Invalidate(key string) {
default:
splitKeys := strings.Split(key, "/")
if len(splitKeys) != 2 {
m.logger.Error("incorrect key while invalidating quota rule")
m.logger.Error("incorrect key while invalidating quota rule", "key", key)
return
}
qType := splitKeys[0]
Expand Down Expand Up @@ -987,7 +987,8 @@ func (m *Manager) HandleRemount(ctx context.Context, nsPath, fromPath, toPath st
}

// HandleBackendDisabling updates the quota subsystem with the disabling of auth
// or secret engine disabling.
// or secret engine disabling. This should only be called on the primary cluster
// node.
func (m *Manager) HandleBackendDisabling(ctx context.Context, nsPath, mountPath string) error {
m.lock.Lock()
defer m.lock.Unlock()
Expand Down

0 comments on commit 032aa5d

Please sign in to comment.