/api/configs/resource_validation#

Resource validation configurations define rules to validate resource requests against available cluster resources.

Each resource validation set is defined by a name and an Array[Resource Validation Rule].

Operator#

The following table shows the default resource validation rules:

Type

Description

LE

Less than or equal to (≤)

GE

Greater than or equal to (≥)

LT

Less than (<)

GT

Greater than (>)

EQ

Equal to (=)

NE

Not equal to (≠)

Resource Validation Rule#

Field

Type

Description

Default Values

operator

Operator

The comparison operator to use for validation.

Required field

left_operand

String

The left side of the comparison, typically a user-requested value or template variable.

Required field

right_operand

String

The right side of the comparison, typically a cluster resource limit or template variable.

Required field

assert_message

String

Error message to display when the validation rule fails.

Required field

Example#

The following example shows a CPU validation rule that ensures user-requested CPU does not exceed available cluster CPU:

{
    "default_cpu": [
        {
            "operator": "LT",
            "left_operand": "{{USER_CPU}}",
            "right_operand": "{{K8_CPU}}",
            "assert_message": "CPU value {{USER_CPU}} too high"
        },
        {
            "operator": "GT",
            "left_operand": "{{USER_CPU}}",
            "right_operand": "0",
            "assert_message": "CPU value {{USER_CPU}} needs to be greater than 0"
        }
    ]
}

The key here is default_cpu, which is the name of the resource validation set. The value is an array of resource validation rules. When a pool is configured using this resource validation set, the resource validation rules will be applied to workflows submitted to the pool.

Rules Breakdown#

In the first rule, we are comparing the values of two dynamic variables: {{USER_CPU}} and {{K8_CPU}}. If a variable that starts with K8_ is used, this validation check will be performed against all available resource nodes in the pool.

In the second rule, we are comparing the values of one dynamic variable ({{USER_CPU}}) and a static value: 0. This static validation check will be performed once.

Note

The static validation check can compare values with units. For example:

{
    "operator": "GT",
    "left_operand": "{{USER_STORAGE}}",
    "right_operand": "5Gi",
    "assert_message": "Storage value {{USER_STORAGE}} needs to be greater than 5Gi"
}

For static values, resource validation supports units B, Ki, Mi, Gi and Ti.

Users can pick any unit specified above for the static value, and the resource validation check will perform unit conversion to compare {{USER_STORAGE}} with the static value.

Does static validation support the m unit for comparing CPU?

Currently, CPU validation does not support the m unit. For your static value, you will need to use an integer instead.

A pool can apply this resource validation set by adding the name to the common_resource_validations array, and a platform can apply this resource validation set by adding the name to the override_resource_validations array.

To learn more about resource validation, see Resource Validation Concepts.