Fix for opencontrail.compute (member list uniq)
- make member list for collectors uniq (4.x)
- make member list for controllers uniq (4.x)
- backport it to 3.0 (otherwise two same servers may be chosen)
Prod-Related: PROD-33809
Change-Id: Ie220d385144aecf2f7ea3427c4e572a0e69028df
diff --git a/opencontrail/files/3.0/contrail-vrouter-agent.conf b/opencontrail/files/3.0/contrail-vrouter-agent.conf
index f057de4..4e5a422 100644
--- a/opencontrail/files/3.0/contrail-vrouter-agent.conf
+++ b/opencontrail/files/3.0/contrail-vrouter-agent.conf
@@ -9,7 +9,13 @@
# value provided by discovery service will be used. (Optional)
# server=10.0.0.1 10.0.0.2
{%- if not compute.discovery.get('enabled', True) %}
-server={% for member in compute.control.members[0:2] %}{{ member.host }}{% if not loop.last %} {% endif %}{% endfor %}
+{%- set control_members = [] %}
+{%- for member in compute.control.members %}
+{%- if member not in control_members %}
+{%- do control_members.append(member) %}
+{%- endif %}
+{%- endfor %}
+server={% for member in control_members[0:2] %}{{ member.host }}{% if not loop.last %} {% endif %}{% endfor %}
{%- endif %}
[DEFAULT]
@@ -20,7 +26,13 @@
# IP:port strings separated by space can be provided
# collectors=127.0.0.1:8086
{%- if not compute.discovery.get('enabled', True) %}
-collectors={% for member in compute.collector.members[0:2] %}{{ member.host }}:8086{% if not loop.last %} {% endif %}{% endfor %}
+{%- set collector_members = [] %}
+{%- for member in compute.collector.members %}
+{%- if member not in collector_members %}
+{%- do collector_members.append(member) %}
+{%- endif %}
+{%- endfor %}
+collectors={% for member in collector_members[0:2] %}{{ member.host }}:8086{% if not loop.last %} {% endif %}{% endfor %}
{%- endif %}
# Agent mode : can be vrouter / tsn / tor (default is vrouter)
@@ -121,7 +133,7 @@
# the value provided by discovery service will be used.
# server=10.0.0.1:53 10.0.0.2:53
{%- if not compute.discovery.get('enabled', True) %}
-server={% for member in compute.control.members[0:2] %}{{ member.host }}:53{% if not loop.last %} {% endif %}{% endfor %}
+server={% for member in control_members[0:2] %}{{ member.host }}:53{% if not loop.last %} {% endif %}{% endfor %}
{%- endif %}
# Client port used by vrouter-agent while connecting to contrail-named
diff --git a/opencontrail/files/3.0/contrail-vrouter-nodemgr.conf b/opencontrail/files/3.0/contrail-vrouter-nodemgr.conf
index 1efe1f2..09c1717 100644
--- a/opencontrail/files/3.0/contrail-vrouter-nodemgr.conf
+++ b/opencontrail/files/3.0/contrail-vrouter-nodemgr.conf
@@ -5,5 +5,11 @@
port=5998
{%- else %}
[COLLECTOR]
-server_list={% for member in compute.collector.members %}{{ member.host }}:8086{% if not loop.last %} {% endif %}{% endfor %}
+{%- set collector_members = [] %}
+{%- for member in compute.collector.members %}
+{%- if member not in collector_members %}
+{%- do collector_members.append(member) %}
+{%- endif %}
+{%- endfor %}
+server_list={% for member in collector_members %}{{ member.host }}:8086{% if not loop.last %} {% endif %}{% endfor %}
{%- endif %}
diff --git a/opencontrail/files/4.0/contrail-vrouter-agent.conf b/opencontrail/files/4.0/contrail-vrouter-agent.conf
index b5bca55..5f0e29c 100644
--- a/opencontrail/files/4.0/contrail-vrouter-agent.conf
+++ b/opencontrail/files/4.0/contrail-vrouter-agent.conf
@@ -6,14 +6,26 @@
[CONTROL-NODE]
# List of IPAdress:Port of control-node's separated by space.(Mandatory)
# servers=10.0.0.1:5269 10.0.0.2:5260 10.0.0.3:5260
-servers={% for member in compute.control.members %}{{ member.host }}:5269{% if not loop.last %} {% endif %}{% endfor %}
+{%- set control_members = [] %}
+{%- for member in compute.control.members %}
+{%- if member not in control_members %}
+{%- do control_members.append(member) %}
+{%- endif %}
+{%- endfor %}
+servers={% for member in control_members %}{{ member.host }}:5269{% if not loop.last %} {% endif %}{% endfor %}
[DEFAULT]
# Everything in this section is optional
# IP address and port to be used to connect to collector.
# Multiple IP:port strings separated by space can be provided
-collectors = {% for member in compute.collector.members %}{{ member.host }}:8086{% if not loop.last %} {% endif %}{% endfor %}
+{%- set collector_members = [] %}
+{%- for member in compute.collector.members %}
+{%- if member not in collector_members %}
+{%- do collector_members.append(member) %}
+{%- endif %}
+{%- endfor %}
+collectors = {% for member in collector_members %}{{ member.host }}:8086{% if not loop.last %} {% endif %}{% endfor %}
# Agent mode : can be vrouter / tsn / tor (default is vrouter)
# agent_mode=
@@ -141,7 +153,7 @@
# List of IPAdress:Port of DNS Servers separated by space.
# servers=10.0.0.1:53 10.0.0.2:53 10.0.0.3:53
-servers={% for member in compute.control.members %}{{ member.host }}:53{% if not loop.last %} {% endif %}{% endfor %}
+servers={% for member in control_members %}{{ member.host }}:53{% if not loop.last %} {% endif %}{% endfor %}
# Timeout for DNS server queries in milli-seconds
# dns_timeout=
diff --git a/opencontrail/files/4.0/contrail-vrouter-nodemgr.conf b/opencontrail/files/4.0/contrail-vrouter-nodemgr.conf
index 9ae7b81..9c2f26d 100644
--- a/opencontrail/files/4.0/contrail-vrouter-nodemgr.conf
+++ b/opencontrail/files/4.0/contrail-vrouter-nodemgr.conf
@@ -10,4 +10,10 @@
{%- endif %}
[COLLECTOR]
-server_list = {% for member in compute.collector.members %}{{ member.host }}:8086 {% endfor %}
+{%- set collector_members = [] %}
+{%- for member in compute.collector.members %}
+{%- if member not in collector_members %}
+{%- do collector_members.append(member) %}
+{%- endif %}
+{%- endfor %}
+server_list = {% for member in collector_members %}{{ member.host }}:8086 {% endfor %}