Skip to content

feat(registration): Enable registered capacity - #201

Merged
scotwells merged 5 commits into
feat/manual-inventory-recordsfrom
feat/registration-stage-2
Nov 28, 2026
Merged

scotwells merged 5 commits into
feat/manual-inventory-recordsfrom
feat/registration-stage-2

Conversation

@scotwells

@scotwells scotwells commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Related to #185. Stacked on #200.

Registered capacity can now be enabled. A capacity operator gives it a pool and a resolving cleaning policy once its server is the registered, active one with no duplicate, and can remove capacity whose server is gone or retired. Only the capacity projector may write its status, and the webhook accepts only configured API server identities. Because enabled capacity can now be offered, the allocator withdraws an unclaimed allocation whose capacity was disabled or removed, or whose server was recreated. A claim already past that check still completes if the capacity is disabled in between: the custody claim cannot be made conditional on a second object, so the registration doc records the window and a test pins it.

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

  • Deployment values. The base manifest's API server client identities and projector username are placeholders that refuse every caller, which also blocks operation creates on the same server. The deployment must set the client identities and the projector username together with this release.

Test plan

  • Tests pass with the race detector, including the packaged webhook against a real API server: changing any field other than the allocation policy, cleaning policy and pool label is denied, and orphaned capacity is removed only when Disabled with no unreleased allocation
  • A certificate from the right authority with an unlisted subject is refused during the handshake
  • Capacity registered for an earlier server incarnation is never offered, selected or claimed
  • Callers outside system:masters without update, delete or Device read are refused, and the scope and route tripwires cover the delete and status paths
  • Both multi-plane runs pass on this head

🤖 Generated with Claude Code

@scotwells
scotwells requested review from ecv and kevwilliams November 25, 2026 17:14
@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/registration-stage-2 branch from 4eb4de1 to 12e02fb Compare November 25, 2026 18:23
@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/registration-stage-2 branch from 12e02fb to c8fa9ea Compare November 25, 2026 21:36
@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/registration-stage-2 branch from c8fa9ea to 36b1f80 Compare November 25, 2026 22:28
@scotwells
scotwells force-pushed the feat/device-commissioning-capacity branch from 2cd8c21 to 4d33448 Compare November 25, 2026 22:51
@scotwells
scotwells force-pushed the feat/registration-stage-2 branch from 36b1f80 to 1bbbf36 Compare November 25, 2026 22:51
@scotwells
scotwells force-pushed the feat/device-commissioning-capacity branch from 4d33448 to 82aac21 Compare November 25, 2026 23:04
@scotwells
scotwells force-pushed the feat/registration-stage-2 branch from 1bbbf36 to 0a98cec Compare November 25, 2026 23:04
@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/registration-stage-2 branch from 0a98cec to 57bd169 Compare November 28, 2026 01:51
@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/registration-stage-2 branch from 57bd169 to a3ad54d Compare November 28, 2026 02:43
@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/registration-stage-2 branch from a3ad54d to e4c3fe7 Compare November 28, 2026 03:10
@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/registration-stage-2 branch from e4c3fe7 to 0d32bb2 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/registration-stage-2 branch from 0d32bb2 to 84cb7dc Compare November 28, 2026 14:46
@scotwells scotwells changed the title feat(registration): Let registered capacity be enabled feat(registration): Enable registered capacity Nov 28, 2026
@scotwells
scotwells force-pushed the feat/device-commissioning-capacity branch from 2ddd5f6 to f349fc5 Compare November 28, 2026 16:30
@scotwells
scotwells force-pushed the feat/registration-stage-2 branch from 84cb7dc to 97ecc5f Compare November 28, 2026 16:30
@scotwells scotwells added multiplane-acceptance Run the multiplane acceptance suites on GitHub-hosted runners and removed multiplane-acceptance Run the multiplane acceptance suites on GitHub-hosted runners labels Nov 28, 2026
@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

@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.

Request changes.

Registered capacity can now be enabled, disabled, deleted and status-written through admission and the allocator re-checks capacity before claiming, but the new authorization and tenancy paths are tested only for callers who are allowed and the allocator's new check has no race test.

  • The new stage-2 admission paths are not covered by negative cross-tenant or unauthorized-caller tests. decisionPaths in internal/registration/tenancy_test.go still lists only create and enabling update, so the out-of-scope-project and mismatched-route tripwires never run for the new status write, disable and delete paths. The stage2 envtests use system:masters actors, so the update, delete and Device get SubjectAccessReviews are never denied, and no test shows a caller without update on the capacity (or without get on the Device) is refused. Add status and delete to decisionPaths, and add denied-caller cases for enable and delete.
  • The project check runs before the new status, update and delete branches in Handle, and each branch checks the caller's own permission, so I found no hole in the code, only an unrun guard. The status branch trusts request.UserInfo.Username against --capacity-projectors, and an empty list denies every status write.
  • Allocator: claim re-reads capacity and Device with capacityUsable and then calls Custody.Claim, so capacity disabled between those two calls can still be claimed. The conditional custody claim protects the Device, not the capacity's enabled state. No test exercises that interleaving. Add a concurrency test that disables the capacity between the check and the claim, or state in the doc that Disable stops new selections but not one already past the check.
  • Delete admission blocks while any non-Released allocation names the capacity, and the allocator withdraws an allocation whose capacity is gone or Disabled before it claims. That closes the delete race, since the allocation exists before it can claim.
  • --client-identities is now required and the base manifest ships a placeholder that accepts no real caller. The webhook is failurePolicy: Fail, so an environment that does not set both flags refuses every registration create. The doc says so (inventory-capacity-registration.md), but the rollout needs to set them in the same change.

Follow-ups:

  • handler.Cleaning is capacity.Unresolved in cmd/fleet-registration/main.go, so no registered capacity can be enabled until the cleaning policy owner provides a resolver. State the owner and issue in the doc.
  • duplicates lists Devices in every provider project on each enable. Fine at this scale, but cap or cache it before the fleet grows.
  • This PR is based on feat/device-commissioning-capacity, so it merges only after #200 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:59
Registration stage 2. The webhook admits updates of registered capacity
that change only the allocation policy, the cleaning policy and the pool
label, keeps them frozen while the capacity is enabled, and enables it
only for the registered, Active Device with a complete identity, a pool,
a resolving cleaning policy and no duplicate identity in the provider
scope. Disabled capacity whose Device is gone or Retired, and that no
unreleased allocation names, can now be removed. Registration and the
projector share the annotation that records the Device incarnation.

Status writes to registered capacity are routed and admitted only from
the capacity projector. The webhook accepts a client only if its
certificate's subject is a configured API server identity. The base
manifest's placeholders refuse every caller until a deployment sets
them. No production cleaning policy resolver exists yet, so production
can enable nothing until its owner provides one.

Enabling makes registered capacity offerable, so the allocator now guards
the incarnation it allocates against. An allocation that has not claimed
its Device is withdrawn when its capacity was disabled or removed, or
when the Device is no longer the incarnation the allocation names, and
selection skips capacity registered for another incarnation. Custody's
claim already refused a Device recreated after that last check; a test
now pins it with custody still naming the old incarnation, which fails
without the claim's check of the live Device.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Say in the stage 2 contract what was only in the review notes: nothing
catches a duplicate recorded between the allocator's check and its
custody claim, and the BMC-proven serial and system UUID are why that is
harmless. Record why the incarnation guard lands with stage 2, and that
the custody claim's check predates it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The feature branch gained a test that replaces the handler's authorizer
with the six-argument signature. This stack's registered capacity change
adds the verb argument, so after the rebase the registration tests no
longer compile. The test now takes and ignores the verb; what it checks
is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The out-of-scope-project and mismatched-route tripwires now run on the
delete and status paths too. The status write must resolve no project
and read nothing, so the route test checks that instead of a denial.

Envtest adds callers outside system:masters, each missing one
permission: without update on the capacity enabling is refused, without
delete the removal is refused, and without get on the Device both are
refused by the webhook's own review.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The custody claim is a conditional update of the Device's custody alone,
and Kubernetes has no write conditional on a second object, so the claim
cannot also require the capacity unchanged. Instead of claiming to close
the gap, pin it: a test disables the capacity between the allocator's
last check and its custody claim, and shows the claim holds while no new
allocation lands on the capacity. The registration doc says Disable stops
new selections, not one already past the check.

The doc also records that Fleet owns the cleaning-policy resolver, built
on the policy pinned at allocation, and that it lands with the cleaning
stack.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@scotwells
scotwells force-pushed the feat/device-commissioning-capacity branch from f349fc5 to 1d08a2b Compare November 28, 2026 17:59
@scotwells
scotwells force-pushed the feat/registration-stage-2 branch from 01c88ae to e78eb4d Compare November 28, 2026 17:59
@scotwells scotwells added multiplane-acceptance Run the multiplane acceptance suites on GitHub-hosted runners and removed multiplane-acceptance Run the multiplane acceptance suites on GitHub-hosted runners labels Nov 28, 2026
@scotwells

Copy link
Copy Markdown
Contributor Author

Thanks, Evan. Everything is addressed at e78eb4d. Multi-plane acceptance passed all four shards on this head.

  1. Tripwires (0b2e733). decisionPaths now includes delete and status. The status write resolves no project, because it has no tenant and is judged by the projector's identity, so its route test checks that it reads nothing and touches neither the client nor the authorizer.
  2. Denied callers. New envtest cases use callers outside system:masters. A caller without update on the capacity is refused enable, one without delete is refused delete, and one without get on the Device is refused both, by the webhook's own access review. The refused callers change nothing. Making Authorize always allow fails the Device-read case.
  3. Disable versus claim (e78eb4d). This is documented and pinned rather than closed. A custody update can't be conditional on a second object, and a re-check after the claim would only narrow the window. TestDisablingAfterTheLastCheckDoesNotStopTheClaim disables the capacity between the check and the claim. The claim holds, and the next allocation finds no capacity. The registration doc says Disable stops new selections but not a claim already past its check, and that allocation is then released the normal way.
  4. Cleaning resolver. The doc now says Fleet owns it, built on the policy pinned at allocation (docs: Propose cleaning policies for reusing servers #183, feat(cleaning): Add CleaningPolicy and pin it at allocation #193), and that it lands with the cleaning stack.
  5. Placeholders. As you noted, the deployment sets --client-identities and --capacity-projectors in the same change as this release.

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

@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.

Only the configured projector writes registered status, both identity flags fail closed, and allocation still decides from live commissioning evidence rather than conditions.

@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.

Both gaps are closed: unauthorized and cross-tenant callers are now refused on the new delete and status paths, and the allocator's check-then-claim window is pinned by a test and stated in the doc. I compared the PR's own commits (b2a9dfb, 0336dac, 0d15b70, 0b2e733, e78eb4d); the old head is gone after the rebase.

  • Negative tests, fixed: decisionPaths in tenancy_test.go now lists delete and status next to create and enabling update, so the out-of-scope-project and mismatched-route tripwires run on every new path. For status the route test asserts it resolves no project and reads nothing.
  • Unauthorized callers, fixed: stage2_envtest_test.go adds non-masters, each missing one permission. A caller without update on the capacity is Forbidden when enabling, one without delete is Forbidden on removal, and one without get on the Device is refused by the webhook's own review on both. The test checks the capacity is unchanged or still present after each refusal. A caller who is not the projector is refused on the status write, and stage2_test.go shows an empty projector list denies every status write.
  • Race test, fixed as documented: TestDisablingAfterTheLastCheckDoesNotStopTheClaim disables the capacity between the allocator's last check and the custody claim. It shows the claim holds and no new allocation lands on the Disabled capacity. The doc now says Disable stops new selections but not a claim already past the check, and that the capacity cannot be removed while that allocation is not Released. I accept this because custody and capacity are two objects, but it is documented rather than closed.
  • Cleaning resolver, fixed: the doc now names Fleet as owner, built on the policy pinned at allocation (#183, #193), landing with the cleaning stack.
  • CI is green, including the localvm and redfish acceptance runs. The envtest suites skip locally without KUBEBUILDER_ASSETS, so I did not run my own tamper test (removing a guard); CI is the evidence.

Follow-ups:

  • duplicates lists Devices in every provider project on each enable; cap or cache it before the fleet grows.
  • The rollout must set both --client-identities and --capacity-projectors in the same change as this lands, because the webhook fails closed without them.
  • This PR is based on feat/device-commissioning-capacity, so it merges only after #200 does.

Base automatically changed from feat/device-commissioning-capacity to feat/manual-inventory-records November 28, 2026 19:34
@scotwells
scotwells merged commit c958da5 into feat/manual-inventory-records Nov 28, 2026
20 checks passed
@scotwells
scotwells deleted the feat/registration-stage-2 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

multiplane-acceptance Run the multiplane acceptance suites on GitHub-hosted runners

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants