Skip to content

Commit 0ecd368

Browse files
author
Robert Gartman
committed
Automate _cluster_setup
1 parent 1ba295d commit 0ecd368

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

mem3_helper.py

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -66,28 +66,21 @@ def connect_the_dots(names):
6666
print("expected_ordinals",expected_ordinals)
6767
print("found ordnials",found_ordinals)
6868

69-
# Are all expected_ordinals are part of found_ordinals?
69+
# Are there expected ordinals that are not part of the found ordinals?
7070
if( expected_ordinals - found_ordinals):
71-
print ('Expected to get at least pod(s)', expected_ordinals - found_ordinals, 'among the DNS records. Will retry.')
71+
print ('Expected to get at least the following pod ordinal(s)', expected_ordinals - found_ordinals, 'among the DNS records. Will retry.')
7272
else:
7373
creds = (os.getenv("COUCHDB_USER"), os.getenv("COUCHDB_PASSWORD"))
7474
for name in names:
7575
uri = "http://127.0.0.1:5986/_nodes/couchdb@{0}".format(name)
7676
doc = {}
77-
77+
print('Adding CouchDB cluster node', name, "to this pod's CouchDB.")
78+
print ('\tRequest: GET',uri)
7879
if creds[0] and creds[1]:
7980
resp = requests.put(uri, data=json.dumps(doc), auth=creds)
8081
else:
8182
resp = requests.put(uri, data=json.dumps(doc))
82-
while resp.status_code != 201 and resp.status_code != 409:
83-
print('Waiting for _nodes DB to be created.',uri,'returned', resp.status_code, resp.json(), flush=True)
84-
time.sleep(5)
85-
if creds[0] and creds[1]:
86-
resp = requests.put(uri, data=json.dumps(doc), auth=creds)
87-
else:
88-
resp = requests.put(uri, data=json.dumps(doc))
89-
if resp.status_code == 201:
90-
print('Adding CouchDB cluster node', name, "to this pod's CouchDB. Response code:", resp.status_code ,flush=True)
83+
print ("\tResponse:", setup_resp.status_code, setup_resp.json(),flush=True)
9184

9285
# Compare (json) objects - order does not matter. Credits to:
9386
# https://stackoverflow.com/a/25851972

0 commit comments

Comments
 (0)