activator: R1 fence skips sidecar rows (M1 review P1)
unlabelledFleetRow now requires Kind instance. A sidecar row's record is sidecars/<name>.json, so the fence's instance-record read always missed and refused every fleet-placed sidecar wake, worker and stateless alike. Witnesses: a fleet sidecar worker wake and the stateless sidecar final gate read nothing and start.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2 files changed,
+62
−4
internal/activator/pendingwake_linux_test.go+49 −0internal/activator/wakeidentity.go+13 −4
Intent
Human
<task-notification> <task-id>bxi4i9zzw</task-id> <tool-use-id>toolu_01KiTvM67YsU2HgnKZh7Zg8Y</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/ac77363b-5830-422c-9f38-d7f2540dd398/tasks/bxi4i9zzw.output</output-file> <status>completed</status> <summary>Background command "Run M1 whole-branch reviews (Astra + Fable)" completed (exit code 0)</summary> </task-notification>
diff --git a/internal/activator/pendingwake_linux_test.go b/internal/activator/pendingwake_linux_test.go| index 2084ab682..5fad06770 100644 |
| --- a/internal/activator/pendingwake_linux_test.go |
| +++ b/internal/activator/pendingwake_linux_test.go |
| @@ -1102,6 +1102,55 @@ func TestStatelessUnlabelledWakeFenced(t *testing.T) { |
| } |
| } |
| +// A standalone sidecar's row (Kind sidecar) has no instance record: its |
| +// record is sidecars/<name>.json, and a fleet placement is a valid sidecar |
| +// region. The R1 fence must not read an instance record for it, so a |
| +// fleet-placed sidecar's wake on a checking box reads nothing and starts. |
| +// The reader answers "no record", which the fence would refuse (M1 review |
| +// Fable P1-1). |
| +func TestUnlabelledFenceSkipsFleetSidecarWorkerWake(t *testing.T) { |
| + a, b, _, _ := testActivator(t, time.Hour) |
| + rt := testWorkerRoute("bot.x.internal") |
| + rt.Region, rt.Provisioned, rt.App, rt.Account = recRegion, true, recApp, recAcct |
| + var reads atomic.Int64 |
| + a.Fleet = FleetWake{Mode: FleetWakeCheck, Fleet: "pi", Label: "pi-1", Record: staticRecord(&reads, nil, nil)} |
| + if err := a.WakeWorker(rt); err != nil { |
| + t.Fatalf("WakeWorker: %v", err) |
| + } |
| + if n := b.workerStarts(); n != 1 { |
| + t.Fatalf("worker starts = %d, want 1", n) |
| + } |
| + if n := reads.Load(); n != 0 { |
| + t.Fatalf("the sidecar wake read an instance record %d times, want 0", n) |
| + } |
| +} |
| + |
| +// The stateless final exec gate (statelessFinalRecord) for a stateless |
| +// fleet-placed sidecar: no instance record read, and the start goes on. |
| +func TestUnlabelledFenceSkipsStatelessFleetSidecar(t *testing.T) { |
| + rt := registry.Route{Host: "jobs.example.com", Kind: "sidecar", Account: recAcct, App: recApp, Channel: "edge", |
| + Region: recRegion, Stateless: true, Provisioned: true, Hibernate: true, CreatedAt: 1, Args: `["sidecar","run"]`, Status: "ready"} |
| + facts, err := RecordFactsOf(provision.Record{Account: rt.Account, App: rt.App, Host: rt.Host, CreatedAt: time.Unix(1, 0)}) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + target := replicas.Build{Version: "v1", Digest: "canonical"} |
| + facts.ReplicaDeploy = &replicas.Deploy{ID: "deploy-v1", Incarnation: facts.Identity.Incarnation, Target: target, LastGood: target, Phase: "done", Revision: 4} |
| + var reads atomic.Int64 |
| + a := &Service{Routes: startupRoutes{rt.Host: rt}, Fleet: FleetWake{Mode: FleetWakeCheck, Fleet: "pi", Label: "pi-1", Record: staticRecord(&reads, nil, nil)}} |
| + a.cfg.Record = func(context.Context, registry.Route) (RecordFacts, error) { return facts, nil } |
| + ctx := WithReplicaReleaseObservation(context.Background(), facts, target, true) |
| + ctx = context.WithValue(ctx, statelessRecordKey{}, rt) |
| + ctx = context.WithValue(ctx, statelessPreparedKey{}, &statelessPreparation{route: rt, id: release.StagedIdentity{Version: "v1"}, digest: "canonical", deployID: "deploy-v1"}) |
| + ctx = a.withStatelessFinalCheck(ctx, rt) |
| + if err := runExecGate(ctx); err != nil { |
| + t.Fatalf("the stateless sidecar's final gate refused: %v", err) |
| + } |
| + if n := reads.Load(); n != 0 { |
| + t.Fatalf("the stateless sidecar read an instance record %d times, want 0", n) |
| + } |
| +} |
| + |
| // workerErrBackend is the stateless wake backend whose worker launches |
| // keep their last error: the refusal reason. |
| type workerErrBackend struct { |
diff --git a/internal/activator/wakeidentity.go b/internal/activator/wakeidentity.go| index 8f68f42f2..14e2abb82 100644 |
| --- a/internal/activator/wakeidentity.go |
| +++ b/internal/activator/wakeidentity.go |
| @@ -289,11 +289,20 @@ func (a *Service) currentWakeRoute(ctx context.Context, rt registry.Route, worke |
| return ¤t, rec, nil |
| } |
| -// unlabelledFleetRow reports whether rt is an unlabelled row placed on a |
| -// fleet: no box label, no copies, and a fleet placement. Such a row's wake |
| -// is fenced by its record (unlabelledFleetFence). |
| +// unlabelledFleetRow reports whether rt is an unlabelled instance row |
| +// placed on a fleet: kind instance, no box label, no copies, and a fleet |
| +// placement. Such a row's wake is fenced by its record |
| +// (unlabelledFleetFence). |
| +// |
| +// Only the instance kind: that is the row minted from an instance record |
| +// (instances/<host>.json), the record the fence reads and the only one a |
| +// label is written to. A sidecar row's record is sidecars/<name>.json, so |
| +// the instance read would always miss and refuse every sidecar wake (M1 |
| +// review Fable P1-1). Provisioned is deliberately not required: an |
| +// instance row on a fleet stays fenced however it was minted, failing |
| +// closed. |
| func unlabelledFleetRow(rt registry.Route) bool { |
| - if rt.Assigned != "" || rt.FleetBoxes != "" { |
| + if rt.Kind != "instance" || rt.Assigned != "" || rt.FleetBoxes != "" { |
| return false |
| } |
| _, ok := registry.FleetPlacement(rt.Region) |