Skip to content

Commit f192f57

Browse files
author
Robert Gartman
committed
Automate _cluster_setup
1 parent ff894dd commit f192f57

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

mem3_helper.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ 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+
is_different = False
118+
118119
# Step through every peer. Ensure they are "ready" before progressing.
119120
for name in names:
120121
print("Probing {0} for cluster membership".format(name))
@@ -123,6 +124,11 @@ def are_nodes_in_sync(names):
123124
remote_resp = requests.get(remote_membership_uri, auth=creds)
124125
else:
125126
remote_resp = requests.get(remote_membership_uri)
127+
128+
if len(names) < 2:
129+
# Minimum 2 nodes to form cluster!
130+
is_different = True
131+
126132
# Compare local and remote _mebership data. Make sure the set
127133
# of nodes match. This will ensure that the remote nodes
128134
# are fully primed with nodes data before progressing with
@@ -142,6 +148,10 @@ def are_nodes_in_sync(names):
142148
print ("Cluster members in {0} not yet present in {1}: {2}".format(name.split(".",1)[0], os.getenv("HOSTNAME"), records_in_remote_but_not_in_local))
143149
else:
144150
is_different = True
151+
152+
if (remote_resp.status_code == 200) and (local_resp.status_code == 200):
153+
print("local: ",local_resp.json().cluster_nodes)
154+
print("remote: ",remote_resp.json().cluster_nodes)
145155
print('returnerar', not is_different)
146156
return not is_different
147157

0 commit comments

Comments
 (0)