Skip to content

feat(quota): Hold each Machine's quota claim until release - #189

Merged
scotwells merged 4 commits into
feat/manual-inventory-recordsfrom
feat/quota-custody-finalizer
Nov 29, 2026
Merged

scotwells merged 4 commits into
feat/manual-inventory-recordsfrom
feat/quota-custody-finalizer

Conversation

@scotwells

@scotwells scotwells commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fleet adds a finalizer to each Machine quota claim so Milo continues counting a deleting claim while hardware cleanup is pending. Fleet removes its own finalizer when it releases the claim and leaves other actors’ finalizers intact. This implements the quota custody portion of the production admission proposal following #188.

Scope

Fleet restores a missing finalizer on a live claim. Milo does not protect service finalizers from identities with claim update permission, so this does not prevent an authorized updater from removing the finalizer during deletion.

Verification

Quota tests cover external deletion, a removed Fleet finalizer, preservation of another actor’s finalizer, and release ordering. Multiplane acceptance is deferred until the staging stack lands.

@scotwells
scotwells requested review from ecv and kevwilliams November 25, 2026 15:55
@scotwells
scotwells force-pushed the feat/machine-creator-admission branch from 13eb67f to 3009922 Compare November 25, 2026 17:35
@scotwells
scotwells force-pushed the feat/quota-custody-finalizer branch 2 times, most recently from adf1c21 to bf7dc2c Compare November 25, 2026 22:07
scotwells and others added 4 commits November 25, 2026 18:52
Create the Milo quota claim with Fleet's quota custody finalizer. Milo
keeps counting a deleting claim while a finalizer holds it, so a claim
deleted by another actor or by namespace purge keeps its quota until
Fleet releases it. Release deletes the claim, then removes the finalizer
with a conditional update, and reports the quota free only once the
claim is gone. Acquire restores a finalizer removed from a live claim.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Release removes only Fleet's finalizer and stays pending while another
actor still holds the claim, because Milo still counts it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Recreate a Machine with the same project, namespace and name. It gets its
own claim and cannot acquire or release the predecessor's granted claim,
because the claim name hashes the Machine UID and the machine-uid label
must match. The test fails when either guard is removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
State the finalizer, its release order and the acknowledgment once, in
the quota claim section, and drop the overview paragraph that repeated
it. Say that Milo still supplies neither a custody anchor nor an
acknowledgment and does not protect Fleet's finalizer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@scotwells
scotwells force-pushed the feat/machine-creator-admission branch from bd768df to 6878d13 Compare November 26, 2026 01:41
@scotwells
scotwells force-pushed the feat/quota-custody-finalizer branch from bf7dc2c to 7aad3d3 Compare November 26, 2026 01:41
Base automatically changed from feat/machine-creator-admission to feat/manual-inventory-records November 29, 2026 18:58
@scotwells
scotwells marked this pull request as ready for review November 29, 2026 18:59
@scotwells
scotwells requested a review from a team as a code owner November 29, 2026 18:59
@scotwells

Copy link
Copy Markdown
Contributor Author

@ecv — please start pre-reviewing the remaining staging PRs in parallel with #189. No need to wait for each predecessor to merge. Start with #192 (image catalog) and #193 (cleaning policy); they are the roots of the two longest product stacks. For each child, review its incremental diff against its current parent and leave findings or approval on that PR so the review stays attached to the commit.

The drafts are open for preliminary review, not out-of-order merges. I’ll reuse approvals when only the base changes; if a head changes, I’ll call out the delta for re-review. No per-PR multiplane acceptance run is requested.

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

New claims carry fleet.datumapis.com/quota-custody. Acquire restores the finalizer on a live claim that lost it before trusting the grant. Release deletes on a UID precondition, then on a later pass drops only its own finalizer from the deleting claim, on the version read, and leaves other finalizers alone. A claim that someone else deletes keeps counting until Fleet releases it. The tests cover external deletion, a removed finalizer, another actor's finalizer and release ordering.

  • Release now needs update on ResourceClaims to drop the finalizer. No role in this repository grants the manager's Milo identity ResourceClaim permissions, so I could not check it holds update. Without it, every released Machine's claim stays deleting and counted, and the project's Machine quota leaks one per release. Confirm the grant, or run the deferred multiplane acceptance, before this reaches a deployment.
  • Claims created before this change have no finalizer. A live one gains it on its next Acquire. One released before that is deleted at once, as it is today.

Follow-ups:

  • As the PR says, anyone with claim update permission can remove the finalizer during deletion and free the quota early. Worth an issue against Milo for service-owned finalizers, since the custody proposal (#187) depends on it.

@scotwells

Copy link
Copy Markdown
Contributor Author

@ecv Thanks for the approval. Staging deploys from the merge branch, so I’m holding this until the deployment permission is confirmed. I verified the manager’s configured project identity, but my Milo account cannot submit a SubjectAccessReview on the consumer-project route. That denial is for my query, not for Fleet. A platform operator with review privileges can unblock this by confirming update on resourceclaims.quota.miloapis.com for the deployed Fleet manager on the routed consumer project, namespace default. No claim mutation or acceptance run is needed. The independent service-owned-finalizer follow-up is milo-os/milo#1070.

@scotwells
scotwells merged commit a4327a4 into feat/manual-inventory-records Nov 29, 2026
9 checks passed
@scotwells
scotwells deleted the feat/quota-custody-finalizer branch November 29, 2026 19:21
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.

2 participants