You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* The validations for the fields within the `etcd` resource are done via [kubebuilder markers for CRD validation](https://book.kubebuilder.io/reference/markers/crd-validation).
4
-
* The validations for clusters with kubernetes versions `>= 1.29` are written using a combination of [CEL expressions](https://kubernetes.io/docs/reference/using-api/cel/) via the `x-validation`tag which provides a straightforward syntax to write validation rules for the fields, and pattern matching with the use of the `validation` tag.
4
+
* The validations for clusters with kubernetes versions `>= 1.29` are written using a combination of [CEL expressions](https://kubernetes.io/docs/reference/using-api/cel/) via the `XValidation` kubebuilder tag which provides a straightforward syntax to write validation rules for the fields, and pattern matching with the use of the `validation` kubebuilder tag.
5
5
* The validations for clusters with kubernetes versions `< 1.29` will not contain validations via `CEL` expressions since this is GA for kubernetes version 1.29 or higher.
6
6
* Upon any changes to the validation rules to the etcd resource, the `yaml` files for the same can be generated by running the `make generate` command.
7
7
8
8
## Validation rules:
9
9
### Type Validation rules:
10
10
The validations for fields of types `Duration`(metav1.Duration) and `cron` expressions are done via `regex` matching. These use the `validation:Pattern` marker.(The checking for the `Quantity`(resource.Quantity) fields are done by default, hence, no explicit validation is needed for the fields of this type):
***NOTE**: The provided regex does not account for `special strings` such as `@yearly` or `@monthly`. Additionally, it fails to invalidate cases involving the `step operator (x/y)` and the `range operator (x-y)`, where the cron expression is considered valid even if `x > y`. Please ensure these values are validated before passing the expression.
17
21
18
22
### Update validations
19
23
These validations are triggered when an update operation is done on the etcd resource.
20
-
* Immutable fields: The fields `etcd.spec.StorageClass` , `etcd.spec.StorageCapacity` and `etcd.spec.VolumeClaimTemplate` are immutable. The immutability is enforced by the CEL expression : `self == oldSelf`.
24
+
* Immutable fields: The fields `etcd.spec.StorageClass` , `etcd.spec.StorageCapacity` and `etcd.spec.VolumeClaimTemplate` are immutable. The immutability is enforced by the CEL expression:
25
+
```
26
+
self == oldSelf
27
+
```
21
28
22
-
* The value set for the field `etcd.spec.replicas` can either be decreased to `0` or increased. This is enforced by the CEL expression:
23
-
`self==0 ? true : self < oldSelf ? false : true`
29
+
* The value set for the field `etcd.spec.replicas` can either be decreased to `0` or increased, since etcd-druid does not yet support scaling down of etcd cluster size. While scaling up a hibernated etcd cluster from 0 replicas, the `etcd.status.clusterSize` field is checked to ensure that replicas can only be set to the previously recorded cluster size and not higher or lower. This is enforced by the CEL expression:
Hibernating the etcd cluster to 0 replicas is always allowed. If replicas field is changed from a non-zero value to another non-zero value, then the rule ensures that the replicas cannot be decreased, since down-scaling of etcd clusters is not currently supported. If the cluster is already hibernated and is attempted to be scaled up, then `etcd.status.clusterSize` field is checked to ensure that replicas can only be set to the previously recorded etcd cluster size. This is required to ensure that the scale-up logic is allowed to be executed correctly. If `etcd.status.clusterSize` is not set, then it is assumed that the etcd cluster has not been created yet and the replicas can be set to any value.
24
34
25
35
### Field validations
26
36
- The fields which expect only a particular set of values are checked by using the kubebuilder marker: `+kubebuilder:validation:Enum=<value1>;<value2>`
@@ -30,9 +40,14 @@ These validations are triggered when an update operation is done on the etcd res
30
40
* The `etcd.spec.sharedConfig.autoCompactionMode` can only be set as either `periodic` or `revision`.
31
41
32
42
33
-
* The value of `etcd.spec.backup.garbageCollectionPeriod` must be greater than `etcd.spec.backup.deltaSnapshotPeriod`. This is enforced by the CEL expression
34
-
`!(has(self.deltaSnapshotPeriod) && has(self.garbageCollectionPeriod)) || duration(self.deltaSnapshotPeriod).getSeconds() < duration(self.garbageCollectionPeriod).getSeconds()`. The first part of the expression ensures that both the fields are present and then compares the values of the garbageCollectionPeriod and deltaSnapshotPeriod fields, if not, skips the check.
43
+
* The value of `etcd.spec.backup.garbageCollectionPeriod` must be greater than `etcd.spec.backup.deltaSnapshotPeriod`. This is enforced by the CEL expression:
The first part of the expression ensures that both the fields are present and then compares the values of the garbageCollectionPeriod and deltaSnapshotPeriod fields, if not, skips the check.
35
48
36
-
* The value of `etcd.spec.StorageCapacity` must be more than 3 times that of the `etcd.spec.etcd.quota` if backups are enabled. If not, the value must be greater than that of the `etcd.spec.etcd.quota` field. This is enforced by using the CEL expression:
The check for whether backups are enabled or not is done by checking if the field `etcd.spec.backup.store` exists.
49
+
* The value of `etcd.spec.StorageCapacity` must be more than 3 times that of the `etcd.spec.etcd.quota` if backups are enabled. If not, the value must be greater than that of the `etcd.spec.etcd.quota` field. This is enforced by using the CEL expression:
0 commit comments