@@ -322,6 +322,15 @@ type Device struct {
322322 // +listType=atomic
323323 // +featureGate=DRADeviceTaints
324324 Taints []DeviceTaint
325+
326+ // Shared marks whether the device is shared.
327+ //
328+ // The device with shared="true" can be allocated to more than one resource claim,
329+ //
330+ // +optional
331+ // +default=false
332+ // +featureGate=DRAConsumableCapacity
333+ Shared * bool
325334}
326335
327336// DeviceCounterConsumption defines a set of counters that
@@ -351,8 +360,60 @@ type DeviceCapacity struct {
351360 // +required
352361 Value resource.Quantity
353362
354- // potential future addition: fields which define how to "consume"
355- // capacity (= share a single device between different consumers).
363+ // ClaimPolicy specifies that this device capacity must be consumed
364+ // by each resource claim according to the defined consumption policy.
365+ //
366+ // +optional
367+ // +featureGate=DRAConsumableCapacity
368+ ClaimPolicy * CapacityClaimPolicy
369+ }
370+
371+ // CapacityClaimPolicy defines consumption policy for consumable capacity.
372+ // Either one of the consumption policies must be defined.
373+ type CapacityClaimPolicy struct {
374+ // Set defines a set of acceptable quantities of consuming requests.
375+ //
376+ // +optional
377+ // +oneOf=CapacityClaimPolicy
378+ Set * CapacityClaimPolicySet
379+
380+ // Range defines an acceptable quantity range of consuming requests.
381+ // +optional
382+ // +oneOf=CapacityClaimPolicy
383+ Range * CapacityClaimPolicyRange
384+ }
385+
386+ // CapacityClaimPolicySet defines a discrete set of allowable capacity values for consumption.
387+ type CapacityClaimPolicySet struct {
388+ // Default specifies the default capacity to be used for a consumption request
389+ // if no value is explicitly provided.
390+ //
391+ // +required
392+ Default resource.Quantity
393+
394+ // Options defines a discrete set of additional valid capacity values that can be requested.
395+ // +optional
396+ // +listType=atomic
397+ Options []resource.Quantity
398+ }
399+
400+ // CapacityClaimPolicyRange defines a valid range of consuming capacity.
401+ type CapacityClaimPolicyRange struct {
402+ // Minimum specifies the minimum capacity required for a consumption request.
403+ // This field is required and serves as the default capacity to be consumed.
404+ //
405+ // +required
406+ Minimum resource.Quantity
407+
408+ // Maximum specifies the maximum capacity that can be requested in a consumption request.
409+ //
410+ // +optional
411+ Maximum * resource.Quantity
412+
413+ // Step defines the incremental block size by which capacity can increase from the minimum.
414+ //
415+ // +optional
416+ Step * resource.Quantity
356417}
357418
358419// Counter describes a quantity associated with a device.
@@ -640,6 +701,18 @@ type DeviceRequest struct {
640701 FirstAvailable []DeviceSubRequest
641702}
642703
704+ // CapacityRequirements defines the capacity requirements for a specific device request.
705+ type CapacityRequirements struct {
706+ // Requests specifies the requested quantity of device capacities for a device request,
707+ // keyed by qualified resource names.
708+ // +optional
709+ Requests map [QualifiedName ]resource.Quantity
710+
711+ // Potentially enhancement field.
712+ // Limits define the maximum amount of per-device resources allowed.
713+ // This enables burstable usage when applicable.
714+ }
715+
643716// ExactDeviceRequest is a request for one or more identical devices.
644717type ExactDeviceRequest struct {
645718 // DeviceClassName references a specific DeviceClass, which can define
@@ -731,6 +804,12 @@ type ExactDeviceRequest struct {
731804 // +listType=atomic
732805 // +featureGate=DRADeviceTaints
733806 Tolerations []DeviceToleration
807+
808+ // Capacities defines resource requirements against each capacity.
809+ //
810+ // +optional
811+ // +featureGate=DRAConsumableCapacity
812+ Capacities * CapacityRequirements
734813}
735814
736815// DeviceSubRequest describes a request for device provided in the
@@ -825,6 +904,12 @@ type DeviceSubRequest struct {
825904 // +listType=atomic
826905 // +featureGate=DRADeviceTaints
827906 Tolerations []DeviceToleration
907+
908+ // Capacities defines requirements against capacity.
909+ //
910+ // +optional
911+ // +featureGate=DRAConsumableCapacity
912+ Capacities * CapacityRequirements
828913}
829914
830915const (
@@ -968,6 +1053,15 @@ type DeviceConstraint struct {
9681053 // +oneOf=ConstraintType
9691054 MatchAttribute * FullyQualifiedName
9701055
1056+ // DistinctAttribute requires that all devices in question have this
1057+ // attribute and that its type and value are unique across those devices.
1058+ //
1059+ // For example, specify attribute name to get virtual devices from distinct shared physical devices.
1060+ //
1061+ // +optional
1062+ // +oneOf=ConstraintType
1063+ DistinctAttribute * FullyQualifiedName
1064+
9711065 // Potential future extension, not part of the current design:
9721066 // A CEL expression which compares different devices and returns
9731067 // true if they match.
@@ -1272,6 +1366,19 @@ type DeviceRequestAllocationResult struct {
12721366 // +listType=atomic
12731367 // +featureGate=DRADeviceTaints
12741368 Tolerations []DeviceToleration
1369+
1370+ // Shared indicates whether the allocated device can be shared by multiple claims.
1371+ //
1372+ // +optional
1373+ // +featureGate=DRAConsumableCapacity
1374+ Shared * bool
1375+
1376+ // ConsumedCapacities is used for tracking the capacity consumed per device by the claim request.
1377+ // The total consumed capacity for each device must not exceed its corresponding available capacity.
1378+ //
1379+ // +optional
1380+ // +featureGate=DRAConsumableCapacity
1381+ ConsumedCapacities map [QualifiedName ]resource.Quantity
12751382}
12761383
12771384// DeviceAllocationConfiguration gets embedded in an AllocationResult.
0 commit comments