From 1c4d99123235d9f4334a05988982d0dac54ebbd3 Mon Sep 17 00:00:00 2001 From: David Ames Date: Mon, 18 Jun 2018 13:20:16 -0700 Subject: [PATCH] Do not use relation_ids directly Use a for loop to handle relation_ids for the case when the relationship has not yet been created. Change-Id: Ia9cf980591a1bf707f3a1a009229c5f5c222206f Closes-Bug: #1777508 --- hooks/percona_utils.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/hooks/percona_utils.py b/hooks/percona_utils.py index aab7ded..3cc0052 100644 --- a/hooks/percona_utils.py +++ b/hooks/percona_utils.py @@ -905,14 +905,14 @@ def cluster_ready(): return seeded() peers = {} - relation_id = relation_ids('cluster')[0] - units = related_units(relation_id) or [] - if local_unit() not in units: - units.append(local_unit()) - for unit in units: - peers[unit] = relation_get(attribute='ready', - rid=relation_id, - unit=unit) + for relation_id in relation_ids('cluster'): + units = related_units(relation_id) or [] + if local_unit() not in units: + units.append(local_unit()) + for unit in units: + peers[unit] = relation_get(attribute='ready', + rid=relation_id, + unit=unit) if len(peers) >= min_cluster_size: return all(peers.values())