Reputation: 103
I am trying to programmatically set up a cluster. For that I have followed the documentation (here https://docs.couchdb.org/en/stable/setup/cluster.html#the-cluster-setup-api), and created a quick python script that does it for me.
I then get the following output: {'error': 'setup_error', 'reason': 'Cluster setup unable to sync admin passwords'}
. So I decided to try the Fauxton interface (which works) and see what goes over the line.
Made some changes to the python script to match exactly what Fauxton sends to the cluster... But were the manual interface (through Fauxton) works, I still get this "unable to sync" error when replicating what happens under the hood... This is driving me crazy now...
Using the following start script:
for i in {1..3}; \
do echo "$i"5984:5984; \
docker run -d --rm -p "$i"5984:5984 \
-e NODENAME=box0$i.couch -e ERL_FLAGS='-setcookie "brumbrum"' \
-e COUCHDB_USER=admin -e COUCHDB_PASSWORD=admin \
--name box0$i --network couch \
couchdb:3.1.1; \
done
which spins up three fresh docker containers using the 3.1.1 version of couchdb. The script I use to clusterize you can find here: https://github.com/wasperen/couchdb_clusterify/blob/main/clusterize.py
Thanks for any help. But anyway: happy new year!
Just followed the documentation step by step, with the same result:
root@75c127f35ad6:~# curl -X POST -H "Content-Type: application/json" http://admin:[email protected]:5984/_cluster_setup -d '{"action": "enable_cluster", "bind_address":"0.0.0.0", "username": "admin", "password":"admin", "node_count":"3"}'
{"error":"bad_request","reason":"Cluster is already enabled"}
root@75c127f35ad6:~# curl -X POST -H "Content-Type: application/json" http://admin:[email protected]:5984/_cluster_setup -d '{"action": "enable_cluster", "bind_address":"0.0.0.0", "username": "admin", "password":"admin", "port": 5984, "node_count": "3", "remote_node": "box02.couch", "remote_current_user": "admin", "remote_current_password": "admin" }'
{"ok":true}
root@75c127f35ad6:~# curl -X POST -H "Content-Type: application/json" http://admin:[email protected]:5984/_cluster_setup -d '{"action": "add_node", "host":"box02.couch", "port": 5984, "username": "admin", "password":"admin"}'
{"ok":true}
root@75c127f35ad6:~# curl -X POST -H "Content-Type: application/json" http://admin:[email protected]:5984/_cluster_setup -d '{"action": "enable_cluster", "bind_address":"0.0.0.0", "username": "admin", "password":"admin", "port": 5984, "node_count": "3", "remote_node": "box03.couch", "remote_current_user": "admin", "remote_current_password": "admin" }'
{"ok":true}
root@75c127f35ad6:~# curl -X POST -H "Content-Type: application/json" http://admin:[email protected]:5984/_cluster_setup -d '{"action": "add_node", "host":"box03.couch", "port": 5984, "username": "admin", "password":"admin"}'
{"ok":true}
root@75c127f35ad6:~# curl -X POST -H "Content-Type: application/json" http://admin:[email protected]:5984/_cluster_setup -d '{"action": "finish_cluster"}'
{"error":"setup_error","reason":"Cluster setup unable to sync admin passwords"}
And this from the browser logs, using the Fauxton user interface (on box01):
POST http://localhost:15984//_cluster_setup
DATA {"action":"enable_cluster","username":"admin","password":"admin","bind_address":"0.0.0.0","port":5984,"node_count":3,"singlenode":false}
RESPONSE 400 {"error":"bad_request","reason":"Cluster is already enabled"}
POST http://localhost:15984//_cluster_setup
DATA {"action":"enable_cluster","username":"admin","password":"admin","bind_address":"0.0.0.0","port":5984,"node_count":3,"remote_node":"box02.couch","remote_current_user":"admin","remote_current_password":"admin"}
RESPONSE 201 {"ok":true}
POST http://localhost:15984//_cluster_setup
DATA {"action":"add_node","username":"admin","password":"admin","host":"box02.couch","port":5984,"singlenode":false}
RESPONSE 201 {"ok":true}
POST http://localhost:15984//_cluster_setup
DATA {"action":"enable_cluster","username":"admin","password":"admin","bind_address":"0.0.0.0","port":5984,"node_count":3,"remote_node":"box03.couch","remote_current_user":"admin","remote_current_password":"admin"}
RESPONSE 201 {"ok":true}
POST http://localhost:15984//_cluster_setup
DATA {"action":"add_node","username":"admin","password":"admin","host":"box03.couch","port":5984,"singlenode":false}
RESPONSE 201 {"ok":true}
POST http://localhost:15984//_cluster_setup
DATA {"action":"finish_cluster"}
RESPONSE 201 {"ok":true}
GET http://localhost:15984/_membership
RESPONSE 200 {"all_nodes":["[email protected]","[email protected]","[email protected]"],"cluster_nodes":["[email protected]","[email protected]","[email protected]"]}
Upvotes: 1
Views: 731
Reputation: 1
I checked your code out, it looks all good seems like you are just hitting this issue here: https://github.com/apache/couchdb/issues/2858. It can get worked around with a GET request to the cluster coordinator node.
Upvotes: 0
Reputation: 21
I think there might be a bug in CouchDB 3.x where it does not accept the finish_cluster action when basic authentication is being used. Seems like it works perfectly fine if you get a session cookie first through the _session endpoint and then use that for authentication.
Upvotes: 2