Commit ba9ef609 authored by Julien Muchembled's avatar Julien Muchembled

ERP5: sort balancer families by name before assigning ports

If the list of families does not change, their ports must not change, and it's
wrong to get this by relying on CPython implementation details. Even if we
automated the update of frontends with new urls, this couldn't be done
atomically and we'd get random failures.

Currently, frontends are only updated manually so we also want to minimize
changes when families are added/renamed/removed. By sorting alphabetically,
we have something predictable. Of course, this does not cover cases like the
following one:
- before: A, B, C
- after: A, C
Even if we added a 'port-base' parameter for the balancer, the port would
change for one of the 2 families.

We have no need for the moment, but we could go further with an optional list
parameter to choose the order, and a special value to skip ports. Another
option is to use publish-early but it's more complicated to implement and
we lose everything when we reinstanciate.

The sort in haproxy.cfg.in is for the stats page.
parent aaefd3fc
......@@ -348,7 +348,7 @@ link-binary =
[template-balancer]
<= download-base
filename = instance-balancer.cfg.in
md5sum = 28c04f599cdbdfa97f2a67156f4f6b67
md5sum = ec9321514674c084e509ca070763b4a1
[template-apache-conf]
<= download-base
......@@ -358,7 +358,7 @@ md5sum = 713b22938d7212c8506449bc0508452b
[template-haproxy-cfg]
<= download-base
filename = haproxy.cfg.in
md5sum = 92c84313fd42f93565c5e5c3d9582bf2
md5sum = 3defd473e2cea17ae36bba7752494858
[bt5-repository]
# Format:
......
......@@ -36,7 +36,7 @@ defaults
# to render a page
option forceclose
{% for name, (port, backend_list) in parameter_dict['backend-dict'].items() -%}
{% for name, (port, backend_list) in sorted(parameter_dict['backend-dict'].iteritems()) -%}
listen {{ name }}
bind {{ parameter_dict['ip'] }}:{{ port }}
http-request set-header X-Balancer-Current-Cookie SERVERID
......
......@@ -44,7 +44,8 @@ ipv4 = {{ ipv4 }}
{% set haproxy_dict = {} -%}
{% set apache_dict = {} -%}
{% set next_port = slapparameter_dict['tcpv4-port'] -%}
{% for family_name, parameter_id_list in slapparameter_dict['zope-family-dict'].items() -%}
{% for family_name, parameter_id_list in sorted(
slapparameter_dict['zope-family-dict'].iteritems()) -%}
{% set zope_family_address_list = [] -%}
{% set has_webdav = [] -%}
{% for parameter_id in parameter_id_list -%}
......
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