Check for network in role.networks for resolve and qdr

In https://review.opendev.org/722241 the service net map
HostnameResolveNetwor was fixed for roles that don't have
the InternalApi network. This follows up and fixes the
same issue for MetricsQdrNetwork and Ceph roles as well.

Also re-factor the jinja2 to iterate only once over the
roles.

Related-Bug: #1874330
Change-Id: Iff0e30a6c52fea75449dbd228dec45f708036f9f
This commit is contained in:
Harald Jensås 2020-10-12 13:16:34 +02:00
parent d1ea32cc88
commit e9da1a2a71
1 changed files with 14 additions and 12 deletions

View File

@ -90,24 +90,26 @@ parameters:
EtcdNetwork: {{ _service_nets.get('internal_api', 'ctlplane') }}
# HaproxyNetwork currently only controls the haproxy.stats network binding
HaproxyNetwork: ctlplane
# We special-case the default ResolveNetwork for the Ceph roles
# We special-case the default ResolveNetwork and MetricsQdrNetwork for the Ceph roles
# for backwards compatibility, all other roles default to internal_api
{%- for role in roles if role.name.startswith('Ceph') %}
{%- for role in roles %}
{%- if role.name.startswith('Ceph') %}
{%- if 'Storage' in role.networks %}
{{role.name}}HostnameResolveNetwork: {{ _service_nets.get('storage', 'ctlplane') }}
{%- endfor %}
{%- for role in roles if not role.name.startswith('Ceph') %}
{%- if 'InternalApi' in role.networks %}
{{role.name}}HostnameResolveNetwork: {{ _service_nets.get('internal_api', 'ctlplane') }}
{{role.name}}MetricsQdrNetwork: {{ _service_nets.get('storage', 'ctlplane') }}
{%- else %}
{{role.name}}HostnameResolveNetwork: ctlplane
{{role.name}}MetricsQdrNetwork: ctlplane
{%- endif %}
{%- endfor %}
# special-case for MetricsQdrNetwork, which will vary depending on role
{%- for role in roles if role.name == 'CephStorage' or role.name == 'BlockStorage' or role.name == 'ObjectStorage' %}
{{role.name}}MetricsQdrNetwork: {{ _service_nets.get('storage', 'ctlplane') }}
{%- endfor %}
{%- for role in roles if role.name != 'CephStorage' and role.name != 'BlockStorage' and role.name != 'ObjectStorage' %}
{%- else %}
{%- if 'InternalApi' in role.networks %}
{{role.name}}HostnameResolveNetwork: {{ _service_nets.get('internal_api', 'ctlplane') }}
{{role.name}}MetricsQdrNetwork: {{ _service_nets.get('internal_api', 'ctlplane') }}
{%- else %}
{{role.name}}HostnameResolveNetwork: ctlplane
{{role.name}}MetricsQdrNetwork: ctlplane
{%- endif %}
{%- endif %}
{%- endfor %}
description: Mapping of service_name -> network name. Typically set