activator: R1 fence review fixes (sentinels, worker backoff, barriers)
Review round 1 of T1 (Astra and Fable). - The unreadable, missing, retired and no-reader refusals of the unlabelled fence now wrap errRouteChangedUnderLease as well as errRecordUnreadUnderLease, as binding R1 requires. - A worker start refused by the unlabelled-row fence backs off like a crash without counting one: wk.backoff doubles from sidecarRestartBase to sidecarRestartMax, with no exit noted, no event and no crash loop. Each start still reads the record once; refusals of labelled copies keep their pacing. TestWorkerUnlabelledFenceBacksOff drives 200 ticks on the test clock and checks the reads follow the curve, not one every 2 s. - The worker witnesses wait on wk.startDone instead of polling, assert exactly one read and check the refusal reason. - The other fence witnesses assert exactly one read, and errUnlabelledRecordLabelled where the record is labelled. - FleetWakeMode docs describe the R1 fence.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
internal/activator/pendingwake_linux_test.go+183 −48internal/activator/rootfsworkers.go+21 −0internal/activator/wakeidentity.go+24 −6
Intent
<task-notification> <task-id>ac1b40faeaa034e33</task-id> <tool-use-id>toolu_014oBGTkPfDFjPcMpwBzNL6B</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/ac77363b-5830-422c-9f38-d7f2540dd398/tasks/ac1b40faeaa034e33.output</output-file> <status>completed</status> <summary>Agent "Implement Task 1: R1 wake fence" finished</summary> <note>A task-notification fires each time this agent stops with no live background children of its own. The user can send it another message and resume it, so the same task-id may notify more than once.</note> <result>Status: DONE_WITH_CONCERNS Commit: c8b6eb49 activator: fence stale unlabelled fleet wakes under the lease (R1) Tests: the brief's Step 4 activator command passes (20 top-level tests, all 11 new ones included), as do the host fleet-wake tests and a darwin build of the changed packages. Two existing tests now expect the fence: `TestLabelledWakeReadsTheRecordOnce` (unlabelled case expects 1 read, not 0) and `TestInvalidFleetIdentityRefusesLabelledWakes` (unlabelled case is now refused). Concerns: 1. **Worker gate widened.** `rootfsworkers.go` only called the shared check when `FleetBoxes != ""`, so an unlabelled row never reached it. The condition is now `g.Stateless && (FleetBoxes != "" || unlabelledFleetRow(rt))`. Stateful workers are still not rechecked when they start. 2. **Production change.** Every unlabelled fleet-placed wake on a fleet box now makes one record GET. Such a row with no record now refuses to wake. 3. **New error text not from the brief:** "it names box…", "it has a copy assignment", "it is gone or retired". These need the copy deck if they count as human text. 4. **Brief's host command matches nothing.** `-run 'TestAgent.*Fleet'` matches no test, so I also ran `TestFleetWakeForTheBoxEnvironment`, which is the one I changed. 5. **Darwin vet fails on HEAD already.** `GOOS=darwin go vet ./internal/host` fails on `claimsOffEnv`; this commit didn't cause it. Report: /home/paulca/amadan.net/carlos/platform/.claude/worktrees/design-fleet-record-labels/.superpowers/sdd/2026-11-14-fleet-record-labels/task-1-report.md</result> <usage><subagent_tokens>162810</subagent_tokens><tool_uses>51</tool_uses><duration_ms>669482</duration_ms></usage> </task-notification>
<task-notification> <task-id>buuwaifti</task-id> <tool-use-id>toolu_01Nv9ftGbDbH4RQz6ccP4CiT</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/ac77363b-5830-422c-9f38-d7f2540dd398/tasks/buuwaifti.output</output-file> <status>completed</status> <summary>Background command "Run Astra and Fable T1 reviews in parallel" completed (exit code 0)</summary> </task-notification>
Attributed to this commit: 7.57 g CO₂e (891,584 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on design-fleet-record-labels, never backward from it. A turn that produced more than one commit books all of its tokens to the last one, and a concurrent session on this branch can add to the same figure. Some of it was priced using the shared default rate, because no model-specific factor row exists yet for at least one model involved. The Carbon view has the repo total, which is never derived from this attribution.
diff --git a/internal/activator/pendingwake_linux_test.go b/internal/activator/pendingwake_linux_test.go| index a8c6d097a..dd0c87725 100644 |
| --- a/internal/activator/pendingwake_linux_test.go |
| +++ b/internal/activator/pendingwake_linux_test.go |
| @@ -10,6 +10,7 @@ import ( |
| "io" |
| "os" |
| "path/filepath" |
| + "slices" |
| "strings" |
| "sync" |
| "sync/atomic" |
| @@ -805,12 +806,15 @@ func (r *unlabelledRig) starts() int { |
| return r.box.starts |
| } |
| -// assertRefused checks a refused wake: the error wraps want, the lease is |
| -// free, nothing was restored or started, and A's copy is as it was. |
| -func (r *unlabelledRig) assertRefused(t *testing.T, err, want error) { |
| +// assertRefused checks a refused wake: the error wraps every want, the |
| +// lease is free, nothing was restored or started, and A's copy is as it |
| +// was. |
| +func (r *unlabelledRig) assertRefused(t *testing.T, err error, want ...error) { |
| t.Helper() |
| - if !errors.Is(err, want) { |
| - t.Fatalf("wake err = %v, want %v", err, want) |
| + for _, w := range want { |
| + if !errors.Is(err, w) { |
| + t.Fatalf("wake err = %v, want it to wrap %v", err, w) |
| + } |
| } |
| if h := r.lock.heldBy(); h != "" { |
| t.Fatalf("the refused wake left the lease held by %s", h) |
| @@ -871,8 +875,12 @@ func TestUnlabelledStaleWakeRefusedWhenRecordNamesAnotherBox(t *testing.T) { |
| // must wake on the labelled path once it has. |
| func TestUnlabelledWakeRefusedWhenRecordLabelledToThisBox(t *testing.T) { |
| r := newUnlabelledRig(t) |
| - asFleetBox(r.a, "pi-1", unlabelledStore(t, "pi-1")) |
| - r.assertRefused(t, r.wake(r.a), errRouteChangedUnderLease) |
| + store := unlabelledStore(t, "pi-1") |
| + asFleetBox(r.a, "pi-1", store) |
| + r.assertRefused(t, r.wake(r.a), errRouteChangedUnderLease, errUnlabelledRecordLabelled) |
| + if n := store.gets.Load(); n != 1 { |
| + t.Fatalf("the wake read the record %d times, want 1", n) |
| + } |
| } |
| func TestUnlabelledWakeRefusedWhenRecordHasAssignment(t *testing.T) { |
| @@ -903,7 +911,7 @@ func TestUnlabelledWakeRefusedWhenRecordUnreadable(t *testing.T) { |
| r := newUnlabelledRig(t) |
| var reads atomic.Int64 |
| r.a.Fleet = FleetWake{Mode: FleetWakeCheck, Fleet: "pi", Label: "pi-1", Record: staticRecord(&reads, tc.rec, tc.err)} |
| - r.assertRefused(t, r.wake(r.a), errRecordUnreadUnderLease) |
| + r.assertRefused(t, r.wake(r.a), errRouteChangedUnderLease, errRecordUnreadUnderLease) |
| if n := reads.Load(); n != 1 { |
| t.Fatalf("the wake read the record %d times, want 1", n) |
| } |
| @@ -912,7 +920,7 @@ func TestUnlabelledWakeRefusedWhenRecordUnreadable(t *testing.T) { |
| t.Run("no reader", func(t *testing.T) { |
| r := newUnlabelledRig(t) |
| r.a.Fleet = FleetWake{Mode: FleetWakeCheck, Fleet: "pi", Label: "pi-1"} |
| - r.assertRefused(t, r.wake(r.a), errRecordUnreadUnderLease) |
| + r.assertRefused(t, r.wake(r.a), errRouteChangedUnderLease, errRecordUnreadUnderLease) |
| }) |
| } |
| @@ -931,6 +939,7 @@ func TestUnlabelledWakeFencedWhenLabelledWhileWaitingForTheLease(t *testing.T) { |
| t.Fatal("A's wake never reached its lease") |
| } |
| moveRecord(t, store, "", "pi-2", assignB) |
| + store.gets.Store(0) // the move's own read |
| close(r.box.gate) |
| var err error |
| select { |
| @@ -938,7 +947,10 @@ func TestUnlabelledWakeFencedWhenLabelledWhileWaitingForTheLease(t *testing.T) { |
| case <-time.After(10 * time.Second): |
| t.Fatal("A's wake never finished") |
| } |
| - r.assertRefused(t, err, errRouteChangedUnderLease) |
| + r.assertRefused(t, err, errRouteChangedUnderLease, errUnlabelledRecordLabelled) |
| + if n := store.gets.Load(); n != 1 { |
| + t.Fatalf("the wake read the record %d times, want 1", n) |
| + } |
| } |
| // An agent restart forgets everything in memory: a fresh Service over A's |
| @@ -975,7 +987,11 @@ func TestFenceHoldsAfterAgentRestartBeforeReconcile(t *testing.T) { |
| r.box.starts = 0 |
| r.box.fakeBackend.mu.Unlock() |
| r.restores.Store(0) |
| - r.assertRefused(t, r.wake(restarted), errRouteChangedUnderLease) |
| + store.gets.Store(0) // the first wake's and the move's reads |
| + r.assertRefused(t, r.wake(restarted), errRouteChangedUnderLease, errUnlabelledRecordLabelled) |
| + if n := store.gets.Load(); n != 1 { |
| + t.Fatalf("the restarted wake read the record %d times, want 1", n) |
| + } |
| } |
| // The request budget on the pass-through path: an unlabelled record wakes |
| @@ -1084,53 +1100,172 @@ func TestStatelessUnlabelledWakeFenced(t *testing.T) { |
| } |
| } |
| +// workerErrBackend is the stateless wake backend whose worker launches |
| +// keep their last error: the refusal reason. |
| +type workerErrBackend struct { |
| + *statelessWakeBackend |
| + mu sync.Mutex |
| + lastErr error |
| +} |
| + |
| +func (b *workerErrBackend) LaunchRootfsWorker(ctx context.Context, rt registry.Route, name string, g Gen, p Proc) (Proc, error) { |
| + proc, err := b.statelessWakeBackend.LaunchRootfsWorker(ctx, rt, name, g, p) |
| + b.mu.Lock() |
| + b.lastErr = err |
| + b.mu.Unlock() |
| + return proc, err |
| +} |
| + |
| +func (b *workerErrBackend) err() error { |
| + b.mu.Lock() |
| + defer b.mu.Unlock() |
| + return b.lastErr |
| +} |
| + |
| +// unlabelledWorkerRig is a stateless unlabelled fleet row, awake, with one |
| +// declared worker ("jobs") not yet started. labelled switches its record |
| +// to name box b; reads counts record reads after the wake, each stamped |
| +// with the rig's clock. |
| +type unlabelledWorkerRig struct { |
| + *wakeRelRig |
| + workers *fakeWorkerBackend |
| + backend *workerErrBackend |
| + labelled atomic.Bool |
| + mu sync.Mutex |
| + readAt []time.Time |
| +} |
| + |
| +func newUnlabelledWorkerRig(t *testing.T) *unlabelledWorkerRig { |
| + t.Helper() |
| + r := &unlabelledWorkerRig{wakeRelRig: newWakeRelRig(t)} |
| + store := wireStatelessRig(r.wakeRelRig) |
| + r.rt.CreatedAt = 1 |
| + r.rt.Region = "fleet/pi" |
| + r.rt.Stateless = true |
| + r.routes.set(r.rt) |
| + r.workers = &fakeWorkerBackend{killBackend: &killBackend{fakeBackend: r.b.fakeBackend}} |
| + r.backend = &workerErrBackend{statelessWakeBackend: &statelessWakeBackend{r.b, r.workers}} |
| + r.a.backend = r.backend |
| + r.b.procs["v2"] = map[string]release.Process{release.ProcessWeb: {Command: []string{"serve"}}, "jobs": {Command: []string{"jobs"}}} |
| + r.a.Fleet = FleetWake{Mode: FleetWakeCheck, Fleet: "pi", Label: "a", Record: func(context.Context, registry.Route) (*provision.Record, error) { |
| + r.mu.Lock() |
| + r.readAt = append(r.readAt, r.clk.now()) |
| + r.mu.Unlock() |
| + rec := &provision.Record{Account: r.rt.Account, App: r.rt.App, Host: r.rt.Host, CreatedAt: time.Unix(1, 0), Runtime: r.rt.Runtime, Channel: r.rt.Channel, Environment: r.rt.Environment, Region: r.rt.Region, ReplicaDeploy: store.snapshot()} |
| + if r.labelled.Load() { |
| + rec.FleetBox, rec.FleetBoxAt = "b", assignB |
| + } |
| + return rec, nil |
| + }} |
| + if err := waitErr(t, r.wake(r.a)); err != nil { |
| + t.Fatal(err) |
| + } |
| + r.mu.Lock() |
| + r.readAt = nil |
| + r.mu.Unlock() |
| + return r |
| +} |
| + |
| +func (r *unlabelledWorkerRig) reads() []time.Time { |
| + r.mu.Lock() |
| + defer r.mu.Unlock() |
| + return slices.Clone(r.readAt) |
| +} |
| + |
| +// tick runs one resident tick and waits for any worker start it began |
| +// to finish (wk.startDone), so its outcome is settled before the caller |
| +// looks. It reports whether a start ran. |
| +func (r *unlabelledWorkerRig) tick(t *testing.T) bool { |
| + t.Helper() |
| + r.a.rootfsTick() |
| + r.a.mu.Lock() |
| + wk := r.a.entries[r.rt.Host].rootfsWorkers["jobs"] |
| + starting, done := wk.starting, wk.startDone |
| + r.a.mu.Unlock() |
| + if !starting { |
| + return false |
| + } |
| + select { |
| + case <-done: |
| + case <-time.After(10 * time.Second): |
| + t.Fatal("the worker start never finished") |
| + } |
| + return true |
| +} |
| + |
| // A declared worker's start (runWorkerStart's gate) on an unlabelled |
| // stateless fleet row reads the record through the same fence: labelled |
| -// since the wake, the worker is refused. |
| +// since the wake, the worker is refused by the fence, after one read, and |
| +// that refusal is no crash. |
| func TestWorkerUnlabelledWakeFenced(t *testing.T) { |
| for _, labelled := range []bool{true, false} { |
| t.Run(fmt.Sprint(labelled), func(t *testing.T) { |
| - r := newWakeRelRig(t) |
| - store := wireStatelessRig(r) |
| - r.rt.CreatedAt = 1 |
| - r.rt.Region = "fleet/pi" |
| - r.rt.Stateless = true |
| - r.routes.set(r.rt) |
| - workers := &fakeWorkerBackend{killBackend: &killBackend{fakeBackend: r.b.fakeBackend}} |
| - r.a.backend = &statelessWakeBackend{r.b, workers} |
| - r.b.procs["v2"] = map[string]release.Process{release.ProcessWeb: {Command: []string{"serve"}}, "jobs": {Command: []string{"jobs"}}} |
| - var label atomic.Bool |
| - var reads atomic.Int32 |
| - r.a.Fleet = FleetWake{Mode: FleetWakeCheck, Fleet: "pi", Label: "a", Record: func(context.Context, registry.Route) (*provision.Record, error) { |
| - reads.Add(1) |
| - rec := &provision.Record{Account: r.rt.Account, App: r.rt.App, Host: r.rt.Host, CreatedAt: time.Unix(1, 0), Runtime: r.rt.Runtime, Channel: r.rt.Channel, Environment: r.rt.Environment, Region: r.rt.Region, ReplicaDeploy: store.snapshot()} |
| - if label.Load() { |
| - rec.FleetBox, rec.FleetBoxAt = "b", assignB |
| - } |
| - return rec, nil |
| - }} |
| - if err := waitErr(t, r.wake(r.a)); err != nil { |
| - t.Fatal(err) |
| + r := newUnlabelledWorkerRig(t) |
| + r.labelled.Store(labelled) |
| + if !r.tick(t) { |
| + t.Fatal("the tick began no worker start") |
| + } |
| + if n := len(r.reads()); n != 1 { |
| + t.Fatalf("the worker start read the record %d times, want 1", n) |
| } |
| - reads.Store(0) |
| - label.Store(labelled) |
| - r.a.rootfsTick() |
| if !labelled { |
| - waitFor(t, "unlabelled worker", func() bool { return workers.alive() == 1 }) |
| - } else { |
| - waitFor(t, "labelled worker refused", func() bool { |
| - r.a.mu.Lock() |
| - defer r.a.mu.Unlock() |
| - wk := r.a.entries[r.rt.Host].rootfsWorkers["jobs"] |
| - return reads.Load() > 0 && !wk.starting |
| - }) |
| - if workers.alive() != 0 || len(workers.stampsOf("start jobs gen1")) != 0 { |
| - t.Fatal("a worker started on a row whose record names another box") |
| + if err := r.backend.err(); err != nil || r.workers.alive() != 1 { |
| + t.Fatalf("unlabelled record: err %v, %d alive; want the worker started", err, r.workers.alive()) |
| } |
| + return |
| + } |
| + err := r.backend.err() |
| + if !errors.Is(err, errRouteChangedUnderLease) || !errors.Is(err, errUnlabelledRecordLabelled) { |
| + t.Fatalf("refusal = %v, want the R1 fence", err) |
| + } |
| + if r.workers.alive() != 0 || len(r.workers.stampsOf("start jobs gen1")) != 0 { |
| + t.Fatal("a worker started on a row whose record names another box") |
| } |
| - if reads.Load() == 0 { |
| - t.Fatal("the worker start did not read the record") |
| + r.a.mu.Lock() |
| + wk := r.a.entries[r.rt.Host].rootfsWorkers["jobs"] |
| + restarts, crashLoop, backoff := wk.restarts, wk.crashLoop, wk.backoff |
| + r.a.mu.Unlock() |
| + if restarts != 0 || crashLoop || backoff != sidecarRestartBase { |
| + t.Fatalf("restarts %d, crash loop %v, backoff %s; want no crash noted and the base backoff", restarts, crashLoop, backoff) |
| } |
| }) |
| } |
| } |
| + |
| +// The request budget of a fenced worker: each start reads the record |
| +// once, and a refused one backs off like a crash (2 s doubling to 60 s) |
| +// without counting one, so ticks every second read on that curve, not |
| +// every 2 s. The test clock drives every tick. |
| +func TestWorkerUnlabelledFenceBacksOff(t *testing.T) { |
| + r := newUnlabelledWorkerRig(t) |
| + r.labelled.Store(true) |
| + start := r.clk.now() |
| + for range 200 { |
| + r.tick(t) |
| + r.clk.advance(time.Second) |
| + } |
| + var got []time.Duration |
| + for _, at := range r.reads() { |
| + got = append(got, at.Sub(start)) |
| + } |
| + var want []time.Duration |
| + for at, wait := time.Duration(0), sidecarRestartBase; at < 200*time.Second; at += wait { |
| + want = append(want, at) |
| + if at > 0 { |
| + wait = min(wait*2, sidecarRestartMax) |
| + } |
| + } |
| + if !slices.Equal(got, want) { |
| + t.Fatalf("record reads at %v, want %v", got, want) |
| + } |
| + r.a.mu.Lock() |
| + wk := r.a.entries[r.rt.Host].rootfsWorkers["jobs"] |
| + restarts, crashLoop, backoff := wk.restarts, wk.crashLoop, wk.backoff |
| + r.a.mu.Unlock() |
| + if restarts != 0 || crashLoop || backoff != sidecarRestartMax { |
| + t.Fatalf("restarts %d, crash loop %v, backoff %s; want no crash and the backoff at its cap", restarts, crashLoop, backoff) |
| + } |
| + if r.workers.alive() != 0 { |
| + t.Fatal("a fenced worker started") |
| + } |
| +} |
diff --git a/internal/activator/rootfsworkers.go b/internal/activator/rootfsworkers.go| index 3cbd8d4ff..600207d8b 100644 |
| --- a/internal/activator/rootfsworkers.go |
| +++ b/internal/activator/rootfsworkers.go |
| @@ -32,6 +32,7 @@ import ( |
| "strconv" |
| "strings" |
| "sync" |
| + "sync/atomic" |
| "time" |
| "github.com/carlosframework/platform/internal/instancectl" |
| @@ -423,6 +424,9 @@ func (a *Service) runWorkerStart(ctx context.Context, wb RootfsWorkerBackend, e |
| installed, refused bool |
| stray bool |
| started Proc // a handle root returned and that was not installed |
| + // fenced: the gate's refusal was the unlabelled-row fence (R1). |
| + // It is set by the gate, which may run off this goroutine. |
| + fenced atomic.Bool |
| ) |
| defer func() { |
| a.mu.Lock() |
| @@ -430,6 +434,20 @@ func (a *Service) runWorkerStart(ctx context.Context, wb RootfsWorkerBackend, e |
| switch { |
| case installed: |
| wk.started, wk.retryAt, wk.startFailed, wk.pending = now, time.Time{}, false, false |
| + case refused && fenced.Load(): |
| + // The unlabelled-row fence (R1) refused: the record names a |
| + // box, has copies, or cannot be read, and each start reads it |
| + // again. Not a crash (no exit noted, no event, no crash loop), |
| + // but paced like one, so a refused worker does not read the |
| + // record on every tick: the backoff doubles from |
| + // sidecarRestartBase to sidecarRestartMax. |
| + wk.startFailed = true |
| + if wk.backoff == 0 { |
| + wk.backoff = sidecarRestartBase |
| + } else { |
| + wk.backoff = min(wk.backoff*2, sidecarRestartMax) |
| + } |
| + wk.retryAt = now.Add(wk.backoff) |
| case refused: |
| // Not a crash: the exit is treated as noted, and the start is |
| // asked again after the current backoff. |
| @@ -478,6 +496,9 @@ func (a *Service) runWorkerStart(ctx context.Context, wb RootfsWorkerBackend, e |
| return err |
| } |
| if err := a.routeCurrentUnderLease(ctx, rt, false); err != nil { |
| + if unlabelledFleetRow(rt) && unlabelledFenceRefusal(err) { |
| + fenced.Store(true) |
| + } |
| return err |
| } |
| return localGate() |
diff --git a/internal/activator/wakeidentity.go b/internal/activator/wakeidentity.go| index 2959d9132..8f68f42f2 100644 |
| --- a/internal/activator/wakeidentity.go |
| +++ b/internal/activator/wakeidentity.go |
| @@ -144,15 +144,21 @@ var errUnlabelledRecordLabelled = errors.New("the record is tied to a box, but t |
| type FleetWakeMode int |
| const ( |
| - // FleetWakeNone: the box is not on a fleet. No record is read and no |
| - // labelled wake is refused for it. |
| + // FleetWakeNone: the box is not on a fleet. No record is read: no |
| + // labelled wake is refused for it, and an unlabelled fleet-placed wake |
| + // is not fenced (R1). |
| FleetWakeNone FleetWakeMode = iota |
| // FleetWakeCheck: the box is on a fleet and knows its label. A labelled |
| // wake reads its record once, which must name the box at rt.Assigned. |
| + // An unlabelled fleet-placed wake reads its record once too, which |
| + // must still be unlabelled with no copies (the R1 fence, |
| + // unlabelledFleetFence). |
| FleetWakeCheck |
| // FleetWakeUnknown: the box is on a fleet (CARLOS_FLEET set, or its |
| // region is a fleet placement) but its fleet identity is invalid. Every |
| - // labelled wake is refused, naming the identity error. |
| + // labelled wake is refused, naming the identity error. An unlabelled |
| + // fleet-placed wake is fenced by its record as on FleetWakeCheck (R1, |
| + // failing closed): the fence needs no label of the box's own. |
| FleetWakeUnknown |
| ) |
| @@ -308,6 +314,10 @@ func unlabelledFleetRow(rt registry.Route) bool { |
| // - carries a ReplicaAssignment; |
| // - is retired, missing or unreadable (errRecordUnreadUnderLease). |
| // |
| +// Every refusal wraps errRouteChangedUnderLease, the unreadable ones |
| +// errRecordUnreadUnderLease as well (unlabelledFenceRefusal tells them |
| +// from other refusals). |
| +// |
| // A box not on a fleet (FleetWakeNone), or a row not placed on one, reads |
| // nothing. nil means the wake goes on as before. |
| func (a *Service) unlabelledFleetFence(ctx context.Context, rt registry.Route) error { |
| @@ -315,14 +325,14 @@ func (a *Service) unlabelledFleetFence(ctx context.Context, rt registry.Route) e |
| return nil |
| } |
| if a.Fleet.Record == nil { |
| - return fmt.Errorf("%s: refusing to wake: %w: %v", rt.Host, errRecordUnreadUnderLease, errNoRecordStore) |
| + return fmt.Errorf("%s: refusing to wake: %w: %w: %v", rt.Host, errRouteChangedUnderLease, errRecordUnreadUnderLease, errNoRecordStore) |
| } |
| rec, err := a.Fleet.Record(ctx, rt) |
| if err != nil { |
| - return fmt.Errorf("%s: refusing to wake: %w: %v", rt.Host, errRecordUnreadUnderLease, err) |
| + return fmt.Errorf("%s: refusing to wake: %w: %w: %v", rt.Host, errRouteChangedUnderLease, errRecordUnreadUnderLease, err) |
| } |
| if rec == nil || rec.Retired { |
| - return fmt.Errorf("%s: refusing to wake: %w: it is gone or retired", rt.Host, errRecordUnreadUnderLease) |
| + return fmt.Errorf("%s: refusing to wake: %w: %w: it is gone or retired", rt.Host, errRouteChangedUnderLease, errRecordUnreadUnderLease) |
| } |
| switch { |
| case rec.FleetBox != "": |
| @@ -335,6 +345,14 @@ func (a *Service) unlabelledFleetFence(ctx context.Context, rt registry.Route) e |
| return nil |
| } |
| +// unlabelledFenceRefusal reports whether err, from currentWakeRoute on an |
| +// unlabelled fleet-placed row, is the R1 fence's refusal (record labelled, |
| +// given copies, or unreadable) rather than a registry change. A worker |
| +// refused by it backs off like a crash, without one (runWorkerStart). |
| +func unlabelledFenceRefusal(err error) bool { |
| + return errors.Is(err, errUnlabelledRecordLabelled) || errors.Is(err, errRecordUnreadUnderLease) |
| +} |
| + |
| // errNoRecordStore is FleetRecordFrom's answer when the box has no |
| // deployment store: a labelled wake cannot be checked, so it is refused. |
| var errNoRecordStore = errors.New("no deployment store to read the instance record from") |