diff --git a/api/apps/v1alpha1/dra_types.go b/api/apps/v1alpha1/dra_types.go index e89fdfdcb..1bc6b8726 100644 --- a/api/apps/v1alpha1/dra_types.go +++ b/api/apps/v1alpha1/dra_types.go @@ -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 } @@ -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. diff --git a/bundle/manifests/apps.nvidia.com_nimpipelines.yaml b/bundle/manifests/apps.nvidia.com_nimpipelines.yaml index 4b46453a9..94892f820 100644 --- a/bundle/manifests/apps.nvidia.com_nimpipelines.yaml +++ b/bundle/manifests/apps.nvidia.com_nimpipelines.yaml @@ -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: diff --git a/bundle/manifests/apps.nvidia.com_nimservices.yaml b/bundle/manifests/apps.nvidia.com_nimservices.yaml index 80c8ad682..f58afe2c9 100644 --- a/bundle/manifests/apps.nvidia.com_nimservices.yaml +++ b/bundle/manifests/apps.nvidia.com_nimservices.yaml @@ -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: diff --git a/config/crd/bases/apps.nvidia.com_nimpipelines.yaml b/config/crd/bases/apps.nvidia.com_nimpipelines.yaml index 4b46453a9..94892f820 100644 --- a/config/crd/bases/apps.nvidia.com_nimpipelines.yaml +++ b/config/crd/bases/apps.nvidia.com_nimpipelines.yaml @@ -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: diff --git a/config/crd/bases/apps.nvidia.com_nimservices.yaml b/config/crd/bases/apps.nvidia.com_nimservices.yaml index 80c8ad682..f58afe2c9 100644 --- a/config/crd/bases/apps.nvidia.com_nimservices.yaml +++ b/config/crd/bases/apps.nvidia.com_nimservices.yaml @@ -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: diff --git a/config/samples/nim/llm/dra-auto-creation/example1/nimservice.yaml b/config/samples/nim/llm/dra-auto-creation/example1/nimservice.yaml index 726a3a41b..d8d0d555e 100644 --- a/config/samples/nim/llm/dra-auto-creation/example1/nimservice.yaml +++ b/config/samples/nim/llm/dra-auto-creation/example1/nimservice.yaml @@ -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: @@ -36,7 +32,7 @@ spec: stringValue: Ampere capacitySelectors: - key: memory - op: Equal + op: GreaterThanOrEqual value: 40Gi expose: service: diff --git a/deployments/helm/k8s-nim-operator/crds/apps.nvidia.com_nimpipelines.yaml b/deployments/helm/k8s-nim-operator/crds/apps.nvidia.com_nimpipelines.yaml index 4b46453a9..94892f820 100644 --- a/deployments/helm/k8s-nim-operator/crds/apps.nvidia.com_nimpipelines.yaml +++ b/deployments/helm/k8s-nim-operator/crds/apps.nvidia.com_nimpipelines.yaml @@ -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: diff --git a/deployments/helm/k8s-nim-operator/crds/apps.nvidia.com_nimservices.yaml b/deployments/helm/k8s-nim-operator/crds/apps.nvidia.com_nimservices.yaml index 80c8ad682..f58afe2c9 100644 --- a/deployments/helm/k8s-nim-operator/crds/apps.nvidia.com_nimservices.yaml +++ b/deployments/helm/k8s-nim-operator/crds/apps.nvidia.com_nimservices.yaml @@ -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: diff --git a/internal/webhook/apps/v1alpha1/nimservice_webhook_validation_helper.go b/internal/webhook/apps/v1alpha1/nimservice_webhook_validation_helper.go index 1dadb84e9..8e6311a3a 100644 --- a/internal/webhook/apps/v1alpha1/nimservice_webhook_validation_helper.go +++ b/internal/webhook/apps/v1alpha1/nimservice_webhook_validation_helper.go @@ -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 diff --git a/internal/webhook/apps/v1alpha1/nimservice_webhook_validation_helper_test.go b/internal/webhook/apps/v1alpha1/nimservice_webhook_validation_helper_test.go index 1ba541183..3dc43fa7d 100644 --- a/internal/webhook/apps/v1alpha1/nimservice_webhook_validation_helper_test.go +++ b/internal/webhook/apps/v1alpha1/nimservice_webhook_validation_helper_test.go @@ -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",