Skip to content

Commit

Permalink
K8SPXC-1071 - Set default value for proxysql scheduler
Browse files Browse the repository at this point in the history
  • Loading branch information
tplavcic committed Aug 24, 2022
1 parent e77f84d commit 1bc8687
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
4 changes: 4 additions & 0 deletions pkg/apis/pxc/v1/pxc_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,10 @@ func (cr *PerconaXtraDBCluster) CheckNSetDefaults(serverVersion *version.ServerV
c.ProxySQL.ImagePullPolicy = corev1.PullAlways
}

if len(c.ProxySQL.Scheduler) == 0 {
c.ProxySQL.Scheduler = "percona"
}

c.ProxySQL.VolumeSpec.reconcileOpts()

if len(c.SSLSecretName) > 0 {
Expand Down
9 changes: 4 additions & 5 deletions pkg/pxc/queries/queries.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,13 +313,12 @@ func (p *Database) PresentInHostgroups(host string) (bool, error) {

func (p *Database) PrimaryHost(scheduler string) (string, error) {
var host string
var writerID int

// value of writer group is hardcoded in ProxySQL config inside docker image
// https://github.com/percona/percona-docker/blob/pxc-operator-1.3.0/proxysql/dockerdir/etc/proxysql-admin.cnf#L23
var writerID = 11
if scheduler == "percona" {
writerID = 100
} else {
// value of writer group is hardcoded in ProxySQL config inside docker image
// https://github.com/percona/percona-docker/blob/pxc-operator-1.3.0/proxysql/dockerdir/etc/proxysql-admin.cnf#L23
writerID = 11
}

err := p.db.QueryRow("SELECT hostname FROM runtime_mysql_servers WHERE hostgroup_id = ?", writerID).Scan(&host)
Expand Down

0 comments on commit 1bc8687

Please sign in to comment.