Skip to content

Commit fc430be

Browse files
committed
Support clusters that have an admin account
1 parent 045e338 commit fc430be

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

mem3_helper.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import dns.resolver
1212
import socket
1313
import backoff
14+
import os
1415

1516
def construct_service_record():
1617
# Drop our Pod's unique identity and replace with '_couchdb._tcp'
@@ -35,10 +36,14 @@ def discover_peers(service_record):
3536
max_tries=10
3637
)
3738
def connect_the_dots(names):
39+
creds = (os.getenv("COUCHDB_USER"), os.getenv("COUCHDB_PASSWORD"))
3840
for name in names:
3941
uri = "http://127.0.0.1:5986/_nodes/couchdb@{0}".format(name)
4042
doc = {}
41-
resp = requests.put(uri, data=json.dumps(doc))
43+
if creds[0] and creds[1]:
44+
resp = requests.put(uri, data=json.dumps(doc), auth=creds)
45+
else:
46+
resp = requests.put(uri, data=json.dumps(doc))
4247
while resp.status_code == 404:
4348
print('Waiting for _nodes DB to be created ...')
4449
time.sleep(5)

0 commit comments

Comments
 (0)