Skip to content

Commit fccddce

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

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

mem3_helper.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,19 @@ def discover_peers(service_record):
3535
print("\tGot the following peers' fqdm from DNS lookup:",result,flush=True)
3636
return result
3737

38+
def backoff_hdlr(details):
39+
print ("Backing off {wait:0.1f} seconds afters {tries} tries "
40+
"calling function {target} with args {args} and kwargs "
41+
"{kwargs}".format(**details))
42+
43+
def pod_not_ready_yet(details):
44+
print ('\tConnection failure. CouchDB is not responding. Will retry.')
45+
3846
@backoff.on_exception(
3947
backoff.expo,
4048
requests.exceptions.ConnectionError,
41-
max_tries=10
49+
max_tries=3,
50+
on_giveup=pod_not_ready_yet
4251
)
4352
def connect_the_dots(names):
4453

@@ -75,7 +84,7 @@ def connect_the_dots(names):
7584
uri = "http://127.0.0.1:5986/_nodes/couchdb@{0}".format(name)
7685
doc = {}
7786
print('Adding CouchDB cluster node', name, "to this pod's CouchDB.")
78-
print ('\tRequest: GET',uri)
87+
print ('\tRequest: PUT',uri)
7988
if creds[0] and creds[1]:
8089
resp = requests.put(uri, data=json.dumps(doc), auth=creds)
8190
else:

0 commit comments

Comments
 (0)