mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-03 20:17:59 +00:00
logical/framework: rollback should return error, easier API
This commit is contained in:
@@ -34,8 +34,7 @@ type Backend struct {
|
||||
Secrets []*Secret
|
||||
|
||||
// Rollback is called when a WAL entry (see wal.go) has to be rolled
|
||||
// back. It is called with the data from the entry. Boolean true should
|
||||
// be returned on success. Errors should just be logged.
|
||||
// back. It is called with the data from the entry.
|
||||
//
|
||||
// RollbackMinAge is the minimum age of a WAL entry before it is attempted
|
||||
// to be rolled back. This should be longer than the maximum time it takes
|
||||
@@ -51,7 +50,7 @@ type Backend struct {
|
||||
type OperationFunc func(*logical.Request, *FieldData) (*logical.Response, error)
|
||||
|
||||
// RollbackFunc is the callback for rollbacks.
|
||||
type RollbackFunc func(*logical.Request, string, interface{}) bool
|
||||
type RollbackFunc func(*logical.Request, string, interface{}) error
|
||||
|
||||
// logical.Backend impl.
|
||||
func (b *Backend) HandleRequest(req *logical.Request) (*logical.Response, error) {
|
||||
@@ -242,10 +241,16 @@ func (b *Backend) handleRollback(
|
||||
}
|
||||
|
||||
// Attempt a rollback
|
||||
if b.Rollback(req, entry.Kind, entry.Data) {
|
||||
if err := DeleteWAL(req.Storage, k); err != nil {
|
||||
merr = multierror.Append(merr, err)
|
||||
}
|
||||
err = b.Rollback(req, entry.Kind, entry.Data)
|
||||
if err != nil {
|
||||
err = fmt.Errorf(
|
||||
"Error rolling back '%s' entry: %s", entry.Kind, err)
|
||||
}
|
||||
if err == nil {
|
||||
err = DeleteWAL(req.Storage, k)
|
||||
}
|
||||
if err != nil {
|
||||
merr = multierror.Append(merr, err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user