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
This commit is contained in:
Alex Kavanagh 2021-01-24 16:12:42 +00:00
parent 3436b75913
commit 946ee47cf0
1 changed files with 9 additions and 4 deletions

View File

@ -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):