Repository navigation
feat(registration): Enable registered capacity - #201
Conversation
f0a1171 to
8983dbf
Compare
4eb4de1 to
12e02fb
Compare
8983dbf to
c18fd24
Compare
12e02fb to
c8fa9ea
Compare
c18fd24 to
2cd8c21
Compare
c8fa9ea to
36b1f80
Compare
2cd8c21 to
4d33448
Compare
36b1f80 to
1bbbf36
Compare
4d33448 to
82aac21
Compare
1bbbf36 to
0a98cec
Compare
d663aff to
197ab3f
Compare
0a98cec to
57bd169
Compare
197ab3f to
0a29e08
Compare
57bd169 to
a3ad54d
Compare
0a29e08 to
e90aba4
Compare
a3ad54d to
e4c3fe7
Compare
e90aba4 to
1d04800
Compare
e4c3fe7 to
0d32bb2
Compare
1d04800 to
2ddd5f6
Compare
0d32bb2 to
84cb7dc
Compare
2ddd5f6 to
f349fc5
Compare
84cb7dc to
97ecc5f
Compare
ecv
left a comment
There was a problem hiding this comment.
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.
decisionPathsininternal/registration/tenancy_test.gostill lists onlycreateandenabling 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 usesystem:mastersactors, so theupdate,deleteand DevicegetSubjectAccessReviews 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 todecisionPaths, 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 trustsrequest.UserInfo.Usernameagainst--capacity-projectors, and an empty list denies every status write. - Allocator:
claimre-reads capacity and Device withcapacityUsableand then callsCustody.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-identitiesis now required and the base manifest ships a placeholder that accepts no real caller. The webhook isfailurePolicy: 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.Cleaningiscapacity.Unresolvedincmd/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.duplicateslists 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.
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>
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>
f349fc5 to
1d08a2b
Compare
01c88ae to
e78eb4d
Compare
|
Thanks, Evan. Everything is addressed at e78eb4d. Multi-plane acceptance passed all four shards on this head.
|
kevwilliams
left a comment
There was a problem hiding this comment.
Only the configured projector writes registered status, both identity flags fail closed, and allocation still decides from live commissioning evidence rather than conditions.
ecv
left a comment
There was a problem hiding this comment.
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:
decisionPathsintenancy_test.gonow listsdeleteandstatusnext tocreateandenabling 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.goadds 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, andstage2_test.goshows an empty projector list denies every status write. - Race test, fixed as documented:
TestDisablingAfterTheLastCheckDoesNotStopTheClaimdisables 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:
duplicateslists Devices in every provider project on each enable; cap or cache it before the fleet grows.- The rollout must set both
--client-identitiesand--capacity-projectorsin 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.
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
Test plan
system:masterswithout update, delete or Device read are refused, and the scope and route tripwires cover the delete and status paths🤖 Generated with Claude Code