| index 2e46f3e12..8fb2d460d 100644 |
| --- a/internal/activator/pendingwake_linux_test.go |
| +++ b/internal/activator/pendingwake_linux_test.go |
| @@ -23,6 +23,7 @@ import ( |
| "github.com/carlosframework/platform/internal/registry" |
| "github.com/carlosframework/platform/internal/release" |
| "github.com/carlosframework/platform/internal/replicas" |
| + "github.com/carlosframework/platform/internal/rolloutwords" |
| ) |
| |
| // A pending wake and the start rule (managed fleets 1b, branch review R1 |
| @@ -1289,10 +1290,10 @@ func TestWorkerUnlabelledWakeFenced(t *testing.T) { |
| } |
| r.a.mu.Lock() |
| wk := r.a.entries[r.rt.Host].rootfsWorkers["jobs"] |
| - restarts, crashLoop, backoff := wk.restarts, wk.crashLoop, wk.backoff |
| + restarts, crashLoop, backoff, pacing := wk.restarts, wk.crashLoop, wk.backoff, wk.fenceBackoff |
| 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) |
| + if restarts != 0 || crashLoop || backoff != 0 || pacing != sidecarRestartBase { |
| + t.Fatalf("restarts %d, crash loop %v, backoff %s, fence pacing %s; want no crash noted, no crash backoff and the base fence pacing", restarts, crashLoop, backoff, pacing) |
| } |
| }) |
| } |
| @@ -1332,16 +1333,76 @@ func TestWorkerUnlabelledFenceBacksOff(t *testing.T) { |
| } |
| r.a.mu.Lock() |
| wk := r.a.entries[r.rt.Host].rootfsWorkers["jobs"] |
| - restarts, crashLoop, backoff := wk.restarts, wk.crashLoop, wk.backoff |
| + restarts, crashLoop, backoff, pacing := wk.restarts, wk.crashLoop, wk.backoff, wk.fenceBackoff |
| 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 restarts != 0 || crashLoop || backoff != 0 || pacing != sidecarRestartMax { |
| + t.Fatalf("restarts %d, crash loop %v, backoff %s, fence pacing %s; want no crash, no crash backoff and the fence pacing at its cap", restarts, crashLoop, backoff, pacing) |
| } |
| if r.workers.alive() != 0 { |
| t.Fatal("a fenced worker started") |
| } |
| } |
| |
| +// M1 review Astra P2-3: the fence's pacing is not crash history. A |
| +// worker refused by the fence long enough for its pacing to reach the cap, |
| +// then let through and installed, that crashes once is a first crash: the |
| +// crash backoff starts at sidecarRestartBase, one restart is counted, and |
| +// there is no crash loop and no RFS-3-C10. |
| +func TestFencePacingIsNoCrashHistory(t *testing.T) { |
| + r := newUnlabelledWorkerRig(t) |
| + r.labelled.Store(true) |
| + for range 200 { |
| + r.tick(t) |
| + r.clk.advance(time.Second) |
| + } |
| + r.a.mu.Lock() |
| + wk := r.a.entries[r.rt.Host].rootfsWorkers["jobs"] |
| + fencePacing := wk.fenceBackoff |
| + r.a.mu.Unlock() |
| + if fencePacing != sidecarRestartMax { |
| + t.Fatalf("the fence's pacing is %s after 200 s of refusals; the witness needs it at its cap", fencePacing) |
| + } |
| + r.labelled.Store(false) |
| + // The next start, at most the capped pacing away, installs. |
| + for waited := time.Duration(0); r.workers.alive() == 0; waited += time.Second { |
| + if waited > sidecarRestartMax { |
| + t.Fatalf("no worker installed within %s of the record clearing", sidecarRestartMax) |
| + } |
| + r.clk.advance(time.Second) |
| + r.tick(t) |
| + } |
| + r.a.mu.Lock() |
| + wk = r.a.entries[r.rt.Host].rootfsWorkers["jobs"] |
| + fencePacing = wk.fenceBackoff |
| + r.a.mu.Unlock() |
| + if fencePacing != 0 { |
| + t.Fatalf("installation left the fence's pacing at %s", fencePacing) |
| + } |
| + |
| + r.workers.lastWorker(t, "jobs").exit("1", "exited") |
| + r.tick(t) // the crash is noted |
| + 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 != 1 || crashLoop || backoff != sidecarRestartBase { |
| + t.Fatalf("after one crash: restarts %d, crash loop %v, backoff %s; want 1, false and %s", restarts, crashLoop, backoff, sidecarRestartBase) |
| + } |
| + loop := fmt.Sprintf(rolloutwords.EventWorkerCrashLoop, "jobs") |
| + var loops, exits int |
| + for _, m := range r.sink.msgs() { |
| + switch { |
| + case m == loop: |
| + loops++ |
| + case strings.HasPrefix(m, "worker jobs exited") && strings.HasSuffix(m, "starting it again in 2s"): |
| + exits++ // RFS-3-C09 or C35, at the first crash's delay |
| + } |
| + } |
| + if loops != 0 || exits != 1 { |
| + t.Fatalf("events %q: RFS-3-C10 %d times and the first crash's RFS-3-C09 %d times; want 0 and 1", r.sink.msgs(), loops, exits) |
| + } |
| +} |
| + |
| // R2 (fleet record labels): a fleet stop's final checkpoint must succeed |
| // before its lease is released. checkpointRig is one box serving host |
| // through the production wake and stop: a real Service over a real |