Skip to content

Commit

Permalink
Update to match KEP
Browse files Browse the repository at this point in the history
  • Loading branch information
johnbelamaric committed Jun 14, 2024
1 parent e11c5dc commit 79c967f
Showing 1 changed file with 45 additions and 35 deletions.
80 changes: 45 additions & 35 deletions dra-evolution/pkg/api/capacity_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,27 +59,26 @@ type ResourcePoolSpec struct {
// vendor of the driver.
DriverName string `json:"driverName" protobuf:"bytes,3,name=driverName"`

// Devices lists all available devices in this pool.
// SharedCapacity defines the set of shared capacity consumable by
// devices in this ResourceSlice.
//
// Must not have more than 128 entries.
Devices []Device `json:"devices,omitempty"`

// SharedCapacity are pooled resources that are shared by all
// devices in the pool. This is typically used when representing a
// partitionable device, and need not be populated otherwise.
//
// Must not have more than 32 entries.
//
// +optional
// +listType=atomic
SharedCapacity []SharedCapacity `json:"sharedCapacity,omitempty"`
// +optional
SharedCapacity []SharedCapacity

// Devices lists all available devices in this pool.
//
// Must not have more than 128 entries.
Devices []Device `json:"devices,omitempty"`

// FUTURE EXTENSION: some other kind of list, should we ever need it.
// Old clients seeing an empty Devices field can safely ignore the (to
// them) empty pool.
}

type ResourceCapacity struct {
type SharedCapacity struct {
// Name is the resource name/type.
// +required
Name string `json:"name"`
Expand All @@ -89,8 +88,8 @@ type ResourceCapacity struct {
Capacity resource.Quantity `json:"capacity"`
}

const ResourcePoolMaxSharedCapacity = 128
const ResourcePoolMaxDevices = 128
const ResourcePoolMaxSharedCapacity = 32

// Device represents one individual hardware instance that can be selected based
// on its attributes.
Expand All @@ -108,16 +107,18 @@ type Device struct {
// +optional
Attributes []DeviceAttribute `json:"attributes,omitempty" protobuf:"bytes,3,opt,name=attributes"`

// SharedCapacityConsumed contains the pooled allocatable resources
// that are consumed when this device is allocated.
// SharedCapacityConsumed defines the set of shared capacity consumed by
// this device.
//
// Must not have more than 32 entries.
//
// +listType=atomic
// +optional
SharedCapacityConsumed []SharedCapacityRequest `json:"sharedCapacityConsumed,omitempty"`
SharedCapacityConsumed []SharedCapacity
}

const ResourcePoolMaxAttributesPerDevice = 32
const ResourcePoolMaxSharedCapacityConsumedPerDevice = 32

// ResourcePoolMaxDevices and ResourcePoolMaxAttributesPerDevice where chosen
// so that with the maximum attribute length of 96 characters the total size of
Expand Down Expand Up @@ -163,31 +164,40 @@ type DeviceAttribute struct {
VersionValue *string `json:"version,omitempty" protobuf:"bytes,5,opt,name=version"`
}

const DeviceAttributeMaxIDLength = 32
const DeviceAttributeMaxValueLength = 64

// SharedCapacity is a set of resources which can be drawn down upon.
type SharedCapacity struct {
// Name is the name of this set of shared capacity, which is unique
// resource pool.
// Name is a unique identifier among all shared capacities managed by the
// driver in the pool.
//
// It is referenced both when defining the total amount of shared capacity
// that is available, as well as by individual devices when declaring
// how much of this shared capacity they consume.
//
// SharedCapacity names must be a C-style identifier (e.g. "the_name") with
// a maximum length of 32.
//
// By limiting these names to a C-style identifier, the same validation can
// be used for both these names and the identifier portion of a
// DeviceAttribute name.
//
// +required
Name string `json:"name"`

// Resources are the list of resources provided in this set.
Resources []ResourceCapacity `json:"resources,omitempty"`
// Capacity is the total capacity of the named resource.
// This can either represent the total *available* capacity, or the total
// capacity *consumed*, depending on the context where it is referenced.
//
// +required
Capacity resource.Quantity `json:"capacity"`
}

// SharedCapacityRequest is a request to draw down resources from a particular
// SharedCapacity.
type SharedCapacityRequest struct {
// CStyleIdentifierMaxLength is the maximum length of a c-style identifier used for naming.
const CStyleIdentifierMaxLength = 32

// Name is the name of the SharedCapacity from which to draw the
// resources.
//
// +required
Name string `json:"name"`
// DeviceAttributeMaxIDLength is the maximum length of the identifier in a device attribute name (`<domain>/<ID>`).
const DeviceAttributeMaxIDLength = CStyleIdentifierMaxLength

// Resources are the list of resources and the amount of resources
// to draw down.
Resources []ResourceCapacity `json:"resources,omitempty"`
}
// DeviceAttributeMaxValueLength is the maximum length of a string or version attribute value.
const DeviceAttributeMaxValueLength = 64

// SharedCapacityMaxNameLength is the maximum length of a shared capacity name.
const SharedCapacityMaxNameLength = CStyleIdentifierMaxLength

0 comments on commit 79c967f

Please sign in to comment.