Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

K8SPS-212: Add validation rules #308

Draft
wants to merge 15 commits into
base: main
Choose a base branch
from
Draft
3 changes: 3 additions & 0 deletions api/v1alpha1/perconaservermysql_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ import (
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.

// PerconaServerMySQLSpec defines the desired state of PerconaServerMySQL

// +kubebuilder:validation:XValidation:message="HAProxy can not be enabled with 'group-replication' clusterType", rule="self.mysql.clusterType=='group-replication' ? !self.proxy.haproxy.enabled : true"
// +kubebuilder:validation:XValidation:message="HAProxy and Orchestrator must be enabled with 'async' clusterType", rule="self.mysql.clusterType=='async' ? self.proxy.haproxy.enabled && self.orchestrator.enabled : true"
type PerconaServerMySQLSpec struct {
CRVersion string `json:"crVersion,omitempty"`
Pause bool `json:"pause,omitempty"`
Expand Down
7 changes: 7 additions & 0 deletions config/crd/bases/ps.percona.com_perconaservermysqls.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6694,6 +6694,13 @@ spec:
type: string
type: object
type: object
x-kubernetes-validations:
- message: HAProxy can not be enabled with 'group-replication' clusterType
rule: 'self.mysql.clusterType==''group-replication'' ? !self.proxy.haproxy.enabled
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now we support HAProxy + GR

: true'
- message: HAProxy and Orchestrator must be enabled with 'async' clusterType
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not true, you can have only 1 MySQL server and you should not have orc and HaProxy for it

Copy link
Contributor Author

@inelpandzic inelpandzic Mar 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok.. then the rules would be

  • HAProxy and Orchestrator must be enabled with 'async' clusterType if mysql.size > 1
  • HAProxy must be enabled with 'async' clusterType if mysql.size == 1

Is that right @hors

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@inelpandzic let's remove
HAProxy must be enabled with 'async' clusterType if mysql.size == 1

rule: 'self.mysql.clusterType==''async'' ? self.proxy.haproxy.enabled
&& self.orchestrator.enabled : true'
status:
properties:
backupVersion:
Expand Down
7 changes: 7 additions & 0 deletions deploy/bundle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8300,6 +8300,13 @@ spec:
type: string
type: object
type: object
x-kubernetes-validations:
- message: HAProxy can not be enabled with 'group-replication' clusterType
rule: 'self.mysql.clusterType==''group-replication'' ? !self.proxy.haproxy.enabled
: true'
- message: HAProxy and Orchestrator must be enabled with 'async' clusterType
rule: 'self.mysql.clusterType==''async'' ? self.proxy.haproxy.enabled
&& self.orchestrator.enabled : true'
status:
properties:
backupVersion:
Expand Down
7 changes: 7 additions & 0 deletions deploy/crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8300,6 +8300,13 @@ spec:
type: string
type: object
type: object
x-kubernetes-validations:
- message: HAProxy can not be enabled with 'group-replication' clusterType
rule: 'self.mysql.clusterType==''group-replication'' ? !self.proxy.haproxy.enabled
: true'
- message: HAProxy and Orchestrator must be enabled with 'async' clusterType
rule: 'self.mysql.clusterType==''async'' ? self.proxy.haproxy.enabled
&& self.orchestrator.enabled : true'
status:
properties:
backupVersion:
Expand Down