percona-server-mysql-operator
percona-server-mysql-operator copied to clipboard
K8SPS-212: Add validation rules
CHANGE DESCRIPTION
Problem:
Some CR fields and their values are related in the sense when one field value is specified, some other should be a certain value. For example, if we set clusterType=group-replication then haproxy.enabled should be false. Now you can set it to enabled, but HAProxy would not be started at all since it does not work with GR cluster type.
Cause: Lack of validation when applying the CR.
Solution: Utilise CRD Validation Rules to validate CR upon creation and reject the create request if certain rules are not met.
Now when the user wants to create a CR with GR cluster type and he enables HAProxy, he will get a response like this.
➜ k apply -f deploy/cr.yaml
The PerconaServerMySQL "cluster1" is invalid: spec: Invalid value: "object": HAProxy can not be enabled with 'group-replication' clusterType
CHECKLIST
Jira
- [x] Is the Jira ticket created and referenced properly?
- [x] Does the Jira ticket have the proper statuses for documentation (
Needs Doc) and QA (Needs QA)? - [x] Does the Jira ticket link to the proper milestone (Fix Version field)?
Tests
- [ ] Is an E2E test/test case added for the new feature/change?
- [ ] Are unit tests added where appropriate?
Config/Logging/Testability
- [x] Are all needed new/changed options added to default YAML files?
- [x] Are the manifests (crd/bundle) regenerated if needed?
- [x] Did we add proper logging messages for operator actions?
- [x] Did we ensure compatibility with the previous version or cluster upgrade process?
- [x] Does the change support oldest and newest supported PS version?
- [x] Does the change support oldest and newest supported Kubernetes version?
| Test name | Status |
|---|---|
| version-service | failure |
| async-ignore-annotations | failure |
| auto-config | failure |
| config | failure |
| config-router | failure |
| demand-backup | failure |
| gr-demand-backup | failure |
| gr-demand-backup-haproxy | failure |
| gr-finalizer | failure |
| gr-haproxy | failure |
| gr-ignore-annotations | failure |
| gr-init-deploy | failure |
| gr-one-pod | failure |
| gr-recreate | failure |
| gr-scaling | failure |
| gr-scheduled-backup | failure |
| gr-security-context | failure |
| gr-self-healing | failure |
| gr-tls-cert-manager | failure |
| gr-users | failure |
| haproxy | failure |
| init-deploy | failure |
| limits | failure |
| monitoring | failure |
| one-pod | failure |
| operator-self-healing | failure |
| recreate | failure |
| scaling | failure |
| scheduled-backup | failure |
| service-per-pod | failure |
| sidecars | failure |
| smart-update | failure |
| tls-cert-manager | failure |
| users | failure |
| We run 34 out of 34 |
commit: https://github.com/percona/percona-server-mysql-operator/pull/308/commits/a4df79110848973bd012ab8e61c837b9fed7af7d
image: perconalab/percona-server-mysql-operator:PR-308-a4df7911