From 946ee47cf0f17ab90562e7ae7ea8502a39bdc898 Mon Sep 17 00:00:00 2001 From: Alex Kavanagh Date: Sun, 24 Jan 2021 16:12:42 +0000 Subject: [PATCH] Ensure PeerHARelationAdapter has correct backend IP addresses In the linked bug, the designate charm ended up with the wrong IP addresses in the haproxy.cfg due to the method add_default_addresses() overwriting the correctly determined addresses obtained by the method add_network_split_addresses(). It's not clear whether this has always been broken, and recent tests have exposed it, or whether changes in charms.reactive have resulted in add_default_addresses() adding more addresses than it used to. However, it seems correct that the default addresses are added first and then the ones from the relations/spaces add/overwrite the default ones to provide the correct set. Change-Id: Id7f1d457911374620e9a7ee3069376a1752160f5 Closes-Bug: #1912505 --- charms_openstack/adapters.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/charms_openstack/adapters.py b/charms_openstack/adapters.py index 71acdf4..082a680 100644 --- a/charms_openstack/adapters.py +++ b/charms_openstack/adapters.py @@ -303,13 +303,18 @@ class PeerHARelationAdapter(OpenStackRelationAdapter): self.api_config_adapter = APIConfigurationAdapter() self.local_address = self.api_config_adapter.local_address self.local_unit_name = self.api_config_adapter.local_unit_name - # Note(AJK) - bug #1698814 - cluster_hosts needs to be ordered so that - # re-writes with no changed data don't cause a restart (dictionaries - # are 'randomly' ordered) + # Note(ajkavanagh) - bug #1698814 - cluster_hosts needs to be ordered + # so that re-writes with no changed data don't cause a restart + # (dictionaries are 'randomly' ordered) self.cluster_hosts = collections.OrderedDict() if relation: - self.add_network_split_addresses() + # NOTE(ajkavanagh) BUG: #1912505 + # do add_default_addresses first, then add_network_split_addresses + # as otherwise it will inadvertently overwrite the correct + # addresses with the private-addresses of the remove units (rather + # the the address that is required) self.add_default_addresses() + self.add_network_split_addresses() @property def internal_addresses(self):