A replica missing a shard is not ready
CI / test (push) Successful in 1m23s

Restarting the control plane over a running two-node replica adopted half of
it. Every shard it still had was healthy, so it was reported Ready — with one
shard of two and no endpoint at all, because the missing one was rank 0. The
router was handed a replica nothing could route to.

The cause is that a replica had no idea how many shards it should have. It
could tell "every shard I have is ready" and nothing else, which is the same
sentence whether or not half of it is gone. It now carries the count from its
profile, set at placement and again at adoption, and a replica short of shards
fails rather than pretending.

Onboarding also wrote no engine paths, so a node onboarded by the script could
not find llama-server and failed every shard placed on it with "executable
file not found". The script now takes them, and says so when none are given —
a node with no engine paths can run the sim engine and nothing else.

The cluster now runs both at once: two-node simulated replicas on each fabric,
and real llama.cpp inference on the CPU, which is a better test bed than
either alone.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ilker ManapandClaude Opus 5 committed 2026-09-16 12:43:51 +02:00
1 parent c97b671ef9
commit 7b4acd9284
5 files changed
+133 -1

No files matched your search

@@ -511,6 +511,7 @@ func (r *Reconciler) startReplica(ctx context.Context, m catalog.Model, pl *plac
ID: id, Model: m.Name, Profile: prof.Name,
Fabric: pl.Fabric, Pool: pl.Pool, State: Placing,
Weight: prof.Weight, CreatedAt: r.now(), Attempt: attempt,
WantShards: len(pl.Nodes),
}
// The leader's address and port are fixed before any shard starts: every
@@ -773,6 +774,9 @@ func (r *Reconciler) Adopt(nodeID string, shards []AdoptedShard) (unclaimed []Ad
Fabric: first.Fabric, Pool: first.Pool,
Weight: prof.Weight, CreatedAt: r.now(),
Endpoint: first.Endpoint,
// From the profile, not from what was reported: the point is to
// notice when what was reported is short.
WantShards: max(prof.Nodes, 1),
}
for _, s := range group {
rep.Shards = append(rep.Shards, Shard{
+18 -1
View File
@@ -84,6 +84,13 @@ type Replica struct {
Endpoint string
// Weight is the profile's capacity weight, passed to the router.
Weight float64
// WantShards is how many shards this replica should have, from its profile.
//
// Without it a replica cannot tell "every shard I have is ready" from
// "every shard I have left is ready". A control plane that adopted half of
// a two-node replica reported it Ready with one shard and no endpoint, and
// the router was handed a replica nothing could route to.
WantShards int
CreatedAt time.Time
ReadyAt time.Time
@@ -163,12 +170,22 @@ func (r *Replica) deriveState() {
}
}
if ready == len(r.Shards) {
// Both conditions. A replica missing a shard is not ready however healthy
// the shards it still has look — and rank 0's absence in particular means
// there is no endpoint to route to at all.
if ready == len(r.Shards) && (r.WantShards == 0 || len(r.Shards) == r.WantShards) {
if r.State != Ready {
r.ReadyAt = time.Now()
}
r.State = Ready
return
}
if r.WantShards > 0 && len(r.Shards) < r.WantShards {
r.State = Failed
if r.Err == "" {
r.Err = fmt.Sprintf("replica has %d of %d shards", len(r.Shards), r.WantShards)
}
return
}
r.State = Starting
}
+66
View File
@@ -340,3 +340,69 @@ func TestAnotherNodesShardsAreNotForgotten(t *testing.T) {
t.Error("node 1's registration forgot node 2's shards")
}
}
// TestAReplicaMissingAShardIsNotReady is what a control plane restart exposed:
// half of a two-node replica was adopted, every shard it still had was healthy,
// and it was reported Ready with no endpoint — so the router was handed a
// replica nothing could route to.
func TestAReplicaMissingAShardIsNotReady(t *testing.T) {
rep := &Replica{
ID: "r1", WantShards: 2,
Shards: []Shard{{ID: "r1-r1", Rank: 1, State: supervisor.Ready}},
}
rep.deriveState()
if rep.State == Ready {
t.Fatal("a replica with one of two shards is Ready")
}
if !strings.Contains(rep.Err, "1 of 2") {
t.Errorf("the error does not say what is missing: %q", rep.Err)
}
}
func TestACompleteReplicaIsReady(t *testing.T) {
rep := &Replica{
ID: "r1", WantShards: 2,
Shards: []Shard{
{ID: "r1-r0", Rank: 0, State: supervisor.Ready},
{ID: "r1-r1", Rank: 1, State: supervisor.Ready},
},
}
rep.deriveState()
if rep.State != Ready {
t.Errorf("state = %s, want ready", rep.State)
}
}
func TestAReplicaStillComingUpIsNotFailed(t *testing.T) {
// Every shard present, not all ready yet: that is Starting, not a shortage.
rep := &Replica{
ID: "r1", WantShards: 2,
Shards: []Shard{
{ID: "r1-r0", Rank: 0, State: supervisor.Ready},
{ID: "r1-r1", Rank: 1, State: supervisor.Loading},
},
}
rep.deriveState()
if rep.State != Starting {
t.Errorf("state = %s, want starting", rep.State)
}
}
func TestAMultiNodeReplicaKnowsHowManyShardsItWants(t *testing.T) {
// End to end through placement, because the count has to reach the replica
// from the profile rather than from whatever turned up.
m := testModel(1, catalog.Profile{
Name: "tp8", GPUClass: "h100-80g", TP: 8, Nodes: 2, GPUsPerNode: 4,
})
h := newHarness(t, m, gpuNode("1", 8, "ib-a"), gpuNode("2", 8, "ib-a"))
h.r.Reconcile(context.Background())
reps := h.r.Replicas()
if len(reps) != 1 {
t.Fatalf("replicas: %+v", reps)
}
if reps[0].WantShards != 2 {
t.Errorf("WantShards = %d, want 2", reps[0].WantShards)
}
}