Skip to content

Commit

Permalink
Optimize revokeSalted by not calling view.List twice
Browse files Browse the repository at this point in the history
  • Loading branch information
calvn committed Apr 26, 2018
1 parent 6fc57a9 commit b2fad5d
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions vault/token_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -1214,9 +1214,16 @@ func (ts *TokenStore) revokeSalted(ctx context.Context, saltedID string) (ret er
return errwrap.Wrapf("failed to update child token: {{err}}", err)
}
lock.Unlock()
}
if err = logical.ClearView(ctx, ts.view.SubView(parentPath)); err != nil {
return errwrap.Wrapf("failed to delete entry: {{err}}", err)

// Delete the the child storage entry after we update the token entry Since
// paths are not deeply nested (i.e. they are simply
// parenPrefix/<parentID>/<childID>), we can simply call view.Delete instead
// of view.ClearView
index := parentPath + child
err = ts.view.Delete(ctx, index)
if err != nil {
return errwrap.Wrapf("failed to delete child entry: {{err}}", err)
}
}

// Now that the entry is not usable for any revocation tasks, nuke it
Expand Down

0 comments on commit b2fad5d

Please sign in to comment.