dra: enable adding ReservedFor entries through strategic-merge-patch

When moving the reservation of a claim for a pod into the PreBind phase in a
future commit, multiple different update attempts will be executed
concurrently. We want an attempt to succeed if and only if adding the entry
passes validation. Without patch strategy and key, strategic-merge-patch
replaces the entire ReservedFor instead of adding new entries.

Server-side-apply cannot be used because each attempt may start with a stale
ResourceClaim (thus cannot send the entire ReservedFor) and SSA doesn't support
merging when using the same manager string. Using different managers (one for
each entry) would work, but sounds like a bad hack.
This commit is contained in:
Patrick Ohly 2023-11-14 13:49:02 +01:00
parent 0c645922ed
commit 324816a883
5 changed files with 14 additions and 4 deletions

View File

@ -14387,7 +14387,9 @@
"x-kubernetes-list-map-keys": [
"uid"
],
"x-kubernetes-list-type": "map"
"x-kubernetes-list-type": "map",
"x-kubernetes-patch-merge-key": "uid",
"x-kubernetes-patch-strategy": "merge"
}
},
"type": "object"

View File

@ -478,7 +478,9 @@
"x-kubernetes-list-map-keys": [
"uid"
],
"x-kubernetes-list-type": "map"
"x-kubernetes-list-type": "map",
"x-kubernetes-patch-merge-key": "uid",
"x-kubernetes-patch-strategy": "merge"
}
},
"type": "object"

View File

@ -42805,7 +42805,9 @@ func schema_k8sio_api_resource_v1alpha2_ResourceClaimStatus(ref common.Reference
"x-kubernetes-list-map-keys": []interface{}{
"uid",
},
"x-kubernetes-list-type": "map",
"x-kubernetes-list-type": "map",
"x-kubernetes-patch-merge-key": "uid",
"x-kubernetes-patch-strategy": "merge",
},
},
SchemaProps: spec.SchemaProps{

View File

@ -257,6 +257,8 @@ message ResourceClaimStatus {
//
// +listType=map
// +listMapKey=uid
// +patchStrategy=merge
// +patchMergeKey=uid
// +optional
repeated ResourceClaimConsumerReference reservedFor = 3;

View File

@ -114,8 +114,10 @@ type ResourceClaimStatus struct {
//
// +listType=map
// +listMapKey=uid
// +patchStrategy=merge
// +patchMergeKey=uid
// +optional
ReservedFor []ResourceClaimConsumerReference `json:"reservedFor,omitempty" protobuf:"bytes,3,opt,name=reservedFor"`
ReservedFor []ResourceClaimConsumerReference `json:"reservedFor,omitempty" protobuf:"bytes,3,opt,name=reservedFor" patchStrategy:"merge" patchMergeKey:"uid"`
// DeallocationRequested indicates that a ResourceClaim is to be
// deallocated.