carlos / platform Public

activator: pace install waits for the resident tick (#1061)

Final review (Fable P2-2). An Installing refusal set retryAt to now and
no waitUntil, so each 2 s tick re-ran Plan and its install pass for as
long as the install never landed.

residentOwnerWait now answers installWaitPace (10 s) for
errBuildNotInstalled, so only the tick waits; a request still plans at
once and nothing counts as a crash.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev dd49a0618d4db772756e431694a4cadc466d47ba parent 214b8f9
2 files changed, +62 −2
  • internal/activator/replica_install_wait_test.go +50 −0
  • internal/activator/rootfs_service.go +12 −2
diff --git a/internal/activator/replica_install_wait_test.go b/internal/activator/replica_install_wait_test.go
index defdbe8a1..01103dbfb 100644
--- a/internal/activator/replica_install_wait_test.go
+++ b/internal/activator/replica_install_wait_test.go
@@ -4,6 +4,7 @@ import (
"context"
"errors"
"slices"
+ "sync/atomic"
"testing"
"time"
@@ -455,3 +456,52 @@ func TestInstallWaitBindsToFirstTarget(t *testing.T) {
t.Fatalf("v3's wait starts at %s, want its own first refusal (%s)", got, r.clk.now())
}
}
+
+// TestInstallWaitIsPacedForTheTick (Fable final P2-2, #1061): every plan
+// of an install wait runs the host's install pass, so the resident tick
+// plans it again only after installWaitPace, not every residentPoll. The
+// pacing is waitUntil, not a backoff: a request still plans at once, and
+// nothing is counted as a crash.
+func TestInstallWaitIsPacedForTheTick(t *testing.T) {
+ r := newInstallRig(t)
+ var plans atomic.Int64
+ inner := r.a.Planner
+ r.a.Planner = func(ctx context.Context, rt registry.Route) WakePlan {
+ plans.Add(1)
+ return inner(ctx, rt)
+ }
+ r.a.residentLister, r.a.residentJitter = residentRows{rows: r.routes}, func() float64 { return 0 }
+ want := func(n int64, when string) {
+ t.Helper()
+ if got := plans.Load(); got != n {
+ t.Fatalf("%s: %d plans, want %d", when, got, n)
+ }
+ }
+ paced := func(when string) {
+ t.Helper()
+ r.a.mu.Lock()
+ st := *r.a.residents[r.rt.Host]
+ delay := r.a.residentDelayLocked(r.rt.Host)
+ r.a.mu.Unlock()
+ if st.failures != 0 || delay != 0 || st.waitUntil.Sub(r.clk.now()) != installWaitPace {
+ t.Fatalf("%s: not a paced wait: failures %d, backoff %s, waitUntil in %s", when, st.failures, delay, st.waitUntil.Sub(r.clk.now()))
+ }
+ }
+
+ tickSettled(t, r.a)
+ want(1, "the first tick")
+ paced("after the first tick")
+ tickSettled(t, r.a)
+ want(1, "a tick at once")
+ r.clk.advance(installWaitPace - time.Second)
+ tickSettled(t, r.a)
+ want(1, "a tick within the pace")
+
+ r.refused("a request within the pace")
+ want(2, "a request within the pace")
+ paced("after the request")
+
+ r.clk.advance(installWaitPace)
+ tickSettled(t, r.a)
+ want(3, "a tick once the pace has passed")
+}
diff --git a/internal/activator/rootfs_service.go b/internal/activator/rootfs_service.go
index 32fbf09b4..6c0f655cc 100644
--- a/internal/activator/rootfs_service.go
+++ b/internal/activator/rootfs_service.go
@@ -421,7 +421,8 @@ type residentState struct {
// [Astra Task 8 R1 5]: a lease another holder still has, or config this
// box cannot provide yet, is no failure of the build, so it counts
// nothing and a request is not held back by it; only the tick waits, so
- // it does not ask the store for the lease every residentPoll.
+ // it does not ask the store for the lease every residentPoll. An install
+ // wait (errBuildNotInstalled) is paced the same way (installWaitPace).
waitUntil time.Time
// secretsSince: since when its wakes, the last one included, have been
// refused because the instance's shared secrets could not be had
@@ -531,15 +532,24 @@ func markOwnershipRefusal(rt registry.Route, err error) error {
return err
}
+// installWaitPace is how long the tick waits before it plans an install
+// wait's wake again (Fable final P2-2, #1061): each plan runs the host's
+// install pass, with its store reads, so the wait for root's install asks
+// a few times a minute, not every residentPoll.
+const installWaitPace = 10 * time.Second
+
// residentOwnerWait is how long the tick waits before it asks again after
// an ownership refusal: a held lease's own retry-after, or the config
-// guard's; 0 for anything else.
+// guard's; after an install wait (errBuildNotInstalled), installWaitPace;
+// 0 for anything else.
func residentOwnerWait(err error) time.Duration {
var held *errLeaseHeld
var refused *errConfigRefused
var config *releaseConfigWait
var secrets *secretsRefused
switch {
+ case errors.Is(err, errBuildNotInstalled):
+ return installWaitPace
case errors.As(err, &config):
return releaseConfigPace
case errors.As(err, &secrets):