Update AllocationResult and ResourceHandle for resource.k8s.io/v1alpha2

This implements the change outlined in the following KEP update:
https://github.com/kubernetes/enhancements/pull/3802

Signed-off-by: Kevin Klues <kklues@nvidia.com>
This commit is contained in:
Kevin Klues 2023-03-07 19:50:58 +00:00
parent e8acfc45ba
commit 53dda4ffe2
2 changed files with 96 additions and 32 deletions

View File

@ -97,9 +97,9 @@ type ResourceClaimStatus struct {
// +optional
DriverName string
// Allocation is set by the resource driver once a resource has been
// allocated successfully. If this is not specified, the resource is
// not yet allocated.
// Allocation is set by the resource driver once a resource or set of
// resources has been allocated successfully. If this is not specified, the
// resources have not been allocated yet.
// +optional
Allocation *AllocationResult
@ -128,21 +128,28 @@ type ResourceClaimStatus struct {
// claim.status.reservedFor.
const ResourceClaimReservedForMaxSize = 32
// AllocationResult contains attributed of an allocated resource.
// AllocationResult contains attributes of an allocated resource.
type AllocationResult struct {
// ResourceHandle contains arbitrary data returned by the driver after a
// successful allocation. This is opaque for
// Kubernetes. Driver documentation may explain to users how to
// interpret this data if needed.
// ResourceHandles contain the state associated with an allocation that
// should be maintained throughout the lifetime of a claim. Each
// ResourceHandle contains data that should be passed to a specific kubelet
// plugin once it lands on a node. This data is returned by the driver
// after a successful allocation and is opaque to Kubernetes. Driver
// documentation may explain to users how to interpret this data if needed.
//
// The maximum size of this field is 16KiB. This may get
// increased in the future, but not reduced.
// Setting this field is optional. It has a maximum size of 32 entries.
// If null (or empty), it is assumed this allocation will be processed by a
// single kubelet plugin with no ResourceHandle data attached. The name of
// the kubelet plugin invoked will match the DriverName set in the
// ResourceClaimStatus this AllocationResult is embedded in.
//
// +listType=atomic
// +optional
ResourceHandle string
ResourceHandles []ResourceHandle
// This field will get set by the resource driver after it has
// allocated the resource driver to inform the scheduler where it can
// schedule Pods using the ResourceClaim.
// This field will get set by the resource driver after it has allocated
// the resource to inform the scheduler where it can schedule Pods using
// the ResourceClaim.
//
// Setting this field is optional. If null, the resource is available
// everywhere.
@ -155,8 +162,33 @@ type AllocationResult struct {
Shareable bool
}
// ResourceHandleMaxSize is the maximum size of allocation.resourceHandle.
const ResourceHandleMaxSize = 16 * 1024
// AllocationResultResourceHandlesMaxSize represents the maximum number of
// entries in allocation.resourceHandles.
const AllocationResultResourceHandlesMaxSize = 32
// ResourceHandle holds opaque resource data for processing by a specific kubelet plugin.
type ResourceHandle struct {
// DriverName specifies the name of the resource driver whose kubelet
// plugin should be invoked to process this ResourceHandle's data once it
// lands on a node. This may differ from the DriverName set in
// ResourceClaimStatus this ResourceHandle is embedded in.
DriverName string
// Data contains the opaque data associated with this ResourceHandle. It is
// set by the controller component of the resource driver whose name
// matches the DriverName set in the ResourceClaimStatus this
// ResourceHandle is embedded in. It is set at allocation time and is
// intended for processing by the kubelet plugin whose name matches
// the DriverName set in this ResourceHandle.
//
// The maximum size of this field is 16KiB. This may get increased in the
// future, but not reduced.
// +optional
Data string
}
// ResourceHandleDataMaxSize represents the maximum size of resourceHandle.data.
const ResourceHandleDataMaxSize = 16 * 1024
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

View File

@ -99,9 +99,9 @@ type ResourceClaimStatus struct {
// +optional
DriverName string `json:"driverName,omitempty" protobuf:"bytes,1,opt,name=driverName"`
// Allocation is set by the resource driver once a resource has been
// allocated successfully. If this is not specified, the resource is
// not yet allocated.
// Allocation is set by the resource driver once a resource or set of
// resources has been allocated successfully. If this is not specified, the
// resources have not been allocated yet.
// +optional
Allocation *AllocationResult `json:"allocation,omitempty" protobuf:"bytes,2,opt,name=allocation"`
@ -133,21 +133,28 @@ type ResourceClaimStatus struct {
// claim.status.reservedFor.
const ResourceClaimReservedForMaxSize = 32
// AllocationResult contains attributed of an allocated resource.
// AllocationResult contains attributes of an allocated resource.
type AllocationResult struct {
// ResourceHandle contains arbitrary data returned by the driver after a
// successful allocation. This is opaque for
// Kubernetes. Driver documentation may explain to users how to
// interpret this data if needed.
// ResourceHandles contain the state associated with an allocation that
// should be maintained throughout the lifetime of a claim. Each
// ResourceHandle contains data that should be passed to a specific kubelet
// plugin once it lands on a node. This data is returned by the driver
// after a successful allocation and is opaque to Kubernetes. Driver
// documentation may explain to users how to interpret this data if needed.
//
// The maximum size of this field is 16KiB. This may get
// increased in the future, but not reduced.
// Setting this field is optional. It has a maximum size of 32 entries.
// If null (or empty), it is assumed this allocation will be processed by a
// single kubelet plugin with no ResourceHandle data attached. The name of
// the kubelet plugin invoked will match the DriverName set in the
// ResourceClaimStatus this AllocationResult is embedded in.
//
// +listType=atomic
// +optional
ResourceHandle string `json:"resourceHandle,omitempty" protobuf:"bytes,1,opt,name=resourceHandle"`
ResourceHandles []ResourceHandle `json:"resourceHandles,omitempty" protobuf:"bytes,1,opt,name=resourceHandles"`
// This field will get set by the resource driver after it has
// allocated the resource driver to inform the scheduler where it can
// schedule Pods using the ResourceClaim.
// This field will get set by the resource driver after it has allocated
// the resource to inform the scheduler where it can schedule Pods using
// the ResourceClaim.
//
// Setting this field is optional. If null, the resource is available
// everywhere.
@ -160,8 +167,33 @@ type AllocationResult struct {
Shareable bool `json:"shareable,omitempty" protobuf:"varint,3,opt,name=shareable"`
}
// ResourceHandleMaxSize is the maximum size of allocation.resourceHandle.
const ResourceHandleMaxSize = 16 * 1024
// AllocationResultResourceHandlesMaxSize represents the maximum number of
// entries in allocation.resourceHandles.
const AllocationResultResourceHandlesMaxSize = 32
// ResourceHandle holds opaque resource data for processing by a specific kubelet plugin.
type ResourceHandle struct {
// DriverName specifies the name of the resource driver whose kubelet
// plugin should be invoked to process this ResourceHandle's data once it
// lands on a node. This may differ from the DriverName set in
// ResourceClaimStatus this ResourceHandle is embedded in.
DriverName string `json:"driverName,omitempty" protobuf:"bytes,1,opt,name=driverName"`
// Data contains the opaque data associated with this ResourceHandle. It is
// set by the controller component of the resource driver whose name
// matches the DriverName set in the ResourceClaimStatus this
// ResourceHandle is embedded in. It is set at allocation time and is
// intended for processing by the kubelet plugin whose name matches
// the DriverName set in this ResourceHandle.
//
// The maximum size of this field is 16KiB. This may get increased in the
// future, but not reduced.
// +optional
Data string `json:"data,omitempty" protobuf:"bytes,2,opt,name=data"`
}
// ResourceHandleDataMaxSize represents the maximum size of resourceHandle.data.
const ResourceHandleDataMaxSize = 16 * 1024
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +k8s:prerelease-lifecycle-gen:introduced=1.26