Raise netlink buffers for large batches; restore snapshot when try apply fails
This commit is contained in:
@@ -175,10 +175,28 @@ func Revert(id string) (reverted bool, err error) {
|
||||
if err != nil || p == nil || (id != "" && p.ID != id) {
|
||||
return false, err
|
||||
}
|
||||
if err := restore(p.Snapshot); err != nil {
|
||||
return false, fmt.Errorf("restoring snapshot: %w", err)
|
||||
return true, restorePending(p)
|
||||
}
|
||||
|
||||
// Abort restores the pending snapshot after a failed apply, which may have
|
||||
// committed partially. A failed restore keeps the snapshot and timer so the
|
||||
// timer still reverts. The caller must hold the lock.
|
||||
func Abort() error {
|
||||
p, err := load()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return true, Discard()
|
||||
if p == nil {
|
||||
return errors.New("no pending try to abort")
|
||||
}
|
||||
return restorePending(p)
|
||||
}
|
||||
|
||||
func restorePending(p *pending) error {
|
||||
if err := restore(p.Snapshot); err != nil {
|
||||
return fmt.Errorf("restoring snapshot: %w", err)
|
||||
}
|
||||
return Discard()
|
||||
}
|
||||
|
||||
func load() (*pending, error) {
|
||||
|
||||
Reference in New Issue
Block a user