Commit 31db0b32 authored by Vincent Pelletier's avatar Vincent Pelletier

stack/erp5/instance-erp5.cfg.in: Generate request-balancer section using "request" macro.

So that it proagates root instance's "balancer" parameter, as other
request-* sections do. No functional change is expected, this is rather
for code simplification and factorisation.
parent 959d5359
...@@ -74,7 +74,7 @@ md5sum = b5ac16fdeed8863e465e955ba6d1e12a ...@@ -74,7 +74,7 @@ md5sum = b5ac16fdeed8863e465e955ba6d1e12a
[template-erp5] [template-erp5]
filename = instance-erp5.cfg.in filename = instance-erp5.cfg.in
md5sum = a608ff4dfd0600826cadba6aa3881b48 md5sum = 068f2590a8ad4db1ad2f16eeb29986cf
[template-zeo] [template-zeo]
filename = instance-zeo.cfg.in filename = instance-zeo.cfg.in
......
...@@ -95,8 +95,35 @@ backup-caucased = ${:srv}/backup/caucased ...@@ -95,8 +95,35 @@ backup-caucased = ${:srv}/backup/caucased
{% do root_common.section('caucased-promise') -%} {% do root_common.section('caucased-promise') -%}
{% endif -%} {% endif -%}
{% do publish_dict.__setitem__('caucase-http-url', caucase_url) -%} {% do publish_dict.__setitem__('caucase-http-url', caucase_url) -%}
{% set balancer_dict = slapparameter_dict.get('balancer', {}) -%} {% set balancer_dict = slapparameter_dict.setdefault('balancer', {}) -%}
{% do balancer_dict.setdefault('ssl', {}).setdefault('caucase-url', caucase_url) -%} {% do balancer_dict.setdefault('ssl', {}).setdefault('caucase-url', caucase_url) -%}
{% do balancer_dict.setdefault('tcpv4-port', 2150) -%}
{% do balancer_dict.__setitem__('haproxy-server-check-path', balancer_dict.get('haproxy-server-check-path', '/') % {'site-id': site_id}) -%}
{% set routing_path_template_field_dict = {"site-id": site_id} -%}
{% macro expandRoutingPath(output, input) -%}
{% for outer_prefix, inner_prefix in input -%}
{% do output.append((outer_prefix, inner_prefix % routing_path_template_field_dict)) -%}
{% endfor -%}
{% endmacro -%}
{% set path_routing_list = [] -%}
{% do expandRoutingPath(
path_routing_list,
balancer_dict.get(
'path-routing-list',
(('/', '/'), ),
),
) -%}
{% do balancer_dict.__setitem__('path-routing-list', path_routing_list) -%}
{% set family_path_routing_dict = {} -%}
{% for name, family_path_routing_list in balancer_dict.get(
'family-path-routing-dict',
{},
).items() -%}
{% set path_routing_list = [] -%}
{% do expandRoutingPath(path_routing_list, family_path_routing_list) -%}
{% do family_path_routing_dict.__setitem__(name, path_routing_list) -%}
{% endfor -%}
{% do balancer_dict.__setitem__('family-path-routing-dict', family_path_routing_dict) -%}
{{ request('memcached-persistent', 'kumofs', 'kumofs', {'tcpv4-port': 2000}, {'url': True, 'monitor-base-url': False}, key_config={'monitor-passwd': 'monitor-htpasswd:passwd'}) }} {{ request('memcached-persistent', 'kumofs', 'kumofs', {'tcpv4-port': 2000}, {'url': True, 'monitor-base-url': False}, key_config={'monitor-passwd': 'monitor-htpasswd:passwd'}) }}
{{ request('memcached-volatile', 'kumofs', 'memcached', {'tcpv4-port': 2010, 'ram-storage-size': 64}, {'url': True, 'monitor-base-url': False}, key_config={'monitor-passwd': 'monitor-htpasswd:passwd'}) }} {{ request('memcached-volatile', 'kumofs', 'memcached', {'tcpv4-port': 2010, 'ram-storage-size': 64}, {'url': True, 'monitor-base-url': False}, key_config={'monitor-passwd': 'monitor-htpasswd:passwd'}) }}
...@@ -325,65 +352,39 @@ config-url = ${request-jupyter:connection-url} ...@@ -325,65 +352,39 @@ config-url = ${request-jupyter:connection-url}
{% endif -%} {% endif -%}
{%- endif %} {%- endif %}
[request-balancer] {% set balancer_ret_dict = {'monitor-base-url': False} -%}
<= request-common {% for family in zope_family_dict -%}
name = balancer {% do balancer_ret_dict.__setitem__(family, False) -%}
software-type = balancer {% do balancer_ret_dict.__setitem__(family + '-v6', False) -%}
{{ root_common.sla('balancer') }}
return =
monitor-base-url
{%- for family in zope_family_dict %}
{{ family }}
{{ family }}-v6
{% if test_runner_enabled %}
{{ family }}-test-runner-url-list
{% endif %}
{% endfor -%}
{% do monitor_base_url_dict.__setitem__('request-balancer', '${' ~ 'request-balancer' ~ ':connection-monitor-base-url}') -%}
config-zope-family-dict = {{ dumps(zope_family_parameter_dict) }}
config-tcpv4-port = {{ dumps(balancer_dict.get('tcpv4-port', 2150)) }}
{% for zope_section_id, name in zope_address_list_id_dict.items() -%}
config-{{ name }} = {{ ' ${' ~ zope_section_id ~ ':connection-zope-address-list}' }}
{% if test_runner_enabled -%} {% if test_runner_enabled -%}
config-{{ name }}-test-runner-address-list = {{ ' ${' ~ zope_section_id ~ ':connection-test-runner-address-list}' }} {% do balancer_ret_dict.__setitem__(family + '-test-runner-url-list', False) -%}
{% endif -%} {% endif -%}
{% endfor -%} {% endfor -%}
# XXX: should those really be same for all families ? {% set balancer_key_config_dict = {
config-haproxy-server-check-path = {{ dumps(balancer_dict.get('haproxy-server-check-path', '/') % {'site-id': site_id}) }} 'monitor-passwd': 'monitor-htpasswd:passwd',
{% set routing_path_template_field_dict = {"site-id": site_id} -%} } -%}
{% macro expandRoutingPath(output, input) -%} {% for zope_section_id, name in zope_address_list_id_dict.items() -%}
{% for outer_prefix, inner_prefix in input -%} {% do balancer_key_config_dict.__setitem__(
{% do output.append((outer_prefix, inner_prefix % routing_path_template_field_dict)) -%} name,
{% endfor -%} zope_section_id + ':connection-zope-address-list',
{% endmacro -%}
{% set path_routing_list = [] -%}
{% do expandRoutingPath(
path_routing_list,
balancer_dict.get(
'path-routing-list',
(('/', '/'), ),
),
) -%} ) -%}
config-path-routing-list = {{ dumps(path_routing_list) }} {% if test_runner_enabled -%}
{% set family_path_routing_dict = {} -%} {% do balancer_key_config_dict.__setitem__(
{% for name, family_path_routing_list in balancer_dict.get( name + '-test-runner-address-list',
'family-path-routing-dict', zope_section_id + ':connection-test-runner-address-list',
{}, ) -%}
).items() -%} {% endif -%}
{% set path_routing_list = [] -%}
{% do expandRoutingPath(path_routing_list, family_path_routing_list) -%}
{% do family_path_routing_dict.__setitem__(name, path_routing_list) -%}
{% endfor -%} {% endfor -%}
config-family-path-routing-dict = {{ dumps(family_path_routing_dict) }} {{ request(
config-monitor-passwd = ${monitor-htpasswd:passwd} name='balancer',
config-ssl = {{ dumps(balancer_dict['ssl']) }} software_type='balancer',
config-name = ${:name} config_key='balancer',
config-backend-path-dict = {{ dumps(zope_backend_path_dict) }} config={
config-ssl-authentication-dict = {{ dumps(ssl_authentication_dict) }} 'zope-family-dict': zope_family_parameter_dict,
config-apachedex-promise-threshold = {{ dumps(monitor_dict.get('apachedex-promise-threshold', 70)) }} 'backend-path-dict': zope_backend_path_dict,
config-apachedex-configuration = {{ 'ssl-authentication-dict': ssl_authentication_dict,
dumps( 'apachedex-promise-threshold': monitor_dict.get('apachedex-promise-threshold', 70),
monitor_dict.get( 'apachedex-configuration': monitor_dict.get(
'apachedex-configuration', 'apachedex-configuration',
[ [
'--logformat', '%h %l %u %t "%r" %>s %O "%{Referer}i" "%{User-Agent}i" %{ms}T', '--logformat', '%h %l %u %t "%r" %>s %O "%{Referer}i" "%{User-Agent}i" %{ms}T',
...@@ -392,7 +393,13 @@ config-apachedex-configuration = {{ ...@@ -392,7 +393,13 @@ config-apachedex-configuration = {{
'--skip-user-agent', 'Zabbix', '--skip-user-agent', 'Zabbix',
'--error-detail', '--error-detail',
'--js-embed', '--js-embed',
'--quiet'])) }} '--quiet',
],
),
},
ret=balancer_ret_dict,
key_config=balancer_key_config_dict,
) }}
[request-frontend-base] [request-frontend-base]
{% if has_frontend -%} {% if has_frontend -%}
......
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