Repository navigation
fix: Refuse a claim that requests one type twice - #983
Merged
Merged
Conversation
A claim holds one allocation per resource type, so its requests are now a map list keyed by resourceType and the API server refuses a second request of one type. A claim stored before keeps working: the API server ratchets a list-map rule that the stored object already broke, so its updates, status, finalizers and deletion are accepted.
ecv
approved these changes
Nov 3, 2026
ecv
left a comment
Contributor
There was a problem hiding this comment.
Approve.
The +listType=map on spec.requests keyed by resourceType is the rule asked for on milo#978, and the upgrade path is tested: CI is green at 6995ac7 including ci / Build and test.
- Pre-existing duplicates are covered:
TestResourceClaimStoredWithTwoRequestsOfOneTypeStaysUpdatablestores a duplicate under the old schema, swaps in the new CRD, then requires a finalizer update, a status update, finalizer removal and delete to all succeed. That matches CRD validation ratcheting for list-map uniqueness, so no stored claim gets stuck. resourceTypeis required onResourceRequest, so the map key is valid and the CRD installs; the envtest installs the generated CRD, which proves it.- The test fails hard when
KUBEBUILDER_ASSETSis unset in CI, so it cannot skip silently.
Follow-ups:
- Ratcheting only covers unchanged duplicates. A controller or client that rewrites
spec.requestson a legacy claim while keeping the duplicate is fine, but any edit that changes the duplicate entries will be refused; worth a note in the release text. - Count legacy duplicates in production before the tag (a one-off list across projects), so any caller still producing them shows up as a failed create rather than a surprise.
Contributor
Author
|
Both follow-ups go with the release that carries this:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related to #978.
A claim holds one allocation per resource type, but its schema let it request one type twice; only the doc comment said once. The requests are now a map list keyed by
resourceType, as the claim's allocations already are, so the API server refuses the second request. A claim stored before keeps working, because the API server ratchets a list-map rule that the stored object already broke.Corner cases
TestResourceClaimRefusesTwoRequestsOfOneTypeTestResourceClaimStoredWithTwoRequestsOfOneTypeStaysUpdatable, and apiextensions-apiserver's ratchetingresourceTypeinstead of replacing the listTest plan
main(the claim is stored; the upgraded schema never refuses) and pass here, 3 runs of 3, with envtest 1.37.0.task generatechanges only the claim CRD's two list lines.go test ./pkg/apis/quota/... ./internal/quota/...passes.