Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions api/apps/v1alpha1/dra_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,13 +179,28 @@ func (d *DRADeviceAttributeSelector) GetCELExpression(driverName string) (string
type DRAResourceQuantitySelectorOp string

const (
DRAResourceQuantitySelectorOpEqual DRAResourceQuantitySelectorOp = "Equal"
DRAResourceQuantitySelectorOpEqual DRAResourceQuantitySelectorOp = "Equal"
DRAResourceQuantitySelectorOpNotEqual DRAResourceQuantitySelectorOp = "NotEqual"
DRAResourceQuantitySelectorOpGreaterThan DRAResourceQuantitySelectorOp = "GreaterThan"
DRAResourceQuantitySelectorOpGreaterThanOrEqual DRAResourceQuantitySelectorOp = "GreaterThanOrEqual"
DRAResourceQuantitySelectorOpLessThan DRAResourceQuantitySelectorOp = "LessThan"
DRAResourceQuantitySelectorOpLessThanOrEqual DRAResourceQuantitySelectorOp = "LessThanOrEqual"
)

func (d DRAResourceQuantitySelectorOp) GetCELOperator() k8sutilcel.ComparisonOperator {
switch d {
case DRAResourceQuantitySelectorOpEqual:
return k8sutilcel.OpEqual
case DRAResourceQuantitySelectorOpNotEqual:
return k8sutilcel.OpNotEqual
case DRAResourceQuantitySelectorOpGreaterThan:
return k8sutilcel.OpGreater
case DRAResourceQuantitySelectorOpGreaterThanOrEqual:
return k8sutilcel.OpGreaterOrEqual
case DRAResourceQuantitySelectorOpLessThan:
return k8sutilcel.OpLess
case DRAResourceQuantitySelectorOpLessThanOrEqual:
return k8sutilcel.OpLessOrEqual
default:
return k8sutilcel.OpEqual
}
Expand All @@ -201,8 +216,13 @@ type DRAResourceQuantitySelector struct {
Key string `json:"key"`
// Op is the operator to use for comparing against the device capacity. Supported operators are:
// * Equal: The resource quantity value must be equal to the value specified in the selector.
// * NotEqual: The resource quantity value must not be equal to the value specified in the selector.
// * GreaterThan: The resource quantity value must be greater than the value specified in the selector.
// * GreaterThanOrEqual: The resource quantity value must be greater than or equal to the value specified in the selector.
// * LessThan: The resource quantity value must be less than the value specified in the selector.
// * LessThanOrEqual: The resource quantity value must be less than or equal to the value specified in the selector.
//
// +kubebuilder:validation:Enum=Equal
// +kubebuilder:validation:Enum=Equal;NotEqual;GreaterThan;GreaterThanOrEqual;LessThan;LessThanOrEqual
// +kubebuilder:default=Equal
Op DRAResourceQuantitySelectorOp `json:"op"`
// Value is the resource quantity to compare against.
Expand Down
10 changes: 10 additions & 0 deletions bundle/manifests/apps.nvidia.com_nimpipelines.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,18 @@ spec:
description: |-
Op is the operator to use for comparing against the device capacity. Supported operators are:
* Equal: The resource quantity value must be equal to the value specified in the selector.
* NotEqual: The resource quantity value must not be equal to the value specified in the selector.
* GreaterThan: The resource quantity value must be greater than the value specified in the selector.
* GreaterThanOrEqual: The resource quantity value must be greater than or equal to the value specified in the selector.
* LessThan: The resource quantity value must be less than the value specified in the selector.
* LessThanOrEqual: The resource quantity value must be less than or equal to the value specified in the selector.
enum:
- Equal
- NotEqual
- GreaterThan
- GreaterThanOrEqual
- LessThan
- LessThanOrEqual
type: string
value:
anyOf:
Expand Down
10 changes: 10 additions & 0 deletions bundle/manifests/apps.nvidia.com_nimservices.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,18 @@ spec:
description: |-
Op is the operator to use for comparing against the device capacity. Supported operators are:
* Equal: The resource quantity value must be equal to the value specified in the selector.
* NotEqual: The resource quantity value must not be equal to the value specified in the selector.
* GreaterThan: The resource quantity value must be greater than the value specified in the selector.
* GreaterThanOrEqual: The resource quantity value must be greater than or equal to the value specified in the selector.
* LessThan: The resource quantity value must be less than the value specified in the selector.
* LessThanOrEqual: The resource quantity value must be less than or equal to the value specified in the selector.
enum:
- Equal
- NotEqual
- GreaterThan
- GreaterThanOrEqual
- LessThan
- LessThanOrEqual
type: string
value:
anyOf:
Expand Down
10 changes: 10 additions & 0 deletions config/crd/bases/apps.nvidia.com_nimpipelines.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,18 @@ spec:
description: |-
Op is the operator to use for comparing against the device capacity. Supported operators are:
* Equal: The resource quantity value must be equal to the value specified in the selector.
* NotEqual: The resource quantity value must not be equal to the value specified in the selector.
* GreaterThan: The resource quantity value must be greater than the value specified in the selector.
* GreaterThanOrEqual: The resource quantity value must be greater than or equal to the value specified in the selector.
* LessThan: The resource quantity value must be less than the value specified in the selector.
* LessThanOrEqual: The resource quantity value must be less than or equal to the value specified in the selector.
enum:
- Equal
- NotEqual
- GreaterThan
- GreaterThanOrEqual
- LessThan
- LessThanOrEqual
type: string
value:
anyOf:
Expand Down
10 changes: 10 additions & 0 deletions config/crd/bases/apps.nvidia.com_nimservices.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,18 @@ spec:
description: |-
Op is the operator to use for comparing against the device capacity. Supported operators are:
* Equal: The resource quantity value must be equal to the value specified in the selector.
* NotEqual: The resource quantity value must not be equal to the value specified in the selector.
* GreaterThan: The resource quantity value must be greater than the value specified in the selector.
* GreaterThanOrEqual: The resource quantity value must be greater than or equal to the value specified in the selector.
* LessThan: The resource quantity value must be less than the value specified in the selector.
* LessThanOrEqual: The resource quantity value must be less than or equal to the value specified in the selector.
enum:
- Equal
- NotEqual
- GreaterThan
- GreaterThanOrEqual
- LessThan
- LessThanOrEqual
type: string
value:
anyOf:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ spec:
deviceClassName: gpu.nvidia.com
driverName: gpu.nvidia.com
attributeSelectors:
- key: index
op: NotEqual
value:
intValue: 0
- key: driverVersion
op: GreaterThanOrEqual
value:
Expand All @@ -36,7 +32,7 @@ spec:
stringValue: Ampere
capacitySelectors:
- key: memory
op: Equal
op: GreaterThanOrEqual
value: 40Gi
expose:
service:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,18 @@ spec:
description: |-
Op is the operator to use for comparing against the device capacity. Supported operators are:
* Equal: The resource quantity value must be equal to the value specified in the selector.
* NotEqual: The resource quantity value must not be equal to the value specified in the selector.
* GreaterThan: The resource quantity value must be greater than the value specified in the selector.
* GreaterThanOrEqual: The resource quantity value must be greater than or equal to the value specified in the selector.
* LessThan: The resource quantity value must be less than the value specified in the selector.
* LessThanOrEqual: The resource quantity value must be less than or equal to the value specified in the selector.
enum:
- Equal
- NotEqual
- GreaterThan
- GreaterThanOrEqual
- LessThan
- LessThanOrEqual
type: string
value:
anyOf:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,18 @@ spec:
description: |-
Op is the operator to use for comparing against the device capacity. Supported operators are:
* Equal: The resource quantity value must be equal to the value specified in the selector.
* NotEqual: The resource quantity value must not be equal to the value specified in the selector.
* GreaterThan: The resource quantity value must be greater than the value specified in the selector.
* GreaterThanOrEqual: The resource quantity value must be greater than or equal to the value specified in the selector.
* LessThan: The resource quantity value must be less than the value specified in the selector.
* LessThanOrEqual: The resource quantity value must be less than or equal to the value specified in the selector.
enum:
- Equal
- NotEqual
- GreaterThan
- GreaterThanOrEqual
- LessThan
- LessThanOrEqual
type: string
value:
anyOf:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ var validDRADeviceAttributeSelectorOps = []appsv1alpha1.DRADeviceAttributeSelect

var validDRAResourceQuantitySelectorOps = []appsv1alpha1.DRAResourceQuantitySelectorOp{
appsv1alpha1.DRAResourceQuantitySelectorOpEqual,
appsv1alpha1.DRAResourceQuantitySelectorOpNotEqual,
appsv1alpha1.DRAResourceQuantitySelectorOpGreaterThan,
appsv1alpha1.DRAResourceQuantitySelectorOpGreaterThanOrEqual,
appsv1alpha1.DRAResourceQuantitySelectorOpLessThan,
appsv1alpha1.DRAResourceQuantitySelectorOpLessThanOrEqual,
}

// validateNIMServiceSpec aggregates all structural validation checks for a NIMService
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ func TestValidateDRAResourcesConfiguration(t *testing.T) {
},
k8sVersion: "v1.34.0",
wantErrs: 1,
wantErrMsgs: []string{"spec.draResources[0].claimCreationSpec.devices[0].capacitySelectors[0].op: Invalid value: \"InvalidOp\": must be one of [Equal]"},
wantErrMsgs: []string{"spec.draResources[0].claimCreationSpec.devices[0].capacitySelectors[0].op: Invalid value: \"InvalidOp\": must be one of [Equal NotEqual GreaterThan GreaterThanOrEqual LessThan LessThanOrEqual]"},
},
{
name: "claimCreationSpec with invalid quantity selector - missing value",
Expand Down
Loading