|
| 1 | +Description: Added CRD validation rules |
| 2 | +Authors: [Alan Clucas](https://github.com/Joibel |
| 3 | +Component: General |
| 4 | +Issues: 13503 |
| 5 | + |
| 6 | +Added some validation rules to the full CRDs which allow some simpler validation to happen as the object is added to the kubernetes cluster. |
| 7 | +This is useful if you're using a mechanism which bypasses the validator such as kubectl apply. |
| 8 | +It will inform you of |
| 9 | + |
| 10 | +**Note:** Some validations cannot be implemented as CEL rules due to Kubernetes limitations. |
| 11 | +Fields marked with `+kubebuilder:validation:Schemaless` (like `withItems`) or `+kubebuilder:pruning:PreserveUnknownFields` (like `inline`) are not visible to CEL validation expressions. |
| 12 | + |
| 13 | +**CEL Budget Management:** Kubernetes limits the total cost of CEL validation rules per CRD. To stay within these limits: |
| 14 | +* All `status` blocks have CEL validations automatically stripped during CRD generation |
| 15 | +* Controller-managed CRDs (WorkflowTaskSet, WorkflowTaskResult, WorkflowArtifactGCTask) have all CEL validations removed from both spec and status |
| 16 | +* Server-side validations in `workflow/validate/validate.go` supplement CEL for fields that cannot be validated with CEL (e.g., schemaless fields) |
| 17 | + |
| 18 | +**Array and String Size Limits:** To manage CEL validation costs, the following maximum sizes are enforced: |
| 19 | +* Templates per workflow: 200 |
| 20 | +* DAG tasks per DAG template: 200 |
| 21 | +* Parameters: 500 |
| 22 | +* Prometheus metrics per template: 100 |
| 23 | +* Gauge metric value string: 256 characters |
| 24 | + |
| 25 | +#### Mutual Exclusivity Rules: |
| 26 | +* only one template type per template |
| 27 | +* only one of sequence count/end |
| 28 | +* only one of manifest/manifestFrom |
| 29 | +* cannot use both depends and dependencies in DAG tasks. |
| 30 | + |
| 31 | +#### DAG Task Constraints: |
| 32 | +* task names cannot start with digit when using depends/dependencies |
| 33 | +* cannot use continueOn with depends. |
| 34 | + |
| 35 | +#### Timeout on Non-Leaf Templates: |
| 36 | +* Timeout cannot be set on steps or dag templates (only on leaf templates). |
| 37 | + |
| 38 | +#### Cron Schedule Format: |
| 39 | +* CronWorkflow schedules must be valid 5-field cron expressions, specialdescriptors (@yearly, @hourly, etc.), or interval format (@every). |
| 40 | + |
| 41 | +#### Metric Validation: |
| 42 | +* metric and label names validation |
| 43 | +* help and value fields required |
| 44 | +* real-time gauges cannot use resourcesDuration metrics |
| 45 | + |
| 46 | +#### Artifact: |
| 47 | +* At most one artifact location may be specified |
| 48 | +* Artifact.Mode must be between 0 and 511 (0777 octal) for file permissions. |
| 49 | + |
| 50 | +#### Enum Validations: |
| 51 | +* PodGC strategy |
| 52 | +* ConcurrencyPolicy |
| 53 | +* RetryPolicy |
| 54 | +* GaugeOperation |
| 55 | +* Resource action |
| 56 | +* MergeStrategy |
| 57 | + all have restricted allowed values. |
| 58 | + |
| 59 | +#### Name Pattern Constraints: |
| 60 | +* Template/Step/Task names: max 128 chars, pattern ^[a-zA-Z0-9][-a-zA-Z0-9]*$; |
| 61 | +* Parameter/Artifact names: pattern ^[a-zA-Z0-9_][-a-zA-Z0-9_]*$. |
| 62 | + |
| 63 | +#### Minimum Array Sizes: |
| 64 | +* Template.Steps requires at least one step group |
| 65 | +* Parameter.Enum requires at least one value |
| 66 | +* CronWorkflow.Schedules requires at least one schedule |
| 67 | +* DAG.Tasks requires at least one task. |
| 68 | + |
| 69 | +#### Numeric Constraints: |
| 70 | +* Parallelism minimum 1 |
| 71 | +* StartingDeadlineSeconds minimum 0. |
0 commit comments