Commit bcc09491 authored by Xavier Thompson's avatar Xavier Thompson

stack/erp5: Reorganize mariadb replication jinja

parent b4a1cf36
......@@ -26,7 +26,7 @@ md5sum = d10b8e35b02b5391cf46bf0c7dbb1196
[template-mariadb]
filename = instance-mariadb.cfg.in
md5sum = e7a5e3863a673cb229855e1fbdbe0ba6
md5sum = 32a9e848d8e90a6f5f43dd6474706d07
[template-kumofs]
filename = instance-kumofs.cfg.in
......
......@@ -20,7 +20,20 @@
{% endif -%}
{% set bash = parameter_dict['bash'] ~ '/bin/bash' -%}
{% set dash = parameter_dict['dash-location'] ~ '/bin/dash' -%}
{#- Replication parameters -#}
{% set replication = slapparameter_dict.get('replication', {}) -%}
{% if replication -%}
{# cast to assert types -#}
{% set replica_threshold = int(replication.get('seconds-behind-master-threshold', -1)) -%}
{% set primary_url = str(replication['primary-url']) -%}
{% set bootstrap_url = replication.get('bootstrap-url') -%}
{% set primary = urllib_parse.urlsplit(primary_url) -%}
{% else -%}
{% set primary_url = None -%}
{% set primary = {'hostname': None, 'port': None, 'username': None} -%}
{% set replica_threshold = None -%}
{% endif -%}
[{{ section('publish') }}]
......@@ -219,9 +232,6 @@ context =
{%- endif %}
{% if replication -%}
{% set bootstrap_url = replication.get('bootstrap-url') -%}
{% set primary_url = replication['primary-url'] -%}
{% set primary = urllib_parse.urlsplit(primary_url) -%}
[{{ section('mariadb-setup-replication') }}]
recipe = slapos.recipe.template
output = ${directory:bin}/${:_buildout_section_name_}
......@@ -316,15 +326,6 @@ inline =
echo "Starting mariadb normally"
{%- endif %}
{% if replication -%}
{# cast to assert types -#}
{% set threshold = int(replication.get('seconds-behind-master-threshold', -1)) -%}
{% set primary_url = str(primary_url) -%}
{% else -%}
{% set primary_url = None -%}
{% set primary = {'hostname': None, 'port': None, 'username': None} -%}
{% set threshold = None -%}
{% endif -%}
[mariadb-replication-sense]
recipe = slapos.recipe.template
output = ${directory:bin}/${:_buildout_section_name_}
......@@ -339,7 +340,7 @@ inline =
expected_url = {{ repr(primary_url) }}
expected = {{ repr((primary.hostname, primary.port, primary.username)) }}
max_delay = {{ threshold }}
max_delay = {{ replica_threshold }}
@implementer(interface.IPromise)
class RunPromise(GenericPromise):
......
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