Engine membership¶
The router serves the engines in its membership snapshot. Joining and removing engines gives the operator procedure.
Membership document¶
Every route on this page returns the narwhal.membership schema version 1 document, with these exceptions:
- HTTP
422for adeadline_sthat is not a number carries FastAPI's validation body withdetail. - HTTP
503fromGET /narwhal/engineson a router that does not control the fleet returns the fleet-state refusal. - HTTP
401for a join or removal without the control token carries therouter_token_requirederror body. - HTTP
413for a request body over 64 KiB has an empty body.
| Field | Meaning |
|---|---|
schema |
narwhal.membership |
schema_version |
Membership schema version, 1 |
generation |
Snapshot generation |
engines |
Member engine entries in snapshot order, with ${VARIABLE} references resolved |
leaving |
Sorted IDs of engines draining before removal |
error |
Refused request's message, empty otherwise |
join |
Join result, or null when the router did not run a join |
Each engines entry holds iid, url and role, plus pin, attestation_url and shared_device when the engine sets them.
join fields:
| Field | Meaning |
|---|---|
iid |
Engine ID from the request |
joined |
true when the engine entered the fleet |
checks |
Checks the engine passed |
failures |
Failed checks, empty when the engine joined or a precondition refused it |
GET /narwhal/engines¶
Returns HTTP 200 with the router's snapshot:
{
"schema": "narwhal.membership",
"schema_version": 1,
"generation": 1,
"engines": [
{"iid": "e0", "url": "http://node0:8000", "role": "prefill", "attestation_url": "http://node0:8010/v1/attestation"},
{"iid": "e1", "url": "http://node1:8000", "role": "decode", "attestation_url": "http://node1:8010/v1/attestation"},
{"iid": "e4", "url": "http://node4:8000", "role": "decode", "attestation_url": "http://node4:8010/v1/attestation"}
],
"leaving": [],
"error": "",
"join": null
}
A router that does not control the fleet returns the HTTP 503 fleet-state refusal in place of its snapshot. Standbys, fenced routers, and lease holders that shut down are such routers. A standby that takes over adopts the active router's saved snapshot (Membership in the handoff).
POST /narwhal/engines¶
Validates one engine and adds it to the fleet. The request needs the router's control token. The body is one engine entry as the fleet file holds it:
| Field | Type | Default | Meaning |
|---|---|---|---|
iid |
String | required | Engine ID, unique in the membership |
url |
String | required | Engine HTTP base URL |
role |
String | decode |
Role the engine joins in: prefill or decode |
pin |
Boolean | false |
Keep the engine in its role |
attestation_url |
String | "" |
Attestation sidecar URL, required to join |
shared_device |
Object | null |
Shared-GPU allocation. An engine that sets it cannot join |
{
"iid": "e4",
"url": "http://node4:8000",
"attestation_url": "http://node4:8010/v1/attestation",
"role": "decode"
}
The router answers HTTP 422, with the reason in error and join null, when the body:
- is not JSON, or not a JSON object
- has an unknown key, lacks
iidorurl, holds a value of the wrong type, or setsroleto a value other thanprefillordecode - has an
iidthat does not match[A-Za-z0-9._-]+ - has a
url, or a nonemptyattestation_url, that is not anhttporhttpsURL with a host - contains
${anywhere
The router refuses a valid entry before it contacts any engine when:
recovery.engine_restart_policyiswhole_wave- the fleet's
engine_contractis incomplete iidnames a member- another member serves
url - the engine sets
shared_device attestation_urlis emptypinisfalsewhileengine.connectorkeeps the backend's engine roles fixed (fleet validation then requirespinon every engine)- an engine's lifecycle
stateis notactive
Otherwise the router runs these checks with the engine out of placement:
- It reads the new engine's attestation and checks it against
engine_contract. - It reads
profiles.pathagain. The store must hold a profile for each member and the new engine. Each profile must match the process generation of its live engine. The router ignores rows for other engines, such as an engine that left. - When
engine.first_token_calibration_pathhas a value, it reads that artifact again. The artifact must cover every directed pair of the members and the new engine. It must match the process generation of each live engine. - It runs the readmission checks on the new engine in its requested role. It uses
process identityin place ofnew process identity. Themodel identitycheck requires the new engine to attest the model file digests of every member that is not ejected or draining.
When every check passes, the router loads the store and the calibration it read. It adds the engine to the next generation with no resident work and writes the state handoff. A failed handoff write logs a warning. The next monitoring pass writes the handoff again.
| HTTP | Meaning |
|---|---|
200 |
The engine joined, and generation increased by one |
401 |
The request carries no control token, or another one |
409 |
A precondition refused the join, named in error, with join.failures empty |
409 |
A check failed, with join.failures listing the failures and join.checks the checks that passed |
422 |
The body is not a valid engine entry, named in error, with join null |
503 |
router.controls_fleet is false |
503 |
The router lost fleet control during the checks |
DELETE /narwhal/engines/{iid}¶
Drains the engine and removes it from the fleet. The query parameter deadline_s sets the drain deadline in seconds. It defaults to 300 and must be positive and finite.
The drain holds the engine out of placement and records its process identity, as POST /narwhal/lifecycle/drain does. On each monitoring pass, the router removes a drained engine after its requests finish and every decode leg that reads KV from it ends. This includes legs that wait for a decode seat. At the deadline, the engine's lifecycle state becomes deadline_exceeded. The removal still waits for its resident requests to finish. The router does not stop the engine process.
The router refuses the removal when:
recovery.engine_restart_policyiswhole_wave- the fleet's
engine_contractis incomplete - the engine sets
shared_device - another engine is in a lifecycle action
- this engine is in a lifecycle action, unless it is
drained,blockedordeadline_exceededand outside a wave - no other engine is eligible for placement
- fewer engines than
controller.min_prefillpluscontroller.min_decodewould remain
| HTTP | Meaning |
|---|---|
200 |
The engine left at once, and generation increased by one |
202 |
The engine is draining, and leaving lists it |
401 |
The request carries no control token, or another one |
404 |
iid names no member |
409 |
A rule above refused the removal, or deadline_s is zero, negative, or infinite |
422 |
deadline_s is not a number |
503 |
router.controls_fleet is false, or the router lost fleet control during the request |
503 |
Process-identity capture failed, with the engine held out of placement and error naming the cause |
After a process-identity capture failure, the engine stays out of placement, and readmission refuses it because it has no recorded process identity. Repeat the request once the engine and its attestation sidecar answer. Readmission ends a leave.
While the engine drains, a repeated request answers HTTP 202 and keeps the drain's deadline, and GET /narwhal/lifecycle reports its record with leaving: true.