Skip to content

Commit efba00b

Browse files
author
Robert Gartman
committed
Automate _cluster_setup
1 parent 6c9bbd7 commit efba00b

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

mem3_helper.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ def are_nodes_in_sync(names):
164164
# "source"
165165
local_membership_uri = "http://127.0.0.1:5984/_membership"
166166
print ("Fetching CouchDB node mebership from this pod: {0}".format(local_membership_uri),flush=True)
167+
creds = (os.getenv("COUCHDB_USER"), os.getenv("COUCHDB_PASSWORD"))
167168
if creds[0] and creds[1]:
168169
local_resp = requests.get(local_membership_uri, auth=creds)
169170
else:
@@ -182,6 +183,9 @@ def are_nodes_in_sync(names):
182183
# are fully primed with nodes data before progressing with
183184
# _cluster_setup
184185
if (remote_resp.status_code == 200) and (local_resp.status_code == 200):
186+
if len(local_resp.json()) < 2:
187+
# Minimum 2 nodes to form cluster!
188+
is_different = True
185189
if ordered(local_resp.json()) != ordered(remote_resp.json()):
186190
is_different = True
187191
print ("Fetching CouchDB node mebership from this pod: {0}".format(local_membership_uri),flush=True)

0 commit comments

Comments
 (0)