Skip to content

Commit 1f2fd18

Browse files
committed
extended resource backed by DRA: API types.go
1 parent f142852 commit 1f2fd18

File tree

6 files changed

+155
-0
lines changed

6 files changed

+155
-0
lines changed

pkg/apis/core/types.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3934,6 +3934,28 @@ type PodResourceClaimStatus struct {
39343934
ResourceClaimName *string
39353935
}
39363936

3937+
// PodExtendedResourceClaimStatus is stored in the PodStatus for the extended
3938+
// resource requests backed by DRA. It stores the generated name for
3939+
// the corresponding special ResourceClaim created by the scheduler.
3940+
type PodExtendedResourceClaimStatus struct {
3941+
// RequestMapping identifies the mapping of <container, extended resource backed by DRA> to device request
3942+
// in the generated ResourceClaim.
3943+
RequestMappings []ContainerExtendedResourceRequest
3944+
3945+
// ResourceClaimName is the name of the ResourceClaim that was
3946+
// generated for the Pod in the namespace of the Pod.
3947+
ResourceClaimName string
3948+
}
3949+
3950+
type ContainerExtendedResourceRequest struct {
3951+
// The name of the container requesting resources.
3952+
ContainerName string
3953+
// The name of the extended resource in that container which gets backed by DRA.
3954+
ResourceName string
3955+
// The name of the request in the special ResourceClaim which corresponds to the extended resource.
3956+
RequestName string
3957+
}
3958+
39373959
// OSName is the set of OS'es that can be used in OS.
39383960
type OSName string
39393961

@@ -4535,6 +4557,11 @@ type PodStatus struct {
45354557
// +featureGate=DynamicResourceAllocation
45364558
// +optional
45374559
ResourceClaimStatuses []PodResourceClaimStatus
4560+
4561+
// Status of claim of extended resource backed by DRA.
4562+
// +featureGate=DRAExtendedResource
4563+
// +optional
4564+
ExtendedResourceClaimStatus *PodExtendedResourceClaimStatus
45384565
}
45394566

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

pkg/apis/resource/types.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,17 @@ const (
3131
// Reserved for use by Kubernetes, DRA driver controllers must
3232
// use their own finalizer.
3333
Finalizer = "resource.kubernetes.io/delete-protection"
34+
// ExtendedResourceClaimAnnotation is the annotation applied on the generated
35+
// special ResourceClaim. Its single valid value is "true".
36+
// This is used only inside the scheduler.
37+
ExtendedResourceClaimAnnotation = "resource.kubernetes.io/extended-resource-claim"
38+
// Resource device class prefix is for generating implicit extended resource
39+
// name for a device class when its ExtendedResourceName field is not
40+
// specified. The generated name is this prefix + the device class name.
41+
// The generated name may not be a valid extended resource name for use
42+
// in pod.Spec.Resources.Requests, in that case, a valid name has to be specified
43+
// explicitly in device class.
44+
ResourceDeviceClassPrefix string = "deviceclass.resource.kubernetes.io/"
3445
)
3546

3647
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
@@ -1446,6 +1457,19 @@ type DeviceClassSpec struct {
14461457
// it got removed. May be reused once decoding v1alpha3 is no longer
14471458
// supported.
14481459
// SuitableNodes *core.NodeSelector
1460+
1461+
// ExtendedResourceName is the extended resource name for the devices of this class.
1462+
// The devices of this class can be used to satisfy a pod's extended resource requests.
1463+
// It has the same format as the name of a pod's extended resource.
1464+
// It should be unique among all the device classes in a cluster.
1465+
// If two device classes have the same name, then the class created later
1466+
// is picked to satisfy a pod's extended resource requests.
1467+
// If two classes are created at the same time, then the name of the class
1468+
// lexicographically sorted first is picked.
1469+
//
1470+
// +optional
1471+
// +featureGate=DRAExtendedResource
1472+
ExtendedResourceName *string
14491473
}
14501474

14511475
// DeviceClassConfiguration is used in DeviceClass.

staging/src/k8s.io/api/core/v1/types.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4489,6 +4489,31 @@ type PodResourceClaimStatus struct {
44894489
ResourceClaimName *string `json:"resourceClaimName,omitempty" protobuf:"bytes,2,opt,name=resourceClaimName"`
44904490
}
44914491

4492+
// PodExtendedResourceClaimStatus is stored in the PodStatus for the extended
4493+
// resource requests backed by DRA. It stores the generated name for
4494+
// the corresponding special ResourceClaim created by the scheduler.
4495+
type PodExtendedResourceClaimStatus struct {
4496+
// RequestMappings identifies the mapping of <container, extended resource backed by DRA> to device request
4497+
// in the generated ResourceClaim.
4498+
// +listType=atomic
4499+
RequestMappings []ContainerExtendedResourceRequest `json:"requestMappings" protobuf:"bytes,1,rep,name=requestMappings"`
4500+
4501+
// ResourceClaimName is the name of the ResourceClaim that was
4502+
// generated for the Pod in the namespace of the Pod.
4503+
ResourceClaimName string `json:"resourceClaimName" protobuf:"bytes,2,name=resourceClaimName"`
4504+
}
4505+
4506+
// ContainerExtendedResourceRequest has the mapping of container name,
4507+
// extended resource name to the device request name.
4508+
type ContainerExtendedResourceRequest struct {
4509+
// The name of the container requesting resources.
4510+
ContainerName string `json:"containerName" protobuf:"bytes,1,name=containerName"`
4511+
// The name of the extended resource in that container which gets backed by DRA.
4512+
ResourceName string `json:"resourceName" protobuf:"bytes,2,name=resourceName"`
4513+
// The name of the request in the special ResourceClaim which corresponds to the extended resource.
4514+
RequestName string `json:"requestName" protobuf:"bytes,3,name=requestName"`
4515+
}
4516+
44924517
// OSName is the set of OS'es that can be used in OS.
44934518
type OSName string
44944519

@@ -5319,6 +5344,10 @@ type PodStatus struct {
53195344
// +featureGate=DynamicResourceAllocation
53205345
// +optional
53215346
ResourceClaimStatuses []PodResourceClaimStatus `json:"resourceClaimStatuses,omitempty" patchStrategy:"merge,retainKeys" patchMergeKey:"name" protobuf:"bytes,15,rep,name=resourceClaimStatuses"`
5347+
// Status of extended resource claim backed by DRA.
5348+
// +featureGate=DRAExtendedResource
5349+
// +optional
5350+
ExtendedResourceClaimStatus *PodExtendedResourceClaimStatus `json:"extendedResourceClaimStatus,omitempty" protobuf:"bytes,18,opt,name=extendedResourceClaimStatus"`
53225351
}
53235352

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

staging/src/k8s.io/api/resource/v1/types.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,17 @@ const (
3131
// Reserved for use by Kubernetes, DRA driver controllers must
3232
// use their own finalizer.
3333
Finalizer = "resource.kubernetes.io/delete-protection"
34+
// ExtendedResourceClaimAnnotation is the annotation applied on the generated
35+
// special ResourceClaim. Its single valid value is "true".
36+
// This is used only inside the scheduler.
37+
ExtendedResourceClaimAnnotation = "resource.kubernetes.io/extended-resource-claim"
38+
// Resource device class prefix is for generating implicit extended resource
39+
// name for a device class when its ExtendedResourceName field is not
40+
// specified. The generated name is this prefix + the device class name.
41+
// The generated name may not be a valid extended resource name for use
42+
// in pod.Spec.Resources.Requests, in that case, a valid name has to be specified
43+
// explicitly in device class.
44+
ResourceDeviceClassPrefix string = "deviceclass.resource.kubernetes.io/"
3445
)
3546

3647
// +genclient
@@ -1458,6 +1469,20 @@ type DeviceClassSpec struct {
14581469
// it got removed. May be reused once decoding v1alpha3 is no longer
14591470
// supported.
14601471
// SuitableNodes *v1.NodeSelector `json:"suitableNodes,omitempty" protobuf:"bytes,3,opt,name=suitableNodes"`
1472+
1473+
// ExtendedResourceName is the extended resource name for the devices of this class.
1474+
// The devices of this class can be used to satisfy a pod's extended resource requests.
1475+
// It has the same format as the name of a pod's extended resource.
1476+
// It should be unique among all the device classes in a cluster.
1477+
// If two device classes have the same name, then the class created later
1478+
// is picked to satisfy a pod's extended resource requests.
1479+
// If two classes are created at the same time, then the name of the class
1480+
// lexicographically sorted first is picked.
1481+
//
1482+
// This is an alpha field.
1483+
// +optional
1484+
// +featureGate=DRAExtendedResource
1485+
ExtendedResourceName *string `json:"extendedResourceName,omitempty" protobuf:"bytes,4,opt,name=extendedResourceName"`
14611486
}
14621487

14631488
// DeviceClassConfiguration is used in DeviceClass.

staging/src/k8s.io/api/resource/v1beta1/types.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,17 @@ const (
3131
// Reserved for use by Kubernetes, DRA driver controllers must
3232
// use their own finalizer.
3333
Finalizer = "resource.kubernetes.io/delete-protection"
34+
// ExtendedResourceClaimAnnotation is the annotation applied on the generated
35+
// special ResourceClaim. Its single valid value is "true".
36+
// This is used only inside the scheduler.
37+
ExtendedResourceClaimAnnotation = "resource.kubernetes.io/extended-resource-claim"
38+
// Resource device class prefix is for generating implicit extended resource
39+
// name for a device class when its ExtendedResourceName field is not
40+
// specified. The generated name is this prefix + the device class name.
41+
// The generated name may not be a valid extended resource name for use
42+
// in pod.Spec.Resources.Requests, in that case, a valid name has to be specified
43+
// explicitly in device class.
44+
ResourceDeviceClassPrefix string = "deviceclass.resource.kubernetes.io/"
3445
)
3546

3647
// +genclient
@@ -1466,6 +1477,20 @@ type DeviceClassSpec struct {
14661477
// it got removed. May be reused once decoding v1alpha3 is no longer
14671478
// supported.
14681479
// SuitableNodes *v1.NodeSelector `json:"suitableNodes,omitempty" protobuf:"bytes,3,opt,name=suitableNodes"`
1480+
1481+
// ExtendedResourceName is the extended resource name for the devices of this class.
1482+
// The devices of this class can be used to satisfy a pod's extended resource requests.
1483+
// It has the same format as the name of a pod's extended resource.
1484+
// It should be unique among all the device classes in a cluster.
1485+
// If two device classes have the same name, then the class created later
1486+
// is picked to satisfy a pod's extended resource requests.
1487+
// If two classes are created at the same time, then the name of the class
1488+
// lexicographically sorted first is picked.
1489+
//
1490+
// This is an alpha field.
1491+
// +optional
1492+
// +featureGate=DRAExtendedResource
1493+
ExtendedResourceName *string `json:"extendedResourceName,omitempty" protobuf:"bytes,4,opt,name=extendedResourceName"`
14691494
}
14701495

14711496
// DeviceClassConfiguration is used in DeviceClass.

staging/src/k8s.io/api/resource/v1beta2/types.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,17 @@ const (
3131
// Reserved for use by Kubernetes, DRA driver controllers must
3232
// use their own finalizer.
3333
Finalizer = "resource.kubernetes.io/delete-protection"
34+
// ExtendedResourceClaimAnnotation is the annotation applied on the generated
35+
// special ResourceClaim. Its single valid value is "true".
36+
// This is used only inside the scheduler.
37+
ExtendedResourceClaimAnnotation = "resource.kubernetes.io/extended-resource-claim"
38+
// Resource device class prefix is for generating implicit extended resource
39+
// name for a device class when its ExtendedResourceName field is not
40+
// specified. The generated name is this prefix + the device class name.
41+
// The generated name may not be a valid extended resource name for use
42+
// in pod.Spec.Resources.Requests, in that case, a valid name has to be specified
43+
// explicitly in device class.
44+
ResourceDeviceClassPrefix string = "deviceclass.resource.kubernetes.io/"
3445
)
3546

3647
// +genclient
@@ -1458,6 +1469,20 @@ type DeviceClassSpec struct {
14581469
// it got removed. May be reused once decoding v1alpha3 is no longer
14591470
// supported.
14601471
// SuitableNodes *v1.NodeSelector `json:"suitableNodes,omitempty" protobuf:"bytes,3,opt,name=suitableNodes"`
1472+
1473+
// ExtendedResourceName is the extended resource name for the devices of this class.
1474+
// The devices of this class can be used to satisfy a pod's extended resource requests.
1475+
// It has the same format as the name of a pod's extended resource.
1476+
// It should be unique among all the device classes in a cluster.
1477+
// If two device classes have the same name, then the class created later
1478+
// is picked to satisfy a pod's extended resource requests.
1479+
// If two classes are created at the same time, then the name of the class
1480+
// lexicographically sorted first is picked.
1481+
//
1482+
// This is an alpha field.
1483+
// +optional
1484+
// +featureGate=DRAExtendedResource
1485+
ExtendedResourceName *string `json:"extendedResourceName,omitempty" protobuf:"bytes,4,opt,name=extendedResourceName"`
14611486
}
14621487

14631488
// DeviceClassConfiguration is used in DeviceClass.

0 commit comments

Comments
 (0)