Commit 11914b3e authored by Xavier Thompson's avatar Xavier Thompson

stack/erp5: Allow empty mariadb bootstrap-url

This skips replication bootstrap and requires that all binlogs be still
available on the primary. This is useful when the primary is recent and
does not have a ready backup for bootstrap yet, or when all binlogs are
still available and skipping the bootstrap seems more efficient.
parent a4157a6d
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
}, },
"oneOf": { "oneOf": {
{ {
"required": ["primary-url", "bootstrap-url"] "required": ["primary-url"]
}, },
{ {
"enum": [{}] "enum": [{}]
......
...@@ -26,7 +26,7 @@ md5sum = d10b8e35b02b5391cf46bf0c7dbb1196 ...@@ -26,7 +26,7 @@ md5sum = d10b8e35b02b5391cf46bf0c7dbb1196
[template-mariadb] [template-mariadb]
filename = instance-mariadb.cfg.in filename = instance-mariadb.cfg.in
md5sum = a6bdfc33ddea7afe667bbfc34bbb0a7c md5sum = 3f2417ba56343ece9b188b54255863db
[template-kumofs] [template-kumofs]
filename = instance-kumofs.cfg.in filename = instance-kumofs.cfg.in
......
...@@ -219,7 +219,7 @@ context = ...@@ -219,7 +219,7 @@ context =
{%- endif %} {%- endif %}
{% if replication -%} {% if replication -%}
{% set bootstrap_url = replication['bootstrap-url'] -%} {% set bootstrap_url = replication.get('bootstrap-url') -%}
{% set primary_url = replication['primary-url'] -%} {% set primary_url = replication['primary-url'] -%}
{% set primary = urllib_parse.urlsplit(primary_url) -%} {% set primary = urllib_parse.urlsplit(primary_url) -%}
[{{ section('mariadb-setup-replication') }}] [{{ section('mariadb-setup-replication') }}]
...@@ -233,8 +233,10 @@ inline = ...@@ -233,8 +233,10 @@ inline =
mycnf="${my-cnf:output}" mycnf="${my-cnf:output}"
mycnf_socket="${my-cnf-parameters:socket}" mycnf_socket="${my-cnf-parameters:socket}"
update_mysql="${update-mysql:output}" update_mysql="${update-mysql:output}"
{%- if bootstrap_url %}
bootstrap_url={{ six_moves.shlex_quote(bootstrap_url) }} bootstrap_url={{ six_moves.shlex_quote(bootstrap_url) }}
bootstrap_file="${directory:mariadb-backup-full}/bootstrap.sql.gz" bootstrap_file="${directory:mariadb-backup-full}/bootstrap.sql.gz"
{%- endif %}
curl="{{ parameter_dict['curl-location'] }}/bin/curl" curl="{{ parameter_dict['curl-location'] }}/bin/curl"
zcat="{{ parameter_dict['gzip-location'] }}/bin/zcat" zcat="{{ parameter_dict['gzip-location'] }}/bin/zcat"
mysql="${binary-wrap-mysql:wrapper-path}" mysql="${binary-wrap-mysql:wrapper-path}"
...@@ -263,6 +265,7 @@ inline = ...@@ -263,6 +265,7 @@ inline =
$update_mysql $update_mysql
echo " \_ OK" echo " \_ OK"
{%- if bootstrap_url %}
echo "Fetching $bootstrap_url" echo "Fetching $bootstrap_url"
$curl -o $bootstrap_file --fail $bootstrap_url $curl -o $bootstrap_file --fail $bootstrap_url
echo " \_ OK" echo " \_ OK"
...@@ -281,6 +284,12 @@ inline = ...@@ -281,6 +284,12 @@ inline =
fi fi
echo " \_ OK, found $SQL_SET_GTID" echo " \_ OK, found $SQL_SET_GTID"
{%- else %}
echo "Skipping bootstrap with empty GTID"
SQL_SET_GTID='SET GLOBAL gtid_slave_pos=""'
echo " \_ Using $SQL_SET_GTID"
{%- endif %}
echo "Configuring server as replica" echo "Configuring server as replica"
echo -n " \_" echo -n " \_"
$mysql -e "$SQL_SET_GTID" $mysql -e "$SQL_SET_GTID"
......
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