From fbc7e07e3cced7586d1f947178e049d92906c428 Mon Sep 17 00:00:00 2001 From: John Belamaric Date: Tue, 18 Jun 2024 09:26:02 -0700 Subject: [PATCH 1/3] Update API for 1.31 without partitionable model --- dra-evolution/pkg/api/capacity_types.go | 78 +++++++++++++++---------- 1 file changed, 46 insertions(+), 32 deletions(-) diff --git a/dra-evolution/pkg/api/capacity_types.go b/dra-evolution/pkg/api/capacity_types.go index 0c9a427..623764d 100644 --- a/dra-evolution/pkg/api/capacity_types.go +++ b/dra-evolution/pkg/api/capacity_types.go @@ -59,14 +59,11 @@ type ResourcePoolSpec struct { // vendor of the driver. DriverName string `json:"driverName" protobuf:"bytes,3,name=driverName"` - // SharedCapacity defines the set of shared capacity consumable by - // devices in this ResourceSlice. + // CommonData represents information that is common across various devices, + // to reduce redundancy in the devices list. // - // Must not have more than 128 entries. - // - // +listType=atomic // +optional - SharedCapacity []SharedCapacity `json:"sharedCapacity,omitempty"` + CommonData []CommonDeviceData `json:"commonData,omitempty"` // Devices lists all available devices in this pool. // @@ -78,9 +75,26 @@ type ResourcePoolSpec struct { // them) empty pool. } -const ResourcePoolMaxSharedCapacity = 128 +const ResourcePoolMaxCommonData = 16 const ResourcePoolMaxDevices = 128 +type CommonDeviceData struct { + // Name identifies the particular set of common data represented + // here. + // + // +required + Name string `json:"name"` + + // Exactly one must be populated + Attributes []DeviceAttribute + Capacity []DeviceCapacity + + // Future possible additions: + // - SharedCapacity for use in allocating partitionable devices + // - DeviceShape for encapsulating attributes, capacities, partion schemes + // - DeviceShapeRef for storing those in a secondary object +} + // Device represents one individual hardware instance that can be selected based // on its attributes. type Device struct { @@ -88,27 +102,43 @@ type Device struct { // the driver on the node. It must be a DNS label. Name string `json:"name" protobuf:"bytes,1,name=name"` + // CommonData is the list of names of entries from the common data that + // should be included in this device. + // + // +listType=atomic + // +optional + // + CommonData []string `json:"commonData,omitempty"` + // Attributes defines the attributes of this device. // The name of each attribute must be unique. // // Must not have more than 32 entries. // + // Values in this list whose name conflict with common attributes + // will override the common attribute values. + // // +listType=atomic // +optional + // Attributes []DeviceAttribute `json:"attributes,omitempty" protobuf:"bytes,3,opt,name=attributes"` - // SharedCapacityConsumed defines the set of shared capacity consumed by - // this device. + // Capacity defines the capacity values for this device. + // The name of each capacity must be unique. // // Must not have more than 32 entries. // + // Values in this list whose name conflict with common capacity + // will override the common capacity values. + // // +listType=atomic // +optional - SharedCapacityConsumed []SharedCapacity `json:"sharedCapacityConsumed,omitempty"` + // + Capacity []DeviceCapacity `json:"capacity,omitempty"` } const ResourcePoolMaxAttributesPerDevice = 32 -const ResourcePoolMaxSharedCapacityConsumedPerDevice = 32 +const ResourcePoolMaxCapacityPerDevice = 32 // ResourcePoolMaxDevices and ResourcePoolMaxAttributesPerDevice where chosen // so that with the maximum attribute length of 96 characters the total size of @@ -154,40 +184,24 @@ type DeviceAttribute struct { VersionValue *string `json:"version,omitempty" protobuf:"bytes,5,opt,name=version"` } -type SharedCapacity struct { - // Name is a unique identifier among all shared capacities managed by the +type DeviceCapacity struct { + // Name is a unique identifier among all 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"` // 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"` } -// CStyleIdentifierMaxLength is the maximum length of a c-style identifier used for naming. -const CStyleIdentifierMaxLength = 32 - // DeviceAttributeMaxIDLength is the maximum length of the identifier in a device attribute name (`/`). -const DeviceAttributeMaxIDLength = CStyleIdentifierMaxLength +const DeviceAttributeMaxIDLength = 32 // 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 +// DeviceCapacityMaxNameLength is the maximum length of a shared capacity name. +const DeviceCapacityMaxNameLength = DeviceAttributeMaxIDLength From 3a7aa4f9789c7979426ea3c65497545136428f55 Mon Sep 17 00:00:00 2001 From: John Belamaric Date: Tue, 18 Jun 2024 11:24:06 -0700 Subject: [PATCH 2/3] Replace all common things with a single discriminator --- dra-evolution/pkg/api/capacity_types.go | 37 ++++--------------------- 1 file changed, 6 insertions(+), 31 deletions(-) diff --git a/dra-evolution/pkg/api/capacity_types.go b/dra-evolution/pkg/api/capacity_types.go index 623764d..a79faad 100644 --- a/dra-evolution/pkg/api/capacity_types.go +++ b/dra-evolution/pkg/api/capacity_types.go @@ -59,11 +59,13 @@ type ResourcePoolSpec struct { // vendor of the driver. DriverName string `json:"driverName" protobuf:"bytes,3,name=driverName"` - // CommonData represents information that is common across various devices, - // to reduce redundancy in the devices list. + // SliceContent represents the type of data in this slice. Currently the only + // valid values is `Devices`. As we add features, new values will be added + // to this discriminator. This allows older schedulers to know if they should + // ignore the slice, due to it being of a type they do not understand. // - // +optional - CommonData []CommonDeviceData `json:"commonData,omitempty"` + // +required + SliceContent string `json:"sliceContent"` // Devices lists all available devices in this pool. // @@ -78,23 +80,6 @@ type ResourcePoolSpec struct { const ResourcePoolMaxCommonData = 16 const ResourcePoolMaxDevices = 128 -type CommonDeviceData struct { - // Name identifies the particular set of common data represented - // here. - // - // +required - Name string `json:"name"` - - // Exactly one must be populated - Attributes []DeviceAttribute - Capacity []DeviceCapacity - - // Future possible additions: - // - SharedCapacity for use in allocating partitionable devices - // - DeviceShape for encapsulating attributes, capacities, partion schemes - // - DeviceShapeRef for storing those in a secondary object -} - // Device represents one individual hardware instance that can be selected based // on its attributes. type Device struct { @@ -102,14 +87,6 @@ type Device struct { // the driver on the node. It must be a DNS label. Name string `json:"name" protobuf:"bytes,1,name=name"` - // CommonData is the list of names of entries from the common data that - // should be included in this device. - // - // +listType=atomic - // +optional - // - CommonData []string `json:"commonData,omitempty"` - // Attributes defines the attributes of this device. // The name of each attribute must be unique. // @@ -173,8 +150,6 @@ type DeviceAttribute struct { // field "String" and the corresponding method. That method is required. // The Kubernetes API is defined without that suffix to keep it more natural. - // QuantityValue is a quantity. - QuantityValue *resource.Quantity `json:"quantity,omitempty" protobuf:"bytes,2,opt,name=quantity"` // BoolValue is a true/false value. BoolValue *bool `json:"bool,omitempty" protobuf:"bytes,3,opt,name=bool"` // StringValue is a string. Must not be longer than 64 characters. From 6187d27ba6de38625a2dba8cd7d776a877d48aba Mon Sep 17 00:00:00 2001 From: John Belamaric Date: Tue, 18 Jun 2024 12:31:25 -0700 Subject: [PATCH 3/3] Remove left over comments --- dra-evolution/pkg/api/capacity_types.go | 6 ------ 1 file changed, 6 deletions(-) diff --git a/dra-evolution/pkg/api/capacity_types.go b/dra-evolution/pkg/api/capacity_types.go index a79faad..db12da0 100644 --- a/dra-evolution/pkg/api/capacity_types.go +++ b/dra-evolution/pkg/api/capacity_types.go @@ -92,9 +92,6 @@ type Device struct { // // Must not have more than 32 entries. // - // Values in this list whose name conflict with common attributes - // will override the common attribute values. - // // +listType=atomic // +optional // @@ -105,9 +102,6 @@ type Device struct { // // Must not have more than 32 entries. // - // Values in this list whose name conflict with common capacity - // will override the common capacity values. - // // +listType=atomic // +optional //