Skip to content

Commit e0dafe5

Browse files
authored
Merge pull request #117351 from pohly/dra-generated-resource-claim-names
DRA: generated resource claim names
2 parents e1fbd0c + fec2578 commit e0dafe5

File tree

38 files changed

+2402
-1179
lines changed

38 files changed

+2402
-1179
lines changed

api/openapi-spec/swagger.json

Lines changed: 31 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/openapi-spec/v3/api__v1_openapi.json

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@
699699
"type": "string"
700700
},
701701
"resourceClaimTemplateName": {
702-
"description": "ResourceClaimTemplateName is the name of a ResourceClaimTemplate object in the same namespace as this pod.\n\nThe template will be used to create a new ResourceClaim, which will be bound to this pod. When this pod is deleted, the ResourceClaim will also be deleted. The name of the ResourceClaim will be <pod name>-<resource name>, where <resource name> is the PodResourceClaim.Name. Pod validation will reject the pod if the concatenated name is not valid for a ResourceClaim (e.g. too long).\n\nAn existing ResourceClaim with that name that is not owned by the pod will not be used for the pod to avoid using an unrelated resource by mistake. Scheduling and pod startup are then blocked until the unrelated ResourceClaim is removed.\n\nThis field is immutable and no changes will be made to the corresponding ResourceClaim by the control plane after creating the ResourceClaim.",
702+
"description": "ResourceClaimTemplateName is the name of a ResourceClaimTemplate object in the same namespace as this pod.\n\nThe template will be used to create a new ResourceClaim, which will be bound to this pod. When this pod is deleted, the ResourceClaim will also be deleted. The pod name and resource name, along with a generated component, will be used to form a unique name for the ResourceClaim, which will be recorded in pod.status.resourceClaimStatuses.\n\nThis field is immutable and no changes will be made to the corresponding ResourceClaim by the control plane after creating the ResourceClaim.",
703703
"type": "string"
704704
}
705705
},
@@ -4980,6 +4980,24 @@
49804980
],
49814981
"type": "object"
49824982
},
4983+
"io.k8s.api.core.v1.PodResourceClaimStatus": {
4984+
"description": "PodResourceClaimStatus is stored in the PodStatus for each PodResourceClaim which references a ResourceClaimTemplate. It stores the generated name for the corresponding ResourceClaim.",
4985+
"properties": {
4986+
"name": {
4987+
"default": "",
4988+
"description": "Name uniquely identifies this resource claim inside the pod. This must match the name of an entry in pod.spec.resourceClaims, which implies that the string must be a DNS_LABEL.",
4989+
"type": "string"
4990+
},
4991+
"resourceClaimName": {
4992+
"description": "ResourceClaimName is the name of the ResourceClaim that was generated for the Pod in the namespace of the Pod. It this is unset, then generating a ResourceClaim was not necessary. The pod.spec.resourceClaims entry can be ignored in this case.",
4993+
"type": "string"
4994+
}
4995+
},
4996+
"required": [
4997+
"name"
4998+
],
4999+
"type": "object"
5000+
},
49835001
"io.k8s.api.core.v1.PodSchedulingGate": {
49845002
"description": "PodSchedulingGate is associated to a Pod to guard its scheduling.",
49855003
"properties": {
@@ -5483,6 +5501,24 @@
54835501
"description": "Status of resources resize desired for pod's containers. It is empty if no resources resize is pending. Any changes to container resources will automatically set this to \"Proposed\"",
54845502
"type": "string"
54855503
},
5504+
"resourceClaimStatuses": {
5505+
"description": "Status of resource claims.",
5506+
"items": {
5507+
"allOf": [
5508+
{
5509+
"$ref": "#/components/schemas/io.k8s.api.core.v1.PodResourceClaimStatus"
5510+
}
5511+
],
5512+
"default": {}
5513+
},
5514+
"type": "array",
5515+
"x-kubernetes-list-map-keys": [
5516+
"name"
5517+
],
5518+
"x-kubernetes-list-type": "map",
5519+
"x-kubernetes-patch-merge-key": "name",
5520+
"x-kubernetes-patch-strategy": "merge,retainKeys"
5521+
},
54865522
"startTime": {
54875523
"allOf": [
54885524
{

api/openapi-spec/v3/apis__apps__v1_openapi.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1579,7 +1579,7 @@
15791579
"type": "string"
15801580
},
15811581
"resourceClaimTemplateName": {
1582-
"description": "ResourceClaimTemplateName is the name of a ResourceClaimTemplate object in the same namespace as this pod.\n\nThe template will be used to create a new ResourceClaim, which will be bound to this pod. When this pod is deleted, the ResourceClaim will also be deleted. The name of the ResourceClaim will be <pod name>-<resource name>, where <resource name> is the PodResourceClaim.Name. Pod validation will reject the pod if the concatenated name is not valid for a ResourceClaim (e.g. too long).\n\nAn existing ResourceClaim with that name that is not owned by the pod will not be used for the pod to avoid using an unrelated resource by mistake. Scheduling and pod startup are then blocked until the unrelated ResourceClaim is removed.\n\nThis field is immutable and no changes will be made to the corresponding ResourceClaim by the control plane after creating the ResourceClaim.",
1582+
"description": "ResourceClaimTemplateName is the name of a ResourceClaimTemplate object in the same namespace as this pod.\n\nThe template will be used to create a new ResourceClaim, which will be bound to this pod. When this pod is deleted, the ResourceClaim will also be deleted. The pod name and resource name, along with a generated component, will be used to form a unique name for the ResourceClaim, which will be recorded in pod.status.resourceClaimStatuses.\n\nThis field is immutable and no changes will be made to the corresponding ResourceClaim by the control plane after creating the ResourceClaim.",
15831583
"type": "string"
15841584
}
15851585
},

api/openapi-spec/v3/apis__batch__v1_openapi.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -870,7 +870,7 @@
870870
"type": "string"
871871
},
872872
"resourceClaimTemplateName": {
873-
"description": "ResourceClaimTemplateName is the name of a ResourceClaimTemplate object in the same namespace as this pod.\n\nThe template will be used to create a new ResourceClaim, which will be bound to this pod. When this pod is deleted, the ResourceClaim will also be deleted. The name of the ResourceClaim will be <pod name>-<resource name>, where <resource name> is the PodResourceClaim.Name. Pod validation will reject the pod if the concatenated name is not valid for a ResourceClaim (e.g. too long).\n\nAn existing ResourceClaim with that name that is not owned by the pod will not be used for the pod to avoid using an unrelated resource by mistake. Scheduling and pod startup are then blocked until the unrelated ResourceClaim is removed.\n\nThis field is immutable and no changes will be made to the corresponding ResourceClaim by the control plane after creating the ResourceClaim.",
873+
"description": "ResourceClaimTemplateName is the name of a ResourceClaimTemplate object in the same namespace as this pod.\n\nThe template will be used to create a new ResourceClaim, which will be bound to this pod. When this pod is deleted, the ResourceClaim will also be deleted. The pod name and resource name, along with a generated component, will be used to form a unique name for the ResourceClaim, which will be recorded in pod.status.resourceClaimStatuses.\n\nThis field is immutable and no changes will be made to the corresponding ResourceClaim by the control plane after creating the ResourceClaim.",
874874
"type": "string"
875875
}
876876
},

pkg/api/pod/util.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,10 @@ func dropDisabledPodStatusFields(podStatus, oldPodStatus *api.PodStatus, podSpec
540540
dropResourcesFields(podStatus.EphemeralContainerStatuses)
541541
podStatus.Resize = ""
542542
}
543+
544+
if !utilfeature.DefaultFeatureGate.Enabled(features.DynamicResourceAllocation) && !dynamicResourceAllocationInUse(oldPodSpec) {
545+
podStatus.ResourceClaimStatuses = nil
546+
}
543547
}
544548

545549
// dropDisabledDynamicResourceAllocationFields removes pod claim references from

pkg/api/pod/util_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -822,6 +822,11 @@ func TestDropDynamicResourceAllocation(t *testing.T) {
822822
},
823823
},
824824
},
825+
Status: api.PodStatus{
826+
ResourceClaimStatuses: []api.PodResourceClaimStatus{
827+
{Name: "my-claim", ResourceClaimName: pointer.String("pod-my-claim")},
828+
},
829+
},
825830
}
826831
podWithoutClaims := &api.Pod{
827832
Spec: api.PodSpec{

pkg/apis/core/types.go

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3210,22 +3210,32 @@ type ClaimSource struct {
32103210
//
32113211
// The template will be used to create a new ResourceClaim, which will
32123212
// be bound to this pod. When this pod is deleted, the ResourceClaim
3213-
// will also be deleted. The name of the ResourceClaim will be <pod
3214-
// name>-<resource name>, where <resource name> is the
3215-
// PodResourceClaim.Name. Pod validation will reject the pod if the
3216-
// concatenated name is not valid for a ResourceClaim (e.g. too long).
3217-
//
3218-
// An existing ResourceClaim with that name that is not owned by the
3219-
// pod will not be used for the pod to avoid using an unrelated
3220-
// resource by mistake. Scheduling and pod startup are then blocked
3221-
// until the unrelated ResourceClaim is removed.
3213+
// will also be deleted. The pod name and resource name, along with a
3214+
// generated component, will be used to form a unique name for the
3215+
// ResourceClaim, which will be recorded in pod.status.resourceClaimStatuses.
32223216
//
32233217
// This field is immutable and no changes will be made to the
32243218
// corresponding ResourceClaim by the control plane after creating the
32253219
// ResourceClaim.
32263220
ResourceClaimTemplateName *string
32273221
}
32283222

3223+
// PodResourceClaimStatus is stored in the PodStatus for each PodResourceClaim
3224+
// which references a ResourceClaimTemplate. It stores the generated name for
3225+
// the corresponding ResourceClaim.
3226+
type PodResourceClaimStatus struct {
3227+
// Name uniquely identifies this resource claim inside the pod.
3228+
// This must match the name of an entry in pod.spec.resourceClaims,
3229+
// which implies that the string must be a DNS_LABEL.
3230+
Name string
3231+
3232+
// ResourceClaimName is the name of the ResourceClaim that was
3233+
// generated for the Pod in the namespace of the Pod. It this is
3234+
// unset, then generating a ResourceClaim was not necessary. The
3235+
// pod.spec.resourceClaims entry can be ignored in this case.
3236+
ResourceClaimName *string
3237+
}
3238+
32293239
// OSName is the set of OS'es that can be used in OS.
32303240
type OSName string
32313241

@@ -3661,6 +3671,11 @@ type PodStatus struct {
36613671
// +featureGate=InPlacePodVerticalScaling
36623672
// +optional
36633673
Resize PodResizeStatus
3674+
3675+
// Status of resource claims.
3676+
// +featureGate=DynamicResourceAllocation
3677+
// +optional
3678+
ResourceClaimStatuses []PodResourceClaimStatus
36643679
}
36653680

36663681
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

pkg/apis/core/v1/zz_generated.conversion.go

Lines changed: 34 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)