-
Notifications
You must be signed in to change notification settings - Fork 2
feat: use rsandbox as ProxySQL monitor, add R/W split proxy users (#69, #70) #73
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -82,13 +82,35 @@ func GenerateConfig(cfg ProxySQLConfig) string { | |
| b.WriteString(")\n\n") | ||
| } | ||
|
|
||
| b.WriteString(fmt.Sprintf("%s=\n(\n", usersKey)) | ||
| b.WriteString(" {\n") | ||
| b.WriteString(fmt.Sprintf(" username=\"%s\"\n", cfg.MonitorUser)) | ||
| b.WriteString(fmt.Sprintf(" password=\"%s\"\n", cfg.MonitorPass)) | ||
| b.WriteString(" default_hostgroup=0\n") | ||
| b.WriteString(" }\n") | ||
| b.WriteString(")\n") | ||
| if isPgsql { | ||
| // PostgreSQL: single user entry (no R/W split) | ||
| b.WriteString(fmt.Sprintf("%s=\n(\n", usersKey)) | ||
| b.WriteString(" {\n") | ||
| b.WriteString(fmt.Sprintf(" username=\"%s\"\n", cfg.MonitorUser)) | ||
| b.WriteString(fmt.Sprintf(" password=\"%s\"\n", cfg.MonitorPass)) | ||
| b.WriteString(" default_hostgroup=0\n") | ||
| b.WriteString(" }\n") | ||
| b.WriteString(")\n") | ||
| } else { | ||
| // MySQL: three users — general purpose, dedicated writer, dedicated reader | ||
| b.WriteString(fmt.Sprintf("%s=\n(\n", usersKey)) | ||
| b.WriteString(" {\n") | ||
| b.WriteString(" username=\"msandbox\"\n") | ||
| b.WriteString(" password=\"msandbox\"\n") | ||
| b.WriteString(" default_hostgroup=0\n") | ||
| b.WriteString(" },\n") | ||
| b.WriteString(" {\n") | ||
| b.WriteString(" username=\"msandbox_rw\"\n") | ||
| b.WriteString(" password=\"msandbox\"\n") | ||
| b.WriteString(" default_hostgroup=0\n") | ||
| b.WriteString(" },\n") | ||
| b.WriteString(" {\n") | ||
| b.WriteString(" username=\"msandbox_ro\"\n") | ||
| b.WriteString(" password=\"msandbox\"\n") | ||
| b.WriteString(" default_hostgroup=1\n") | ||
| b.WriteString(" }\n") | ||
| b.WriteString(")\n") | ||
|
Comment on lines
+95
to
+112
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The MySQL proxy users are now hardcoded to |
||
| } | ||
|
|
||
| // For Group Replication / InnoDB Cluster topologies, configure ProxySQL | ||
| // to monitor GR status and automatically reroute on failover. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -67,11 +67,11 @@ func (p *ProxySQLProvider) CreateSandbox(config providers.SandboxConfig) (*provi | |
|
|
||
| monitorUser := config.Options["monitor_user"] | ||
| if monitorUser == "" { | ||
| monitorUser = "msandbox" | ||
| monitorUser = "rsandbox" | ||
| } | ||
| monitorPass := config.Options["monitor_password"] | ||
| if monitorPass == "" { | ||
| monitorPass = "msandbox" | ||
| monitorPass = "rsandbox" | ||
| } | ||
|
Comment on lines
69
to
75
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The default monitor user and password are changed to |
||
|
|
||
| host := config.Host | ||
|
|
@@ -117,8 +117,9 @@ func (p *ProxySQLProvider) CreateSandbox(config providers.SandboxConfig) (*provi | |
| scripts["use_proxy"] = fmt.Sprintf("#!/bin/bash\npsql -h %s -p %d -U %s \"$@\"\n", | ||
| host, mysqlPort, monitorUser) | ||
| } else { | ||
| scripts["use_proxy"] = fmt.Sprintf("#!/bin/bash\nmysql -h %s -P %d -u %s -p%s --prompt 'ProxySQL> ' \"$@\"\n", | ||
| host, mysqlPort, monitorUser, monitorPass) | ||
| // use_proxy connects as msandbox (app user), not the monitor user (rsandbox) | ||
| scripts["use_proxy"] = fmt.Sprintf("#!/bin/bash\nmysql -h %s -P %d -u msandbox -pmsandbox --prompt 'ProxySQL> ' \"$@\"\n", | ||
| host, mysqlPort) | ||
|
Comment on lines
+121
to
+122
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
Comment on lines
+120
to
+122
|
||
| } | ||
|
|
||
| for name, content := range scripts { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -84,8 +84,8 @@ func DeployProxySQLForTopology(sandboxDir string, masterPort int, slavePorts []i | |
| DbUser: "admin", | ||
| DbPassword: "admin", | ||
| Options: map[string]string{ | ||
| "monitor_user": "msandbox", | ||
| "monitor_password": "msandbox", | ||
| "monitor_user": "rsandbox", | ||
| "monitor_password": "rsandbox", | ||
| "backends": strings.Join(backendParts, ","), | ||
| "backend_provider": backendProvider, | ||
|
Comment on lines
86
to
90
|
||
| "topology": topologyName(topology), | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GenerateConfig() now hard-codes MySQL frontend users/passwords to msandbox/msandbox (and msandbox_rw/msandbox_ro). This makes ProxySQL config incorrect when the sandbox is deployed with non-default --db-user/--db-password (the grants templates create these users with {{.DbUser}}/{{.DbPassword}}). Consider deriving these usernames/passwords from inputs (e.g., add fields to ProxySQLConfig or provider options for proxy user/password) so ProxySQL stays in sync with the sandbox credentials.