Skip to content

Commit 00d1954

Browse files
author
Robert Gartman
committed
Automate _cluster_setup
1 parent 0834916 commit 00d1954

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

mem3_helper.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def are_nodes_in_sync(names):
114114
local_resp = requests.get(local_membership_uri)
115115

116116
# If any difference is found - set to true
117-
is_different = False
117+
not_ready = False
118118

119119
# Step through every peer. Ensure they are "ready" before progressing.
120120
for name in names:
@@ -127,18 +127,20 @@ def are_nodes_in_sync(names):
127127

128128
if len(names) < 2:
129129
# Minimum 2 nodes to form cluster!
130-
is_different = True
130+
not_ready = True
131+
print("\tNeed at least 2 DNS records to start with. Got ",len(names))
131132

132133
# Compare local and remote _mebership data. Make sure the set
133134
# of nodes match. This will ensure that the remote nodes
134135
# are fully primed with nodes data before progressing with
135136
# _cluster_setup
136137
if (remote_resp.status_code == 200) and (local_resp.status_code == 200):
137-
if len(local_resp.json()) < 2:
138+
if len(local_resp.json()['cluster_nodes']) < 2:
138139
# Minimum 2 nodes to form cluster!
139-
is_different = True
140+
not_ready = True
141+
print("\tNeed at least 2 cluster nodes in the _membership of pod",os.getenv("HOSTNAME"))
140142
if ordered(local_resp.json()) != ordered(remote_resp.json()):
141-
is_different = True
143+
not_ready = True
142144

143145
# For logging only...
144146
records_in_local_but_not_in_remote = set(local_resp.json()['cluster_nodes']) - set(remote_resp.json()['cluster_nodes'])
@@ -148,8 +150,8 @@ def are_nodes_in_sync(names):
148150
if records_in_remote_but_not_in_local:
149151
print ("\tCluster members in {0} not yet present in {1}: {2}".format(name.split(".",1)[0], os.getenv("HOSTNAME"), records_in_remote_but_not_in_local))
150152
else:
151-
is_different = True
152-
return not is_different
153+
not_ready = True
154+
return not not_ready
153155

154156
def sleep_forever():
155157
while True:

0 commit comments

Comments
 (0)