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

Conversation

inelpandzic
Copy link
Contributor

@inelpandzic inelpandzic commented Mar 3, 2023

K8SPS-212 Powered by Pull Request Badge

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

  • Is the Jira ticket created and referenced properly?
  • Does the Jira ticket have the proper statuses for documentation (Needs Doc) and QA (Needs QA)?
  • 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

  • Are all needed new/changed options added to default YAML files?
  • Are the manifests (crd/bundle) regenerated if needed?
  • Did we add proper logging messages for operator actions?
  • Did we ensure compatibility with the previous version or cluster upgrade process?
  • Does the change support oldest and newest supported PS version?
  • Does the change support oldest and newest supported Kubernetes version?

@pull-request-size pull-request-size bot added the size/S 10-29 lines label Mar 3, 2023
- 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
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

@pull-request-size pull-request-size bot added size/M 30-99 lines and removed size/S 10-29 lines labels Mar 3, 2023
@@ -8067,6 +8067,16 @@ 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

@pull-request-size pull-request-size bot added size/L 100-499 lines and removed size/M 30-99 lines labels Aug 17, 2024
@JNKPercona
Copy link
Collaborator

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: a4df791
image: perconalab/percona-server-mysql-operator:PR-308-a4df7911

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/L 100-499 lines
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants