Skip to content

feat(capacity): Derive capacity status from commissioning - #200

Merged
scotwells merged 5 commits into
feat/manual-inventory-recordsfrom
feat/device-commissioning-capacity
Nov 28, 2026
Merged

scotwells merged 5 commits into
feat/manual-inventory-recordsfrom
feat/device-commissioning-capacity

Conversation

@scotwells

@scotwells scotwells commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Related to #185 and #131. Stacked on #196.

Whether a server can be allocated now comes only from evidence: its latest commissioning under the current plan, discovery and custody. The allocator evaluates that evidence itself, so editing status cannot make a server allocatable, and a server recorded without a hardware ID is never offered (#131). Every mode, both multi-plane runs included, commissions its servers before it allocates. Nothing ships until the stack reaches the feature branch.

An environment moving from the old synthetic staging must commission its Devices before the first allocation. The cutover steps in the config README give the order, with example manifests, and hack/commissioning-request prints the approval and each commissioning from the stored plan and Device, since both must match them exactly.

Landing

The capacity stack lands first: #182, #219, #208 and #232 (all merged), then #195, #196, #200 and #201. Overlapping PRs on other stacks (cleaning #193, #202, #205, #206 and #207, power #190, NSO and IPAM #198 and #225, virtual media #229) rebase onto it, and #205 adds its NVMe lab drive on top of the lab model in #196.

Decisions for a person

  • The capacity projector's credential. The capacity projector writes capacity status with its own client certificate, which the deployment must supply before this deploys, or the manager cannot start. The shared controller role no longer writes capacity status, so any other user of that role loses that write.
  • The capacity projector's grant. The capacity projector's role must be able to list servers across the provider project, not in one namespace, because a duplicate identity in any namespace withdraws an offer. A test pins this in every mode.
  • Multi-plane dispatch window. The site needs a worker before any allocation exists, but the partition scenario needs the install delivered before any worker. So one source revision enables dispatch for the commissioning and the next disables it. When dispatch comes back, or the graph lifecycle recreates workers, the finished commissioning's worker runs again and either replays a no-op or is refused by the server's fence. It sends nothing either way, and the evidence checks that in both modes.
  • Allocation cost. An allocation pass reads each candidate's server and custody first, evaluates only identified, free capacity, and lists servers, plans, approvals and commissionings once per pass. One capacity that fails to evaluate is skipped. A watch-backed cache could cut the per-pass lists further if provider projects grow large.
  • Cleaning policy. No production cleaning policy resolver exists, so no production capacity becomes available until one does. Decided: Fleet owns it, built on the cleaning policy pinned at allocation (docs: Propose cleaning policies for reusing servers #183, feat(cleaning): Add CleaningPolicy and pin it at allocation #193), and it lands with the cleaning stack after this one. feat(registration): Enable registered capacity #201 records this in the registration doc.

Test plan

  • Tests pass with the race detector against a real API server, in every mode
  • A new failed run or a replacing plan withdraws the next offer with no projector pass in between
  • A hand-edited status, a failed re-commission, a server without a hardware ID, and a capacity whose evaluation fails never lead to a wrong allocation
  • The standalone smoke commissions its server as three people, then allocates, installs, releases and reuses it, and both multi-plane runs, local VM and Redfish, pass their flux and release shards with commissioning on the top of the stack
  • In local VM mode, the replayed commissioning leaves its journal and boot record as the commission phase left them; harness tests show a replayed step or a touched boot record fails that check

🤖 Generated with Claude Code

@scotwells
scotwells requested review from ecv and kevwilliams November 25, 2026 17:07
@scotwells
scotwells force-pushed the feat/device-commissioning-redfish branch from c982b26 to 0f5e486 Compare November 25, 2026 18:23
@scotwells
scotwells force-pushed the feat/device-commissioning-capacity branch from f0a1171 to 8983dbf Compare November 25, 2026 18:23
@scotwells
scotwells force-pushed the feat/device-commissioning-redfish branch from 0f5e486 to a9d9b36 Compare November 25, 2026 21:36
@scotwells
scotwells force-pushed the feat/device-commissioning-capacity branch from 8983dbf to c18fd24 Compare November 25, 2026 21:36
@scotwells
scotwells force-pushed the feat/device-commissioning-redfish branch from a9d9b36 to ee30ce8 Compare November 25, 2026 22:28
@scotwells
scotwells force-pushed the feat/device-commissioning-capacity branch from c18fd24 to 2cd8c21 Compare November 25, 2026 22:28
@scotwells
scotwells force-pushed the feat/device-commissioning-redfish branch from ee30ce8 to 4ff43c3 Compare November 25, 2026 22:51
@scotwells
scotwells force-pushed the feat/device-commissioning-capacity branch 2 times, most recently from 4d33448 to 82aac21 Compare November 25, 2026 23:04
@scotwells
scotwells force-pushed the feat/device-commissioning-redfish branch from 4ff43c3 to c3c3e51 Compare November 28, 2026 01:25
@scotwells
scotwells force-pushed the feat/device-commissioning-capacity branch 2 times, most recently from d663aff to 197ab3f Compare November 28, 2026 01:48
@scotwells
scotwells force-pushed the feat/device-commissioning-redfish branch from c3c3e51 to 3888640 Compare November 28, 2026 02:43
@scotwells
scotwells force-pushed the feat/device-commissioning-capacity branch from 197ab3f to 0a29e08 Compare November 28, 2026 02:43
@scotwells
scotwells force-pushed the feat/device-commissioning-redfish branch from 3888640 to 4edbd10 Compare November 28, 2026 03:10
@scotwells
scotwells force-pushed the feat/device-commissioning-capacity branch from 0a29e08 to e90aba4 Compare November 28, 2026 03:10
@scotwells
scotwells force-pushed the feat/device-commissioning-redfish branch from 4edbd10 to 402c071 Compare November 28, 2026 03:55
@scotwells
scotwells force-pushed the feat/device-commissioning-capacity branch from e90aba4 to 1d04800 Compare November 28, 2026 03:55
@scotwells
scotwells force-pushed the feat/device-commissioning-capacity branch from 1d04800 to 2ddd5f6 Compare November 28, 2026 14:46
@scotwells
scotwells force-pushed the feat/device-commissioning-redfish branch from 49ccca5 to b7ceaad Compare November 28, 2026 16:30
@scotwells
scotwells force-pushed the feat/device-commissioning-capacity branch from 2ddd5f6 to f349fc5 Compare November 28, 2026 16:30
@scotwells
scotwells marked this pull request as ready for review November 28, 2026 17:13
@scotwells
scotwells requested a review from a team as a code owner November 28, 2026 17:13
@scotwells
scotwells removed the request for review from a team November 28, 2026 17:13

@kevwilliams kevwilliams left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hold: after rollout synthetic staging has no allocatable capacity, and the cutover runbook never says why.

  • ensureObservation and the synthetic Prepared/Healthy/Available conditions are removed, so every existing capacity reads Prepared=False NotCommissioned. That fails closed correctly, but config/README.md never mentions commissioning, so step 8, "verify a fresh allocation", fails with insufficient capacity.
  • Fix: add cutover steps that create the plan, approval and a commissioning per synthetic Device, including the plan-approver and operator identities and the new enrollment hardware field.

@ecv ecv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve with follow-ups.

Capacity status is now derived from commissioning evidence by a dedicated projector, and the allocator decides from the same projection on live inputs, so nothing a device has not earned is offered. The follow-ups are the rollout steps and a few permissions that can be narrower.

  • Capacity cannot be reported for an uncommissioned device: ProjectCapacity in internal/custody/capacity.go makes Prepared false without a succeeded commissioning, a Passed result, a plan whose reference matches the evidence, and a Device UID that matches. Healthy then needs evidence inside the plan's lifetime, current discovery, and the recorded serial, system UUID and BMC key unchanged. Available needs Verified custody, no hold, no holder, an enabled policy, no duplicate identity and a resolving cleaning policy.
  • Regression is handled: the latest succeeded commissioning is read live, so a later Failed result gives CommissioningFailed, a changed plan gives PlanChanged, and expiry or an identity change gives EvidenceExpired or IdentityChanged. The allocator calls Offer/Evaluate on live inputs and does not read the stored conditions, so a stale status cannot make a server allocatable; it can only mislead a reader of the status until the next ProjectAll pass.
  • RBAC in config/standalone/rbac.yaml narrows the provider writer (it loses machinecapacities/status) and adds one account per duty: projector, plan author, plan approver and operator. The author cannot approve and the approver cannot create plans. The capacity-projector role is read-only apart from updateStatus.
  • Agree with kevwilliams on the cutover: after rollout every existing capacity reads Prepared=False NotCommissioned, which fails closed, but config/README.md never says why step 8 (fresh allocation) fails. Add steps to create the plan, the approval and one commissioning per synthetic device, with the approver and operator identities.

Follow-ups:

  • The new fleet-standalone-smoke-devices ClusterRoleBinding gives the smoke account cluster-wide Device read. Scope it to the provider namespace if the smoke does not need the duplicate scan.
  • The projector reads Devices in every namespace for duplicate detection (the comment says why). Record that this is a deliberate widening in the role description too.
  • Add a test that a commissioning which regresses after a pass (new failed run, or plan replaced) flips the next Offer to false without a projector pass.
  • This PR is based on feat/device-commissioning-redfish, so it merges only after #196 does.

scotwells added a commit that referenced this pull request Nov 28, 2026
Kubernetes RBAC cannot grant write on one spec field, so the capacity
operator could have dropped the block in a write that offers or
withdraws. Admission now rejects any add, change, or removal of the
supply hold part from a caller without its own permission.

Removal entries are stamped from the caller like the other identity
fields, and removing the block while a check is open is refused. The
text now says where it relies on behavior only proposed in #200 and
#201, and the summary example uses the API group that exists on main.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
scotwells and others added 5 commits November 28, 2026 11:35
The simulator and the local VM site gain DeviceCommissioning workers, and
the multi-plane sites register them alongside the Redfish one. A synthetic
target has no BMC, so both compare the hardware and firmware the site
enrolls for the Device with the plan. The simulator records one burn-in
step. The local VM boots the site image once in burn-in mode on a scratch
disk, reads its one result by receipt and removes the disk.

The base site enrollment describes its synthetic Device's hardware so a
commissioning can inspect it. Nothing creates a commissioning until the
coordinator and allocator use commissioning evidence.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The capacity projector now writes Prepared, Healthy, Available and the
hardware of every MachineCapacity, from the Device's latest commissioning
under its current plan, discovery, custody, the cleaning policy resolver
and duplicate identities. It runs in the coordinator loop with its own
identity in every mode, and the Metal controller role no longer writes
capacity status. It re-reads the current plan each pass, so a plan
revoked after admission makes nothing Prepared.

Capacity counts its Device only while the Device is the incarnation
registration recorded, never backs a Device without a hardware ID (#131),
and needs evidence naming the current plan's name, generation, digest
and approval. Serials compare without surrounding space on either side.

The allocator no longer reads conditions: it evaluates each candidate from
live evidence and pins the hardware commissioning inspected, so an edited
status cannot make a server allocatable. It reads a candidate's Device
and custody first and evaluates only identified, visibly free capacity.
One allocation pass, like one projector pass, lists Devices, plans,
approvals and commissionings once instead of once per capacity. A
capacity whose reads or evaluation fail is skipped, and the error is
returned only when nothing is offered. Every identity that evaluates
capacity lists Devices project-wide in every mode, which a test pins.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every mode commissions its servers instead of writing fixture
conditions. The standalone smoke and both multi-plane runs commission as
a plan author, an approver and an operator before allocating. The
multi-plane runs open a dispatch window for the commissioning with one
source revision and close it with the next, so the install is still
delivered before any worker Job, and the install scenarios count only
the other assignments. The Redfish run's plan requires the lab's
firmware inventory.

kro recreates the finished commissioning's Job later in the run. In
Redfish mode the BMC audit, boot count and receipts prove that replay
sent nothing. In local VM mode a new commission-mark phase records
digests of the commissioning's journal and boot record, and the evidence
phase requires both unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
After rollout every synthetic capacity reads Prepared=False
NotCommissioned, so the cutover's "verify a fresh allocation" failed
with insufficient capacity and the runbook never said why.

Add the commissioning steps in order: three identities with the author
and approver two different people, the plan, its approval, hardware and
firmware in the site enrollment, one commissioning per Device, the wait
for Prepared and Available, and only then the allocation check. The
approval and the commissioning must match the stored plan exactly, so a
small hack/commissioning-request command prints them from the objects
the API server returns, with a test that its output is what custody
computes.

Say why the smoke's Device read and the capacity projector's are
cluster-wide: the duplicate identity scan reads every namespace.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A commissioning that regresses after a pass, by a new run that fails or
a plan that replaces the one it passed under, must withdraw the next
offer before any projector pass rewrites status. The test stops the
projector, regresses the Device, and checks that the written status
still says Available while Offer and the allocator refuse the server.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@scotwells
scotwells force-pushed the feat/device-commissioning-redfish branch from b7ceaad to 54d9276 Compare November 28, 2026 17:59
@scotwells
scotwells force-pushed the feat/device-commissioning-capacity branch from f349fc5 to 1d08a2b Compare November 28, 2026 17:59

@kevwilliams kevwilliams left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cutover now defers the allocation check until each synthetic Device is commissioned, and walks through role bindings, plan, two-person approval, enrollment hardware and commissioning.

@scotwells

Copy link
Copy Markdown
Contributor Author

Thanks, both. Kevin approved b852ef5/1d08a2ba. Here is the delta for Evan's follow-ups:

  • Cutover runbook (b852ef5). config/README.md now runs the seven steps in order: role bindings, plan, approval by a different person, enrollment hardware and firmware, one commissioning per Device, wait for Prepared and Available, then allocate. The approval's name and digest, and each commissioning's plan copy, must match the stored plan exactly. A small read-only hack/commissioning-request command prints them, using the same custody functions the coordinator and projector use.
  • Smoke ClusterRoleBinding. It stays cluster-wide. The smoke's allocator uses the projector as its offer source, and the projector's duplicate check lists Devices in every namespace, so a namespaced binding would fail every offer. The binding comment says so, and the capacity-projector role description now calls its cluster-wide Device read a deliberate widening.
  • Regression test (1d08a2b). TestARegressionWithdrawsTheNextOffer covers a new failed run and a replaced plan, and checks that each flips the next Offer to false without a projector pass. Making Offer trust the stored status fails it.

Follow-up, not in this PR: the local VM commissioning worker still times burn-in from VM start to the journaled verdict. It's a test-environment worker, and production sites use the Redfish worker fixed in #196.

@scotwells
scotwells requested review from ecv and kevwilliams November 28, 2026 18:57

@ecv ecv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve.

The cutover gap is closed and three of the four follow-ups are done. I compared the PR's own commits (dbfdfc4, 0fca357, f0cb8b7, b852ef5, 1d08a2b); the old head is no longer fetchable.

  • Agree with kevwilliams on the cutover, fixed: config/README.md now has a "Commissioning the synthetic Devices" section. It says why the capacities read NotCommissioned and allocation fails until they are commissioned. It then walks through the role bindings, plan, two-person approval (hack/commissioning-request builds the approval), enrollment hardware, one commissioning per Device and the wait for Prepared and Available. The fresh-allocation step now waits for that.
  • Regression test, fixed: 1d08a2b adds a test that a regressed offer is withdrawn live, without a projector pass.
  • Projector widening, fixed: the capacity-projector role description says it reads Devices in every namespace deliberately, so a duplicate identity elsewhere withdraws the offer.
  • Smoke account binding, not fixed: fleet-standalone-smoke-devices still gives the smoke account cluster-wide Device read through the coordinator Devices ClusterRole. Still a follow-up, not a hold.
  • Nothing in the new fix commits weakened the fail-closed default: capacity stays Prepared=False until commissioning passes.
  • CI is green, including standalone-smoke on this head.

Follow-ups:

  • Scope the smoke account's Device read to the provider namespace if the smoke does not need the duplicate scan.
  • This PR is based on feat/device-commissioning-redfish, so it merges only after #196 does.

Base automatically changed from feat/device-commissioning-redfish to feat/manual-inventory-records November 28, 2026 19:13
@scotwells
scotwells merged commit 94ec253 into feat/manual-inventory-records Nov 28, 2026
15 checks passed
@scotwells
scotwells deleted the feat/device-commissioning-capacity branch November 28, 2026 19:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants