Make peer discover more defensive

Before adding a (unit-name, address) tuple to the list of peers
for a particular address type, ensure that the unit has actually
presented data for the requested address type.

This avoids 'None' values being written to the haproxy configuration
files during initial deployment and scale back of units.

Change-Id: Ia10e1454791d92b9ca6233425b4a6ea89642def0
Closes-Bug: 1849901
This commit is contained in:
James Page
2020-07-20 08:22:27 +01:00
parent 92b649e6c4
commit 75286e5117

View File

@@ -35,7 +35,9 @@ class OpenstackHAPeers(RelationBase):
nodes = []
for conv in self.conversations():
host_name = conv.scope.replace('/', '-')
nodes.append((host_name, conv.get_remote(address_key)))
address = conv.get_remote(address_key)
if address:
nodes.append((host_name, address))
return nodes