carlos / platform Public

Managed fleets 1b: a pending wake judges the route under its lease (branch review R1 P1-1)

doWake read its row before the instance lease. If the record moved while
the wake waited, another box could take the lease, write and release it,
and the waiting wake then booted the copy kept under its old assignment.

- After the lease, doWake re-reads the row (leaseRouteChanged): a row
  that is gone, no longer this wake's route, or whose Assigned, Moved or
  Region changed gives the lease back and starts nothing. Members read
  it as the fence (errRouteChangedUnderLease).
- RetireExcept marks a waking entry retired; doWake's checks up to the
  spawn (wakeGoesOn) refuse it, so a retired host's pending wake gives
  its lease back before any restore or start.
- TestPendingWakeDoesNotBootAStaleCopy: A's acquire held, the record
  moved to B, B restores, writes and sleeps, A resumes: A refuses (three
  cases: retired and gone, gone, moved away and back). Before the fix A
  booted its one-row copy and, on the retired path, its sleep overwrote
  B's two rows in the bucket.
- TestRetirementFencesAPendingWake.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev 4ece23624dfe29c486909a2bb97135b0f69f7a1e parent 89891ac
5 files changed, +501 −7
  • internal/activator/activator.go +40 −7
  • internal/activator/logsink.go +7 −0
  • internal/activator/maintenance.go +10 −0
  • internal/activator/pendingwake_linux_test.go +414 −0
  • internal/activator/wakeidentity.go +30 −0
diff --git a/internal/activator/activator.go b/internal/activator/activator.go
index ba4182817..f8ca90ed2 100644
--- a/internal/activator/activator.go
+++ b/internal/activator/activator.go
@@ -532,6 +532,11 @@ type actEntry struct {
stopped chan struct{} // stopping: closed when the stop completes
wakeCancel context.CancelFunc
stopOutcome *stopObservation
+ // retired is set by RetireExcept on a waking entry whose host left the
+ // managed set (managed fleets 1b, branch review R1 P1-1): the wake must
+ // not go on past its next check (wakeGoesOn), whatever its lease says.
+ // Under a.mu.
+ retired bool
// stopWhy is why this entry is stopping (beginStopLocked), written under
// a.mu; finishStop hands it to a run it interrupts (run spec §5.3).
@@ -1977,7 +1982,7 @@ func (a *Service) wake(e *actEntry) {
// A wake that starts after Shutdown began is cancelled before its
// lease, whatever CARLOS_SWAP says (#292): with swaps off it used to run
// on, and take a lease the exiting agent never gave back.
- if a.fences[e.host] != 0 || a.shuttingDown {
+ if a.fences[e.host] != 0 || a.shuttingDown || e.retired {
cancel()
}
// A route a lapse turned off is refused like a fence (plans 4d); a
@@ -2344,7 +2349,7 @@ func (a *Service) doWake(ctx context.Context, e *actEntry) (*wokenInstance, erro
w := &wokenInstance{stopOutcome: &stopObservation{}}
w.stopOutcome.notStarted()
w.steps.begin(a.now())
- if ctx.Err() != nil || !a.wakeAllowed(host) {
+ if ctx.Err() != nil || !a.wakeGoesOn(e) {
return w, ErrFenced
}
@@ -2568,10 +2573,31 @@ func (a *Service) doWake(ctx context.Context, e *actEntry) (*wokenInstance, erro
}
w.steps.mark(a.now(), "lease")
- if ctx.Err() != nil || !a.wakeAllowed(host) {
+ if ctx.Err() != nil || !a.wakeGoesOn(e) {
w.stopOutcome.leaseReleased = a.giveBack(ctx, host, lease)
return w, ErrFenced
}
+ // 1.1. The route under the lease (managed fleets 1b, branch review R1
+ // P1-1). The row was read before the lease, and the wait for it can
+ // outlast a move: the record goes to another box, that box takes the
+ // lease, writes and releases it, and only then does this acquisition
+ // succeed. The start rule (startrule.go) judges the local copy by the
+ // row it is handed, so it must be handed the row as it is now. A row
+ // that is gone, no longer this wake's route, or whose fleet assignment
+ // or placement changed gives the lease back and starts nothing; the
+ // next wake reads the current row.
+ if a.Routes != nil {
+ now, err := a.Routes.Get(host)
+ if err != nil {
+ w.stopOutcome.leaseReleased = a.giveBack(ctx, host, lease)
+ return w, fmt.Errorf("%s: route lookup under the lease: %w", host, err)
+ }
+ if err := leaseRouteChanged(rt, now, e.worker); err != nil {
+ log.Printf("activator: %v; giving the lease back", err)
+ w.stopOutcome.leaseReleased = a.giveBack(ctx, host, lease)
+ return w, err
+ }
+ }
// 1.5. Flag off, the host cgroup is proven empty under the lease before
// anything is restored or started (Task 8 fix round 1, finding 4). The
// stop that released the lease proved it, but an agent restart forgets
@@ -2624,7 +2650,7 @@ func (a *Service) doWake(ctx context.Context, e *actEntry) (*wokenInstance, erro
a.mu.Unlock()
}
}
- if ctx.Err() != nil || !a.wakeAllowed(host) {
+ if ctx.Err() != nil || !a.wakeGoesOn(e) {
w.stopOutcome.leaseReleased = a.giveBack(ctx, host, lease)
return w, ErrFenced
}
@@ -2655,7 +2681,7 @@ func (a *Service) doWake(ctx context.Context, e *actEntry) (*wokenInstance, erro
placed = true
log.Printf("activator: %s: first boot: placed an empty database before the start", host)
w.steps.mark(a.now(), "placeholder")
- if ctx.Err() != nil || !a.wakeAllowed(host) {
+ if ctx.Err() != nil || !a.wakeGoesOn(e) {
w.stopOutcome.leaseReleased = a.giveBack(ctx, host, lease)
return w, ErrFenced
}
@@ -2786,7 +2812,7 @@ func (a *Service) doWake(ctx context.Context, e *actEntry) (*wokenInstance, erro
spawnVer string
token string
)
- if ctx.Err() != nil || !a.wakeAllowed(host) {
+ if ctx.Err() != nil || !a.wakeGoesOn(e) {
w.stopOutcome.leaseReleased = a.giveBack(ctx, host, lease)
return w, ErrFenced
}
@@ -5679,7 +5705,14 @@ func (a *Service) RetireExcept(keep map[string]bool) {
a.beginStopLocked(e, StopRetired)
case actWaking:
// A wake can't be stopped mid-flight; finish the retire once it
- // resolves (below, off-lock).
+ // resolves (below, off-lock). It is fenced from here on
+ // (managed fleets 1b, branch review R1 P1-1): a wake still
+ // waiting for its lease, or anywhere before its spawn, gives
+ // the lease back and starts nothing (wakeGoesOn, at doWake's
+ // checks up to the spawn), so a retired host's pending wake
+ // never boots the copy it kept. One past its spawn finishes and
+ // is stopped below, as before.
+ e.retired = true
waking = append(waking, e)
case actStopping:
// Already on its way out.
diff --git a/internal/activator/logsink.go b/internal/activator/logsink.go
index 75944a932..d3cbee297 100644
--- a/internal/activator/logsink.go
+++ b/internal/activator/logsink.go
@@ -141,6 +141,13 @@ func memberSafeWakeReason(err error) string {
// member gets the maintenance fence's existing text.
err = ErrFenced
}
+ if errors.Is(err, errRouteChangedUnderLease) {
+ // A wake whose row changed while it waited for its lease (managed
+ // fleets 1b): the instance moved or was retired, and the next wake
+ // reads the current row. The fence's existing text; the detail is
+ // the operator's (the wake logs it).
+ err = ErrFenced
+ }
if errors.Is(err, errHostUnproven) {
// A flag-off wake refused because its host cgroup holds processes
// not proven gone (Task 8 fix round 1, finding 4): the platform holds
diff --git a/internal/activator/maintenance.go b/internal/activator/maintenance.go
index 454761793..ef3aadc98 100644
--- a/internal/activator/maintenance.go
+++ b/internal/activator/maintenance.go
@@ -280,6 +280,16 @@ func (a *Service) wakeAllowed(host string) bool {
return a.fences[host] == 0
}
+// wakeGoesOn is wakeAllowed for one wake: no fence for its host, and the
+// entry not retired while it was waking (RetireExcept). doWake asks it at
+// each of its checks up to the spawn; after the spawn a retired wake
+// finishes and RetireExcept stops it.
+func (a *Service) wakeGoesOn(e *actEntry) bool {
+ a.mu.Lock()
+ defer a.mu.Unlock()
+ return a.fences[e.host] == 0 && !e.retired
+}
+
// Fenced reports whether a maintenance fence is installed for host right
// now. It is the layout pass's own affirmative read of the same map
// wakeAllowed checks, so a pass deciding whether it is safe to install its
diff --git a/internal/activator/pendingwake_linux_test.go b/internal/activator/pendingwake_linux_test.go
new file mode 100644
index 000000000..96dba118c
--- /dev/null
+++ b/internal/activator/pendingwake_linux_test.go
@@ -0,0 +1,414 @@
+//go:build linux
+
+package activator
+
+import (
+ "context"
+ "database/sql"
+ "errors"
+ "fmt"
+ "io"
+ "os"
+ "path/filepath"
+ "sync"
+ "testing"
+ "time"
+
+ "github.com/carlosframework/platform/internal/registry"
+)
+
+// A pending wake and the start rule (managed fleets 1b, branch review R1
+// P1-1). A wake reads its route, then waits for the instance lease. If the
+// record moves to another box while it waits, that box can take the lease,
+// write and release before the wait ends. The waiting wake must then judge
+// the route as it is under the lease, not as it was before: the row it
+// began from may be gone, retired or reassigned, and its local copy is
+// then not the newest data.
+
+const assignC = "2026-10-30T12:00:00.000000003Z"
+
+// sharedLock is the one instance lease two boxes contend for: the fleet
+// bucket's lock.json, held by at most one box at a time.
+type sharedLock struct {
+ mu sync.Mutex
+ holder string
+}
+
+func (l *sharedLock) take(who string) error {
+ l.mu.Lock()
+ defer l.mu.Unlock()
+ if l.holder != "" {
+ return fmt.Errorf("lease held by %s", l.holder)
+ }
+ l.holder = who
+ return nil
+}
+
+func (l *sharedLock) drop(who string) {
+ l.mu.Lock()
+ defer l.mu.Unlock()
+ if l.holder == who {
+ l.holder = ""
+ }
+}
+
+func (l *sharedLock) heldBy() string {
+ l.mu.Lock()
+ defer l.mu.Unlock()
+ return l.holder
+}
+
+// fleetBucket is the fleet bucket's replica of the host's database: a
+// restore copies it down, a final sync copies the box's database up.
+type fleetBucket struct {
+ mu sync.Mutex
+ path string
+ has bool
+}
+
+func (fb *fleetBucket) upload(t *testing.T, from string) {
+ t.Helper()
+ fb.mu.Lock()
+ defer fb.mu.Unlock()
+ copyFile(t, from, fb.path)
+ fb.has = true
+}
+
+func (fb *fleetBucket) restoreTo(t *testing.T, dbPath string) bool {
+ t.Helper()
+ fb.mu.Lock()
+ defer fb.mu.Unlock()
+ if !fb.has {
+ return false
+ }
+ copyFile(t, fb.path, dbPath)
+ return true
+}
+
+func copyFile(t *testing.T, from, to string) {
+ t.Helper()
+ src, err := os.Open(from)
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer src.Close()
+ dst, err := os.OpenFile(to, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0o600)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if _, err := io.Copy(dst, src); err != nil {
+ t.Fatal(err)
+ }
+ if err := dst.Close(); err != nil {
+ t.Fatal(err)
+ }
+}
+
+// leasedBox is one fleet box: the real start rule (ruleBackend over an
+// ExecBackend) under the shared lock. gate, when set, holds the box's
+// Acquire before it takes the lock; entered is closed once the Acquire is
+// waiting there.
+type leasedBox struct {
+ *ruleBackend
+ t *testing.T
+ name string
+ lock *sharedLock
+ bucket *fleetBucket
+ dbPath string
+ gate chan struct{}
+ entered chan struct{}
+ once sync.Once
+}
+
+func (b *leasedBox) Acquire(ctx context.Context, rt registry.Route) (Lease, error) {
+ if b.entered != nil {
+ b.once.Do(func() { close(b.entered) })
+ }
+ if b.gate != nil {
+ <-b.gate
+ }
+ if err := b.lock.take(b.name); err != nil {
+ return nil, err
+ }
+ l, err := b.ruleBackend.Acquire(ctx, rt)
+ if err != nil {
+ b.lock.drop(b.name)
+ return nil, err
+ }
+ return &boxLease{inner: l.(*fakeLease), box: b}, nil
+}
+
+// boxLease drops the shared lock when it is released or when its
+// replication closes; the close is the final sync, so the box's database
+// goes up to the bucket first.
+type boxLease struct {
+ inner *fakeLease
+ box *leasedBox
+}
+
+func (l *boxLease) Err() error { return l.inner.Err() }
+
+func (l *boxLease) Replicate(ctx context.Context, dbPath string, iv time.Duration) (Rep, error) {
+ r, err := l.inner.Replicate(ctx, dbPath, iv)
+ if err != nil {
+ return nil, err
+ }
+ return &boxRep{Rep: r, box: l.box}, nil
+}
+
+func (l *boxLease) Release(ctx context.Context) error {
+ err := l.inner.Release(ctx)
+ l.box.lock.drop(l.box.name)
+ return err
+}
+
+type boxRep struct {
+ Rep
+ box *leasedBox
+}
+
+func (r *boxRep) Close(ctx context.Context) error {
+ r.box.bucket.upload(r.box.t, r.box.dbPath)
+ err := r.Rep.Close(ctx)
+ r.box.lock.drop(r.box.name)
+ return err
+}
+
+// fleetBox is a box's Service over its own registry, holding rt.
+func fleetBox(t *testing.T, name string, lock *sharedLock, bucket *fleetBucket, eb *ExecBackend, rt registry.Route) (*Service, *leasedBox, *registry.Registry) {
+ t.Helper()
+ reg, err := registry.Open(filepath.Join(t.TempDir(), "registry.db"))
+ if err != nil {
+ t.Fatal(err)
+ }
+ t.Cleanup(func() { reg.Close() })
+ if err := reg.Upsert(rt); err != nil {
+ t.Fatal(err)
+ }
+ box := &leasedBox{ruleBackend: &ruleBackend{fakeBackend: &fakeBackend{}, eb: eb, t: t},
+ t: t, name: name, lock: lock, bucket: bucket, dbPath: rt.DBPath}
+ a := New(Config{Bucket: "test-bucket", Idle: time.Hour}, box, reg)
+ a.Routes = reg
+ return a, box, reg
+}
+
+// The review's interleaving, at the Service: box A's wake reads its route
+// and stalls before its lease; the record moves to box B (A's row goes, and
+// in the first case A retires it); B takes the lease, restores, writes and
+// sleeps, releasing it; then A's acquisition resumes and succeeds. A must
+// not boot the copy it kept under its old assignment: it refuses and gives
+// the lease back. The other cases change A's row without a retirement (the
+// row gone before A's reconcile retires it; the record moved away and back
+// so A's row names a newer assignment): the check under the lease refuses
+// those too, and the next wake judges the current route.
+func TestPendingWakeDoesNotBootAStaleCopy(t *testing.T) {
+ for _, tc := range []struct {
+ name string
+ // change is what happens to A's row while A's wake waits.
+ change func(t *testing.T, a *Service, reg *registry.Registry, host string)
+ gone bool
+ }{
+ {
+ name: "retired and gone",
+ change: func(t *testing.T, a *Service, reg *registry.Registry, host string) {
+ if err := reg.Delete(host); err != nil {
+ t.Fatal(err)
+ }
+ a.RetireExcept(map[string]bool{})
+ },
+ gone: true,
+ },
+ {
+ name: "gone before the retirement",
+ change: func(t *testing.T, _ *Service, reg *registry.Registry, host string) {
+ if err := reg.Delete(host); err != nil {
+ t.Fatal(err)
+ }
+ },
+ gone: true,
+ },
+ {
+ name: "moved away and back",
+ change: func(t *testing.T, _ *Service, reg *registry.Registry, host string) {
+ if err := reg.SetFleetAssignment(host, assignC, true); err != nil {
+ t.Fatal(err)
+ }
+ },
+ },
+ } {
+ t.Run(tc.name, func(t *testing.T) {
+ lock := &sharedLock{}
+ bucket := &fleetBucket{path: filepath.Join(t.TempDir(), "replica.db")}
+ swapRestoreReplica(t, func(_ context.Context, dbPath, _, _, _ string) (bool, error) {
+ return bucket.restoreTo(t, dbPath), nil
+ })
+
+ // A served the instance under assignA and slept: its local copy
+ // (one row) is kept under assignA, and the bucket holds the same.
+ ebA := testExecBackend(t)
+ rtA := fleetRoute(ebA, assignA, false)
+ writeUsableDB(t, rtA.DBPath)
+ writeAssignedMarker(t, rtA.DBPath, assignA)
+ bucket.upload(t, rtA.DBPath)
+ aSvc, boxA, regA := fleetBox(t, "pi-1", lock, bucket, ebA, rtA)
+ boxA.gate, boxA.entered = make(chan struct{}), make(chan struct{})
+
+ // A's wake reads its route and waits for the lease.
+ woke := make(chan error, 1)
+ go func() {
+ release, err := aSvc.beginRequest(context.Background(), rtA)
+ if err == nil {
+ release()
+ }
+ woke <- err
+ }()
+ select {
+ case <-boxA.entered:
+ case <-time.After(10 * time.Second):
+ t.Fatal("A's wake never reached its lease")
+ }
+
+ // The record moves to B: A's row changes.
+ tc.change(t, aSvc, regA, rtA.Host)
+
+ // B takes the lease, restores the replica, writes a second row
+ // and sleeps: its final sync puts two rows in the bucket and
+ // releases the lease.
+ ebB := testExecBackend(t)
+ rtB := fleetRoute(ebB, assignB, true)
+ bSvc, boxB, _ := fleetBox(t, "pi-2", lock, bucket, ebB, rtB)
+ release, err := bSvc.beginRequest(context.Background(), rtB)
+ if err != nil {
+ t.Fatalf("B's wake: %v", err)
+ }
+ release()
+ boxB.fakeBackend.mu.Lock()
+ bStarts := boxB.starts
+ boxB.fakeBackend.mu.Unlock()
+ if bStarts != 1 {
+ t.Fatalf("B started %d times, want 1", bStarts)
+ }
+ appendRow(t, rtB.DBPath)
+ ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+ defer cancel()
+ bSvc.Shutdown(ctx)
+ if h := lock.heldBy(); h != "" {
+ t.Fatalf("B's sleep left the lease held by %s", h)
+ }
+
+ // A's acquisition resumes and takes the free lease.
+ close(boxA.gate)
+ var wakeErr error
+ select {
+ case wakeErr = <-woke:
+ case <-time.After(10 * time.Second):
+ t.Fatal("A's wake never finished")
+ }
+ boxA.fakeBackend.mu.Lock()
+ starts := boxA.starts
+ boxA.fakeBackend.mu.Unlock()
+ if starts != 0 || wakeErr == nil {
+ t.Fatalf("A started %d times (wake error %v): it booted the copy kept under its old assignment, one row behind the bucket's %d", starts, wakeErr, countRows(t, bucket.path))
+ }
+ if h := lock.heldBy(); h != "" {
+ t.Fatalf("A's refused wake left the lease held by %s", h)
+ }
+ if n := countRows(t, rtA.DBPath); n != 1 {
+ t.Fatalf("A's kept copy has %d rows; the refusal must leave it as it was", n)
+ }
+ row, err := regA.Get(rtA.Host)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if tc.gone {
+ if row != nil {
+ t.Fatalf("A's row is back: %+v", row)
+ }
+ return
+ }
+ // The next wake judges the current route: the copy kept under
+ // assignA is set aside and the bucket's two rows restored.
+ release, err = aSvc.beginRequest(context.Background(), *row)
+ if err != nil {
+ t.Fatalf("A's next wake: %v", err)
+ }
+ release()
+ if n := countRows(t, rtA.DBPath); n != 2 {
+ t.Fatalf("A's next wake runs %d rows, want the bucket's 2", n)
+ }
+ if got, _ := markerAt(t, rtA.DBPath); got != assignC {
+ t.Fatalf("marker = %q, want %q", got, assignC)
+ }
+ assertOneSetAside(t, ebA, rtA.Host)
+ })
+ }
+}
+
+// RetireExcept fences a wake that has not yet taken its lease: once the
+// lease comes, the wake gives it back and starts nothing, even when its
+// row is still there (a retirement that is not a removal: the hibernate
+// flag turned off).
+func TestRetirementFencesAPendingWake(t *testing.T) {
+ lock := &sharedLock{}
+ bucket := &fleetBucket{path: filepath.Join(t.TempDir(), "replica.db")}
+ swapRestoreReplica(t, func(_ context.Context, dbPath, _, _, _ string) (bool, error) {
+ return bucket.restoreTo(t, dbPath), nil
+ })
+ eb := testExecBackend(t)
+ rt := fleetRoute(eb, assignA, false)
+ writeUsableDB(t, rt.DBPath)
+ writeAssignedMarker(t, rt.DBPath, assignA)
+ a, box, _ := fleetBox(t, "pi-1", lock, bucket, eb, rt)
+ box.gate, box.entered = make(chan struct{}), make(chan struct{})
+ woke := make(chan error, 1)
+ go func() {
+ release, err := a.beginRequest(context.Background(), rt)
+ if err == nil {
+ release()
+ }
+ woke <- err
+ }()
+ <-box.entered
+ a.RetireExcept(map[string]bool{})
+ close(box.gate)
+ var err error
+ select {
+ case err = <-woke:
+ case <-time.After(10 * time.Second):
+ t.Fatal("the wake never finished")
+ }
+ box.fakeBackend.mu.Lock()
+ starts, restores := box.starts, box.restores
+ box.fakeBackend.mu.Unlock()
+ if err == nil || starts != 0 || restores != 0 {
+ t.Fatalf("a wake retired while it waited for its lease: err %v, %d restores, %d starts; want a refusal before both", err, restores, starts)
+ }
+ if !errors.Is(err, ErrFenced) && !errors.Is(err, context.Canceled) {
+ t.Fatalf("err = %v, want the fence", err)
+ }
+ if h := lock.heldBy(); h != "" {
+ t.Fatalf("the lease is still held by %s", h)
+ }
+}
+
+// appendRow adds one row to a database writeUsableDB made.
+func appendRow(t *testing.T, dbPath string) {
+ t.Helper()
+ db, err := sql.Open("sqlite", dbPath)
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer db.Close()
+ if _, err := db.Exec("INSERT INTO t DEFAULT VALUES"); err != nil {
+ t.Fatal(err)
+ }
+}
+
+// assertOneSetAside checks there is exactly one complete set-aside entry.
+func assertOneSetAside(t *testing.T, b *ExecBackend, host string) {
+ t.Helper()
+ names := supersededEntries(t, b, host)
+ if len(names) != 1 {
+ t.Fatalf("set-aside entries %q, want one", names)
+ }
+}
diff --git a/internal/activator/wakeidentity.go b/internal/activator/wakeidentity.go
index 7d2f5db7b..df62dca67 100644
--- a/internal/activator/wakeidentity.go
+++ b/internal/activator/wakeidentity.go
@@ -1,6 +1,7 @@
package activator
import (
+ "errors"
"fmt"
"github.com/carlosframework/platform/internal/registry"
@@ -84,3 +85,32 @@ func rowSeedID(col string) string {
}
return rs.ID
}
+
+// errRouteChangedUnderLease is a wake refused because its row changed while
+// it waited for the instance lease (leaseRouteChanged). Members read it as
+// the fence: the next wake reads the current row.
+var errRouteChangedUnderLease = errors.New("the route changed while the wake waited for its lease")
+
+// leaseRouteChanged is doWake's check, under the lease, of the row as it is
+// now against the row the wake began from (managed fleets 1b, branch review
+// R1 P1-1). now nil is a row that is gone. Beyond wakeRouteChanged's
+// identity, the fleet assignment (Assigned, Moved) and the placement
+// (Region) must be the same: the start rule judges the local copy by them,
+// and a change means the record was moved, so another box may have
+// written since. nil means the wake goes on.
+func leaseRouteChanged(began registry.Route, now *registry.Route, worker bool) error {
+ if now == nil {
+ return fmt.Errorf("%s: refusing to wake: %w: it is gone", began.Host, errRouteChangedUnderLease)
+ }
+ if err := wakeRouteChanged(began, *now, worker); err != nil {
+ return fmt.Errorf("%w: %w", errRouteChangedUnderLease, err)
+ }
+ switch {
+ case began.Assigned != now.Assigned || began.Moved != now.Moved:
+ return fmt.Errorf("%s: refusing to wake: %w: its fleet assignment is %q (moved %v) now, not %q (moved %v)",
+ began.Host, errRouteChangedUnderLease, now.Assigned, now.Moved, began.Assigned, began.Moved)
+ case began.Region != now.Region:
+ return fmt.Errorf("%s: refusing to wake: %w: its placement is %q now, not %q", began.Host, errRouteChangedUnderLease, now.Region, began.Region)
+ }
+ return nil
+}