Hold a merge the controller cannot record now, and hand it over again, instead of taking it (issue 921)
This commit is contained in:
@@ -2,6 +2,8 @@ package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
@@ -220,3 +222,14 @@ func TestARetryWaitsOnlyForAnOpenWalkItIsRelatedTo(t *testing.T) {
|
||||
t.Error("an own-path retry went beside an open walk")
|
||||
}
|
||||
}
|
||||
|
||||
// Plans another controller is working are "not now", not a failure: the merge is held and handed over again
|
||||
// (issue 921).
|
||||
func TestPlansHeldByAnotherControllerAreNotNow(t *testing.T) {
|
||||
if err := notNow(fmt.Errorf("x: %w", inventory.ErrPlansBusy)); !errors.Is(err, link.ErrTryAgain) {
|
||||
t.Errorf("busy plans read as %v; want ErrTryAgain", err)
|
||||
}
|
||||
if err := notNow(errors.New("no such module")); errors.Is(err, link.ErrTryAgain) {
|
||||
t.Errorf("another failure read as ErrTryAgain: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -294,10 +294,10 @@ func (f following) Announceable(ctx context.Context) ([]link.Announcement, error
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// notNow marks a store that could not be read right now, so the announcement is held rather than
|
||||
// lost; anything else is returned as it was.
|
||||
// notNow marks a store that could not be read right now, or plans another controller is working (issue 921), so
|
||||
// the announcement is held rather than lost; anything else is returned as it was.
|
||||
func notNow(err error) error {
|
||||
if inventory.Unreachable(err) {
|
||||
if inventory.Unreachable(err) || errors.Is(err, inventory.ErrPlansBusy) {
|
||||
return fmt.Errorf("%w: %w", link.ErrTryAgain, err)
|
||||
}
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user