Commit 657570f9 authored by Alain Takoudjou's avatar Alain Takoudjou

repman: fix add support for multiple SQL proxy

parent a27c7329
...@@ -18,11 +18,11 @@ md5sum = b6798777834fdc4789591b9a53048e9c ...@@ -18,11 +18,11 @@ md5sum = b6798777834fdc4789591b9a53048e9c
[instance-repman.cfg] [instance-repman.cfg]
_update_hash_filename_ = instance-repman.cfg.jinja2.in _update_hash_filename_ = instance-repman.cfg.jinja2.in
md5sum = e89737ecaa9308baa792d01f8f130667 md5sum = dc55574a7a7374c7e2d2a8173925b213
[instance-proxy.cfg] [instance-proxy.cfg]
_update_hash_filename_ = instance-proxy.cfg.jinja2.in _update_hash_filename_ = instance-proxy.cfg.jinja2.in
md5sum = a8560b62fa3e8907a9483bb55ce02ebf md5sum = 4a01dc6efaef2caa780024a48339d6a4
[config-toml.in] [config-toml.in]
_update_hash_filename_ = templates/config.toml.in _update_hash_filename_ = templates/config.toml.in
......
{% set publish_dict = {} -%} {% set publish_dict = {} -%}
{% set part_list = [] -%} {% set part_list = [] -%}
{% set ip = (ipv6_set | list)[0] -%} {% set ipv6 = (ipv6_set | list)[0] -%}
{% set ipv4 = (ipv4_set | list)[0] -%} {% set ipv4 = (ipv4_set | list)[0] -%}
{% set name = slapparameter_dict['proxy-name'] -%} {% set name = slapparameter_dict['proxy-name'] -%}
{% set monitor_password = slapparameter_dict['monitor-passwd'] -%} {% set monitor_password = slapparameter_dict['monitor-passwd'] -%}
...@@ -8,8 +8,16 @@ ...@@ -8,8 +8,16 @@
{% set proxy_port = slapparameter_dict.get('proxy-port', 6032) -%} {% set proxy_port = slapparameter_dict.get('proxy-port', 6032) -%}
{% set proxy_admin_port = slapparameter_dict.get('proxy-admin-port', 7032) -%} {% set proxy_admin_port = slapparameter_dict.get('proxy-admin-port', 7032) -%}
{% set cluster_list = [] -%} {% set cluster_list = [] -%}
{% set use_ipv6 = slapparameter_dict.get('use-ipv6', False) -%}
{% set host = ipv4 -%}
{% set ip = ipv4 -%}
{% do cluster_list.append({'name':name, 'host': ipv4, 'port': proxy_admin_port}) -%} {% if use_ipv6 -%}
{% set host = '[' ~ ipv6 ~ ']' -%}
{% set ip = ipv6 -%}
{% endif -%}
{% do cluster_list.append({'name':name, 'host': host, 'port': proxy_admin_port}) -%}
[directory] [directory]
recipe = slapos.cookbook:mkdirectory recipe = slapos.cookbook:mkdirectory
...@@ -60,7 +68,7 @@ stop-on-error = false ...@@ -60,7 +68,7 @@ stop-on-error = false
config = ${directory:etc}/proxysql.cnf config = ${directory:etc}/proxysql.cnf
data = ${directory:data} data = ${directory:data}
command = command =
${download-proxy-config:rendered} {{ name }} {{ ipv4 }} {{ proxy_admin_port }} ${:config} ${download-proxy-config:rendered} {{ name }} {{ host }} {{ proxy_admin_port }} ${:config}
update-command = ${:command} update-command = ${:command}
[proxysql-wrapper] [proxysql-wrapper]
...@@ -78,28 +86,30 @@ wait-for-files = ...@@ -78,28 +86,30 @@ wait-for-files =
depends = depends =
${proxysql-admin-promise:recipe} ${proxysql-admin-promise:recipe}
${proxysql-promise:recipe} ${proxysql-promise:recipe}
${proxysql-ipv6-promise:recipe}
[proxysql-admin-promise] [proxysql-admin-promise]
<= monitor-promise-base <= monitor-promise-base
module = check_port_listening module = check_port_listening
name = proxysql-admin-port-listening.py name = proxysql-admin-port-listening.py
config-hostname= {{ ipv4 }} config-hostname= {{ ip }}
config-port = {{ proxy_admin_port }} config-port = {{ proxy_admin_port }}
[proxysql-promise] [proxysql-promise]
<= monitor-promise-base <= monitor-promise-base
module = check_port_listening module = check_port_listening
name = proxysql-port-listening.py name = proxysql-port-listening.py
config-hostname= {{ ipv4 }} config-hostname= {{ ip }}
config-port = {{ proxy_port }} config-port = {{ proxy_port }}
{% if not use_ipv6 -%}
[proxysql-ipv6-promise] [proxysql-ipv6-promise]
<= monitor-promise-base <= monitor-promise-base
module = check_port_listening module = check_port_listening
name = proxysql-ipv6-port-listening.py name = proxysql-ipv6-port-listening.py
config-hostname= {{ ip }} config-hostname= {{ ip }}
config-port = {{ proxy_port }} config-port = {{ proxy_port }}
{% do part_list.append("proxysql-ipv6-promise") -%}
{% endif -%}
{% set service_name = "proxy-" ~ name -%} {% set service_name = "proxy-" ~ name -%}
{% set proxysql_dict = {"name": service_name, "command": "${proxysql-wrapper:wrapper-path}", {% set proxysql_dict = {"name": service_name, "command": "${proxysql-wrapper:wrapper-path}",
...@@ -125,7 +135,7 @@ recipe = slapos.cookbook:publish.serialised ...@@ -125,7 +135,7 @@ recipe = slapos.cookbook:publish.serialised
proxy-port = {{ proxy_port }} proxy-port = {{ proxy_port }}
proxy-admin-port = {{ proxy_admin_port }} proxy-admin-port = {{ proxy_admin_port }}
ipv4 = {{ ipv4 }} ipv4 = {{ ipv4 }}
ipv6 = {{ ip }} ipv6 = {{ ipv6 }}
partition-path = ${buildout:directory} partition-path = ${buildout:directory}
......
...@@ -157,7 +157,8 @@ ...@@ -157,7 +157,8 @@
"description": "Database amount to deploy with this cluster. Minimal amount is 2 required to enable replication.", "description": "Database amount to deploy with this cluster. Minimal amount is 2 required to enable replication.",
"type": "integer", "type": "integer",
"default": 2, "default": 2,
"minimum": 2 "minimum": 2,
"maximum": 4
}, },
"-sla-0-computer_guid": { "-sla-0-computer_guid": {
"title": "Prefered Master Computer Guid", "title": "Prefered Master Computer Guid",
...@@ -236,7 +237,20 @@ ...@@ -236,7 +237,20 @@
"description": "Number of Proxy instances de deploy", "description": "Number of Proxy instances de deploy",
"type": "integer", "type": "integer",
"default": 1, "default": 1,
"minimum": 1 "minimum": 1,
"maximum": 3
},
"-sla-proxy1-computer_guid": {
"title": "Second SQL Proxy Computer Guid",
"description": "Computer Guid for the second SQL Proxy instance. The first proxy instance is requested on root partition.",
"type": "string",
"default": ""
},
"-sla-proxy2-computer_guid": {
"title": "Third Proxy Computer Guid",
"description": "Computer Guid for the third SQL Proxy instance. The first proxy instance is requested on root partition.",
"type": "string",
"default": ""
}, },
"proxy-cpu-cores": { "proxy-cpu-cores": {
"title": "Proxy Cpu cores", "title": "Proxy Cpu cores",
......
...@@ -101,7 +101,18 @@ return = ...@@ -101,7 +101,18 @@ return =
<= request-common <= request-common
software-type = proxydb software-type = proxydb
name = {{ proxy_name }} name = {{ proxy_name }}
#sla-computer_guid = {% if i == 0 -%}
{% do proxy_config_dict['ip'].append('${' ~ section ~ ':connection-ipv4}') -%}
{# set proxysql-servers-ipv6 to also allow access proxy via ipv6 -#}
{% do proxy_config_dict['ipv6'].append('${' ~ section ~ ':connection-ipv6}') -%}
sla-computer_guid = ${slap-connection:computer-id}
{% else -%}
sla-computer_guid = {{ dumps(parameter_dict.get('-sla-proxy' ~ i ~'-computer_guid', '')) }}
# This proxy can be on different machine with repman, so we enforce use IPv6
{% do proxy_config_dict['ip'].append("[${" ~ section ~ ":connection-ipv6}]") -%}
{% do proxy_config_dict['ipv6'].append('${' ~ section ~ ':connection-ipv6}') -%}
config-use-ipv6 = True
{% endif -%}
config-monitor-passwd = ${publish-early:monitor-password} config-monitor-passwd = ${publish-early:monitor-password}
config-repman-url = ${nginx-parameter:backend-url} config-repman-url = ${nginx-parameter:backend-url}
config-repman-secure-url = ${nginx-parameter:backend-ssl-url} config-repman-secure-url = ${nginx-parameter:backend-ssl-url}
...@@ -110,15 +121,13 @@ config-type = {{ parameter_dict.get('proxy-type', "proxysql") }} ...@@ -110,15 +121,13 @@ config-type = {{ parameter_dict.get('proxy-type', "proxysql") }}
config-proxy-port = {{ proxy_config_dict['port'] }} config-proxy-port = {{ proxy_config_dict['port'] }}
config-admin-proxy-port = {{ proxy_config_dict['admin-port'] }} config-admin-proxy-port = {{ proxy_config_dict['admin-port'] }}
config-bootstraped = false config-bootstraped = false
return = return =
partition-path partition-path
monitor-base-url monitor-base-url
ipv4 ipv4
ipv6 ipv6
{% do part_list.append(section) -%} {% do part_list.append(section) -%}
{% do proxy_config_dict['ip'].append('${' ~ section ~ ':connection-ipv4}') -%}
{% do proxy_config_dict['ipv6'].append('${' ~ section ~ ':connection-ipv6}') -%}
{% do proxy_config_dict['partition'].append('${' ~ section ~ ':connection-partition-path}') -%} {% do proxy_config_dict['partition'].append('${' ~ section ~ ':connection-partition-path}') -%}
{% do monitor_base_url_dict.__setitem__('proxy' ~ name ~ '-' ~ i, '${' ~ section ~ ':connection-monitor-base-url}') -%} {% do monitor_base_url_dict.__setitem__('proxy' ~ name ~ '-' ~ i, '${' ~ section ~ ':connection-monitor-base-url}') -%}
...@@ -197,18 +206,23 @@ context = ...@@ -197,18 +206,23 @@ context =
{% set proxy = "request-proxy-" ~ name ~ '-' ~ i -%} {% set proxy = "request-proxy-" ~ name ~ '-' ~ i -%}
{% for database in database_list -%} {% for database in database_list -%}
{% if database.get('user') -%} {% if database.get('user') -%}
{% do publish_database_list.append("mysql://" ~ database['user'] ~ ":" ~ database['password'] ~ "@${" ~ proxy ~ ":connection-ipv4}:" ~ proxy_config_dict['port'] ~ "/" ~ database['name']) -%} {# first proxy which is deployed on repman partition can use ipv4 connexion string -#}
{% if i == 0 -%}
{% do publish_database_list.append("mysql://" ~ database['user'] ~ ":" ~ database['password'] ~ "@${" ~ proxy ~ ":connection-ipv4}:" ~ proxy_config_dict['port'] ~ "/" ~ database['name']) -%}
{% endif -%}
{% do publish_database_v6_list.append("mysql://" ~ database['user'] ~ ":" ~ database['password'] ~ "@[${" ~ proxy ~ ":connection-ipv6}]:" ~ proxy_config_dict['port'] ~ "/" ~ database['name']) -%} {% do publish_database_v6_list.append("mysql://" ~ database['user'] ~ ":" ~ database['password'] ~ "@[${" ~ proxy ~ ":connection-ipv6}]:" ~ proxy_config_dict['port'] ~ "/" ~ database['name']) -%}
{% else -%} {% else -%}
{% do publish_database_list.append("mysql://${" ~ proxy ~ ":connection-ipv4}:" ~ proxy_config_dict['port'] ~ "/" ~ database['name']) -%} {% if i == 0 -%}
{% do publish_database_list.append("mysql://${" ~ proxy ~ ":connection-ipv4}:" ~ proxy_config_dict['port'] ~ "/" ~ database['name']) -%}
{% endif -%}
{% do publish_database_v6_list.append("mysql://[${" ~ proxy ~ ":connection-ipv6}]:" ~ proxy_config_dict['port'] ~ "/" ~ database['name']) -%} {% do publish_database_v6_list.append("mysql://[${" ~ proxy ~ ":connection-ipv6}]:" ~ proxy_config_dict['port'] ~ "/" ~ database['name']) -%}
{% endif -%} {% endif -%}
{% endfor -%} {% endfor -%}
{% endfor -%} {% endfor -%}
{% do part_list.append('config-' ~ name) -%} {% do part_list.append('config-' ~ name) -%}
{% do publish_dict.__setitem__(name ~ '-db-list', "!py!['" ~ publish_database_list | join("', '") ~ "']") -%} {% do publish_dict.__setitem__(name ~ '-db-list-ipv4', "!py!['" ~ publish_database_list | join("', '") ~ "']") -%}
{% do publish_dict.__setitem__(name ~ '-db-list-v6', "!py!['" ~ publish_database_v6_list | join("', '") ~ "']") -%} {% do publish_dict.__setitem__(name ~ '-db-list-ipv6', "!py!['" ~ publish_database_v6_list | join("', '") ~ "']") -%}
{% endfor -%} {% endfor -%}
[slap-configuration] [slap-configuration]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment