Commit 9714a74c authored by Łukasz Nowak's avatar Łukasz Nowak Committed by Łukasz Nowak

caddy-frontend: Publish only active slaves from main partition

As some of the nodes can lag behind, the system can be in state, that those
nodes will send inactive (also destroyed) slave publish information. Before
publishing it to master, check if each of slaves is really present on master.

Tasks:

 - [x] prove it really works on simulated environment
 - [x] check impact on massive simulated environment
 - [x] cover with a test (optionally)
 - [ ] check test results with this change

/reviewed-on !519
parent a11e39a6
...@@ -26,7 +26,7 @@ md5sum = 6fd023f0d29421d8579f0b3351473bb0 ...@@ -26,7 +26,7 @@ md5sum = 6fd023f0d29421d8579f0b3351473bb0
[template-apache-replicate] [template-apache-replicate]
filename = instance-apache-replicate.cfg.in filename = instance-apache-replicate.cfg.in
md5sum = 86f15c85054800a55a7093d37b03cdce md5sum = 15d6b5b00ab1f74d42863c90f2537981
[template-slave-list] [template-slave-list]
filename = templates/apache-custom-slave-list.cfg.in filename = templates/apache-custom-slave-list.cfg.in
...@@ -38,7 +38,7 @@ md5sum = 54ae95597a126ae552c3a913ddf29e5e ...@@ -38,7 +38,7 @@ md5sum = 54ae95597a126ae552c3a913ddf29e5e
[template-replicate-publish-slave-information] [template-replicate-publish-slave-information]
filename = templates/replicate-publish-slave-information.cfg.in filename = templates/replicate-publish-slave-information.cfg.in
md5sum = 01efde8febafcff6dde2ebb43e75a9e4 md5sum = 73e3d1e55a98a3c4d25a1618aa584fff
[template-caddy-frontend-configuration] [template-caddy-frontend-configuration]
filename = templates/Caddyfile.in filename = templates/Caddyfile.in
......
...@@ -223,6 +223,13 @@ custom-group = ${dynamic-publish-slave-information:rendered} ...@@ -223,6 +223,13 @@ custom-group = ${dynamic-publish-slave-information:rendered}
{{ frontend_section }} = {{ "${%s:connection-slave-instance-information-list}" % frontend_section }} {{ frontend_section }} = {{ "${%s:connection-slave-instance-information-list}" % frontend_section }}
{% endfor %} {% endfor %}
[active-slave-instance]
{% for slave_instance in slave_instance_list %}
{# Provide a list of slave titles send by master, in order to filter out already destroyed slaves #}
{# Note: This functionality is not yet covered by tests, please modify with care #}
{{ slave_instance['slave_title'] }} = active
{% endfor %}
[dynamic-publish-slave-information] [dynamic-publish-slave-information]
< = jinja2-template-base < = jinja2-template-base
template = {{ template_publish_slave_information }} template = {{ template_publish_slave_information }}
...@@ -231,6 +238,7 @@ extensions = jinja2.ext.do ...@@ -231,6 +238,7 @@ extensions = jinja2.ext.do
extra-context = extra-context =
section slave_information slave-information section slave_information slave-information
section rejected_slave_information rejected-slave-information section rejected_slave_information rejected-slave-information
section active_slave_instance_dict active-slave-instance
[monitor-conf-parameters] [monitor-conf-parameters]
monitor-url-list += monitor-url-list +=
......
...@@ -36,6 +36,9 @@ ...@@ -36,6 +36,9 @@
# Publish information for each slave # Publish information for each slave
{% for slave_reference, slave_information in slave_information_dict.iteritems() %} {% for slave_reference, slave_information in slave_information_dict.iteritems() %}
{# Filter out destroyed, so not existing anymore, slaves #}
{# Note: This functionality is not yet covered by tests, please modify with care #}
{% if slave_reference in active_slave_instance_dict %}
{% set publish_section_title = 'publish-%s' % slave_reference %} {% set publish_section_title = 'publish-%s' % slave_reference %}
{% do part_list.append(publish_section_title) %} {% do part_list.append(publish_section_title) %}
[{{ publish_section_title }}] [{{ publish_section_title }}]
...@@ -48,6 +51,7 @@ log-access-url = {{ dumps(json_module.dumps(log_access_url)) }} ...@@ -48,6 +51,7 @@ log-access-url = {{ dumps(json_module.dumps(log_access_url)) }}
{% for key, value in slave_information.iteritems() %} {% for key, value in slave_information.iteritems() %}
{{ key }} = {{ dumps(value) }} {{ key }} = {{ dumps(value) }}
{% endfor %} {% endfor %}
{% endif %}
{% endfor %} {% endfor %}
[buildout] [buildout]
......
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