From ac3e4cf9c9b84e43c39cc928ddd1f07687ad2b72 Mon Sep 17 00:00:00 2001
From: Vladislav Belogrudov <vladislav.belogrudov@oracle.com>
Date: Mon, 21 Nov 2016 13:55:23 +0300
Subject: [PATCH] Use kolla_internal_vip_address for glance_api servers

Nova and Cinder used a list of glance api servers - this list
does not provide a proper high availability because the servers
are connected at random without recalling who is failed last
time. E.g. out of three controllers with a failed first one nova
and cinder can try connection to the first controller because of
random / shuffled choice of the glance server. A proper solution
is to use VIP that connects to alive server from the beginning.
Also as workaround one could significantly increase max number
of retries in configuration files in hope that a random function
will choose a healthy glance server sometime - not a good choice.

Change-Id: Ifaf8ffe3697ec88a6da4c2b43c83975b63dc2e8c
Closes-Bug: #1643509
---
 ansible/roles/cinder/templates/cinder.conf.j2 | 2 +-
 ansible/roles/nova/templates/nova.conf.j2     | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/ansible/roles/cinder/templates/cinder.conf.j2 b/ansible/roles/cinder/templates/cinder.conf.j2
index 16f07b976c..e4ef07c33f 100644
--- a/ansible/roles/cinder/templates/cinder.conf.j2
+++ b/ansible/roles/cinder/templates/cinder.conf.j2
@@ -12,7 +12,7 @@ enable_v1_api=false
 osapi_volume_workers = {{ openstack_service_workers }}
 volume_name_template = volume-%s
 
-glance_api_servers = {% for host in groups['glance-api'] %}{{ internal_protocol }}://{% if orchestration_engine == 'KUBERNETES' %}glance-api{% else %}{{ hostvars[host]['ansible_' + hostvars[host]['api_interface']]['ipv4']['address'] }}{% endif %}:{{ glance_api_port }}{% if not loop.last %},{% endif %}{% endfor %}
+glance_api_servers = {{ internal_protocol }}://{% if orchestration_engine == 'KUBERNETES' %}glance-api{% else %}{{ kolla_internal_vip_address }}{% endif %}:{{ glance_api_port }}
 
 glance_num_retries = {{ groups['glance-api'] | length }}
 glance_api_version = 2
diff --git a/ansible/roles/nova/templates/nova.conf.j2 b/ansible/roles/nova/templates/nova.conf.j2
index 6706d16e96..9eb8b69ccb 100644
--- a/ansible/roles/nova/templates/nova.conf.j2
+++ b/ansible/roles/nova/templates/nova.conf.j2
@@ -106,7 +106,7 @@ api_endpoint = {{ internal_protocol }}://{{ kolla_internal_fqdn }}:{{ ironic_api
 lock_path = /var/lib/nova/tmp
 
 [glance]
-api_servers = {% for host in groups['glance-api'] %}{{ internal_protocol }}://{% if orchestration_engine == 'KUBERNETES' %}glance-api{% else %}{{ hostvars[host]['ansible_' + hostvars[host]['api_interface']]['ipv4']['address'] }}{% endif %}:{{ glance_api_port }}{% if not loop.last %},{% endif %}{% endfor %}
+api_servers = {{ internal_protocol }}://{% if orchestration_engine == 'KUBERNETES' %}glance-api{% else %}{{ kolla_internal_vip_address }}{% endif %}:{{ glance_api_port }}
 
 num_retries = {{ groups['glance-api'] | length }}