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

K8SPXC-1071: Add Percona scheduler for ProxySQL #1436

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from
Draft

Conversation

egegunes
Copy link
Contributor

@egegunes egegunes commented Jun 13, 2023

K8SPXC-1071 Powered by Pull Request Badge

CHANGE DESCRIPTION

PXC Scheduler Handler is an application that can run as standalone or invoked from ProxySQL scheduler. Its function is to manage integration between ProxySQL and Galera (from Codership), including its different implementations like PXC. The scope of PXC Scheduler Handler is to maintain the ProxySQL mysql_server table, in a way that the PXC cluster managed will suffer of minimal negative effects due to possible data node: failures, service degradation and maintenance.

Connected PR for ProxySQL docker image: percona/percona-docker#647

This PR adds a new option in CR under .spec.proxysql section called pxchandler.
Values are:

Entrypoint in proxysql image prepares all config files at the same time so it is possible to switch between old and new scheduler. If we need to enable new scheduler we first check if the old one is installed and then remove it and install the new one.
Config file for new scheduler is located in: /etc/config.toml and it is enabled from pxc-monit sidecar.
Scheduler is enabled/disabled by percona-scheduler-admin script located here: https://github.com/percona/proxysql-admin-tool/blob/v2/percona-scheduler-admin

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?
  • Are OpenShift compare files changed for E2E tests (compare/*-oc.yml)?

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 PXC version?
  • Does the change support oldest and newest supported Kubernetes version?

tplavcic and others added 4 commits May 10, 2023 15:56
… proxysql

K8SPXC-1071 - Make percona-scheduler-admin usage optional

Fix bundle and crd

Add validation

Error fixes

fix build errors

K8SPXC-1071 - Add SCHEDULER environment var for proxysql container

K8SPXC-1071 - Set default value for proxysql scheduler

K8SPXC-1071 - Fix validation for proxysql scheduler field

Fix tests

Remove different writer hostgroup for percona scheduler

Remove scheduler as parameter for PrimaryHost function

Revert proxysql hostgroup to the old one in e2e-tests/functions

Leverage k8s API validation for Scheduler field

Check mysql_galera_hostgroups only if proxysql-admin scheduler used

Update tests

Return writeID to original position and type

Remove empty line

Switch default scheduler in code to proxysql-admin

Update tests

Rename proxysql scheduler to pxchandler

Fix validation for pxchandler for new variabe names

Update manifest

Fix review comment
@@ -813,6 +819,10 @@ func (cr *PerconaXtraDBCluster) CheckNSetDefaults(serverVersion *version.ServerV
c.ProxySQL.ImagePullPolicy = corev1.PullAlways
}

if cr.CompareVersionWith("1.12.0") >= 0 && len(c.ProxySQL.PXCHandler) == 0 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
if cr.CompareVersionWith("1.12.0") >= 0 && len(c.ProxySQL.PXCHandler) == 0 {
if cr.CompareVersionWith("1.13.0") >= 0 && len(c.ProxySQL.PXCHandler) == 0 {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -147,6 +147,13 @@ func (c *Proxy) AppContainer(spec *api.PodSpec, secrets string, cr *api.PerconaX
}
}

if cr.CompareVersionWith("1.12.0") >= 0 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
if cr.CompareVersionWith("1.12.0") >= 0 {
if cr.CompareVersionWith("1.13.0") >= 0 {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -236,6 +243,30 @@ func (c *Proxy) SidecarContainers(spec *api.PodSpec, secrets string, cr *api.Per
},
},
}

if cr.CompareVersionWith("1.12.0") >= 0 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
if cr.CompareVersionWith("1.12.0") >= 0 {
if cr.CompareVersionWith("1.13.0") >= 0 {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -813,6 +819,10 @@ func (cr *PerconaXtraDBCluster) CheckNSetDefaults(serverVersion *version.ServerV
c.ProxySQL.ImagePullPolicy = corev1.PullAlways
}

if cr.CompareVersionWith("1.12.0") >= 0 && len(c.ProxySQL.PXCHandler) == 0 {
c.ProxySQL.PXCHandler = "internal"
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe have "internal" and "scheduler" as consts, and like that, you can briefly describe them, like what "internal" refers to.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

inelpandzic
inelpandzic previously approved these changes Jun 14, 2023
Comment on lines +21 to +27
// Foo foo = ...;
// Any any;
// any.PackFrom(foo);
// ...
// if (any.UnpackTo(&foo)) {
// ...
// }
Copy link
Contributor

Choose a reason for hiding this comment

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

[gofmt] reported by reviewdog 🐶

Suggested change
// Foo foo = ...;
// Any any;
// any.PackFrom(foo);
// ...
// if (any.UnpackTo(&foo)) {
// ...
// }
// Foo foo = ...;
// Any any;
// any.PackFrom(foo);
// ...
// if (any.UnpackTo(&foo)) {
// ...
// }

Comment on lines +31 to +56
// Foo foo = ...;
// Any any = Any.pack(foo);
// ...
// if (any.is(Foo.class)) {
// foo = any.unpack(Foo.class);
// }
//
// Example 3: Pack and unpack a message in Python.
//
// foo = Foo(...)
// any = Any()
// any.Pack(foo)
// ...
// if any.Is(Foo.DESCRIPTOR):
// any.Unpack(foo)
// ...
//
// Example 4: Pack and unpack a message in Go
//
// foo := &pb.Foo{...}
// any, err := ptypes.MarshalAny(foo)
// ...
// foo := &pb.Foo{}
// if err := ptypes.UnmarshalAny(any, foo); err != nil {
// ...
// }
Copy link
Contributor

Choose a reason for hiding this comment

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

[gofmt] reported by reviewdog 🐶

Suggested change
// Foo foo = ...;
// Any any = Any.pack(foo);
// ...
// if (any.is(Foo.class)) {
// foo = any.unpack(Foo.class);
// }
//
// Example 3: Pack and unpack a message in Python.
//
// foo = Foo(...)
// any = Any()
// any.Pack(foo)
// ...
// if any.Is(Foo.DESCRIPTOR):
// any.Unpack(foo)
// ...
//
// Example 4: Pack and unpack a message in Go
//
// foo := &pb.Foo{...}
// any, err := ptypes.MarshalAny(foo)
// ...
// foo := &pb.Foo{}
// if err := ptypes.UnmarshalAny(any, foo); err != nil {
// ...
// }
// Foo foo = ...;
// Any any = Any.pack(foo);
// ...
// if (any.is(Foo.class)) {
// foo = any.unpack(Foo.class);
// }
//
// Example 3: Pack and unpack a message in Python.
//
// foo = Foo(...)
// any = Any()
// any.Pack(foo)
// ...
// if any.Is(Foo.DESCRIPTOR):
// any.Unpack(foo)
// ...
//
// Example 4: Pack and unpack a message in Go
//
// foo := &pb.Foo{...}
// any, err := ptypes.MarshalAny(foo)
// ...
// foo := &pb.Foo{}
// if err := ptypes.UnmarshalAny(any, foo); err != nil {
// ...
// }

//
// The pack methods provided by protobuf library will by default use
// 'type.googleapis.com/full.type.name' as the type URL and the unpack
// methods only use the fully qualified type name after the last '/'
// in the type URL, for example "foo.bar.com/x/y.z" will yield type
// name "y.z".
//
//
Copy link
Contributor

Choose a reason for hiding this comment

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

[gofmt] reported by reviewdog 🐶

Suggested change
//

Comment on lines +71 to +75
// package google.profile;
// message Person {
// string first_name = 1;
// string last_name = 2;
// }
Copy link
Contributor

Choose a reason for hiding this comment

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

[gofmt] reported by reviewdog 🐶

Suggested change
// package google.profile;
// message Person {
// string first_name = 1;
// string last_name = 2;
// }
// package google.profile;
// message Person {
// string first_name = 1;
// string last_name = 2;
// }

Comment on lines +77 to +81
// {
// "@type": "type.googleapis.com/google.profile.Person",
// "firstName": <string>,
// "lastName": <string>
// }
Copy link
Contributor

Choose a reason for hiding this comment

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

[gofmt] reported by reviewdog 🐶

Suggested change
// {
// "@type": "type.googleapis.com/google.profile.Person",
// "firstName": <string>,
// "lastName": <string>
// }
// {
// "@type": "type.googleapis.com/google.profile.Person",
// "firstName": <string>,
// "lastName": <string>
// }

@@ -46,8 +46,7 @@ func NewVersionServiceOperatorOK() *VersionServiceOperatorOK {
return &VersionServiceOperatorOK{}
}

/*
VersionServiceOperatorOK describes a response with status code 200, with default header values.
/*VersionServiceOperatorOK handles this case with default header values.
Copy link
Contributor

Choose a reason for hiding this comment

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

[gofmt] reported by reviewdog 🐶

Suggested change
/*VersionServiceOperatorOK handles this case with default header values.
/*
VersionServiceOperatorOK handles this case with default header values.

@@ -81,8 +81,7 @@ func NewVersionServiceOperatorDefault(code int) *VersionServiceOperatorDefault {
}
}

/*
VersionServiceOperatorDefault describes a response with status code -1, with default header values.
/*VersionServiceOperatorDefault handles this case with default header values.
Copy link
Contributor

Choose a reason for hiding this comment

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

[gofmt] reported by reviewdog 🐶

Suggested change
/*VersionServiceOperatorDefault handles this case with default header values.
/*
VersionServiceOperatorDefault handles this case with default header values.

for the version service product operation.

Typically these are written to a http.Request.
/*VersionServiceProductParams contains all the parameters to send to the API endpoint
Copy link
Contributor

Choose a reason for hiding this comment

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

[gofmt] reported by reviewdog 🐶

Suggested change
/*VersionServiceProductParams contains all the parameters to send to the API endpoint
/*
VersionServiceProductParams contains all the parameters to send to the API endpoint

@@ -46,8 +46,7 @@ func NewVersionServiceProductOK() *VersionServiceProductOK {
return &VersionServiceProductOK{}
}

/*
VersionServiceProductOK describes a response with status code 200, with default header values.
/*VersionServiceProductOK handles this case with default header values.
Copy link
Contributor

Choose a reason for hiding this comment

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

[gofmt] reported by reviewdog 🐶

Suggested change
/*VersionServiceProductOK handles this case with default header values.
/*
VersionServiceProductOK handles this case with default header values.

@@ -81,8 +81,7 @@ func NewVersionServiceProductDefault(code int) *VersionServiceProductDefault {
}
}

/*
VersionServiceProductDefault describes a response with status code -1, with default header values.
/*VersionServiceProductDefault handles this case with default header values.
Copy link
Contributor

Choose a reason for hiding this comment

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

[gofmt] reported by reviewdog 🐶

Suggested change
/*VersionServiceProductDefault handles this case with default header values.
/*
VersionServiceProductDefault handles this case with default header values.

@hors hors requested review from inelpandzic and hors June 14, 2023 09:26
@JNKPercona
Copy link
Collaborator

Test name Status
affinity-8-0 passed
auto-tuning-8-0 passed
cross-site-8-0 passed
demand-backup-cloud-8-0 passed
demand-backup-encrypted-with-tls-8-0 passed
demand-backup-8-0 passed
haproxy-5-7 failure
haproxy-8-0 failure
init-deploy-5-7 failure
init-deploy-8-0 failure
limits-8-0 passed
monitoring-2-0-8-0 failure
one-pod-5-7 passed
one-pod-8-0 passed
pitr-8-0 failure
pitr-gap-errors-8-0 passed
proxy-protocol-8-0 passed
proxysql-sidecar-res-limits-8-0 passed
recreate-8-0 passed
restore-to-encrypted-cluster-8-0 passed
scaling-proxysql-8-0 passed
scaling-8-0 passed
scheduled-backup-5-7 passed
scheduled-backup-8-0 passed
security-context-8-0 passed
smart-update1-8-0 passed
smart-update2-8-0 passed
storage-8-0 failure
tls-issue-cert-manager-ref-8-0 passed
tls-issue-cert-manager-8-0 passed
tls-issue-self-8-0 passed
upgrade-consistency-8-0 failure
upgrade-haproxy-8-0 failure
upgrade-proxysql-8-0 passed
users-5-7 failure
users-8-0 failure
validation-hook-8-0 passed
We run 37 out of 37

commit: 1de6526
image: perconalab/percona-xtradb-cluster-operator:PR-1436-1de6526a

@hors hors marked this pull request as draft December 7, 2023 17:21
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.

5 participants