Hold a merge the controller cannot record now, and hand it over again, instead of taking it (issue 921)

This commit is contained in:
2026-10-17 12:03:00 +02:00
parent b0d489a86c
commit 379a52c2e8
4 changed files with 65 additions and 6 deletions
+13
View File
@@ -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)
}
}
+3 -3
View File
@@ -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