Skip to content

Cluster set up with API fails with unknown_error #2797

@YC

Description

@YC

Description

Encountered an issue when trying to automate CouchDB 3.0 cluster setup with cluster setup API, described at https://docs.couchdb.org/en/stable/setup/cluster.html#the-cluster-setup-api.

If the / path is not accessed before finish_cluster is called, {"error":"unknown_error","reason":"undef","ref":1124911208} is given.

Steps to Reproduce

Pre-existing data directories are deleted and docker-compose up -d is executed on all nodes
Docker compose configuration

version: '3'
services:
  couchdb:
    image: couchdb:3
    environment:
      - COUCHDB_USER=user
      - COUCHDB_PASSWORD=pass
      - COUCHDB_SECRET=secret
      - NODENAME=<ip of node>
    command: "-setcookie cookie"
    ports:
      - "5984:5984"
      - "4369:4369"
      - "9100:9100"
    volumes:
      - ./data:/opt/couchdb/data

Assuming a 2 node setup:
On setup node: the following commands are executed:

curl http://user:pass@localhost:5984/_cluster_setup
curl --request POST \
  --url http://user:pass@localhost:5984/_cluster_setup \
  --header 'content-type: application/json' \
  --data '{
	"action": "enable_cluster",
	"bind_address": "0.0.0.0",
	"username": "user",
	"password": "pass",
	"port": 5984,
	"node_count": 2,
	"remote_node": "<ip of remote node>",
	"remote_current_user": "user",
	"remote_current_password": "pass"
}'
curl --request POST \
  --url http://user:pass@localhost:5984/_cluster_setup \
  --header 'content-type: application/json' \
  --data '{
    "action": "add_node",
    "host": "<ip of remote node>",
    "port": 5984,
    "username": "user",
    "password": "pass",
    "singlenode": false
}'
# curl http://localhost:5984/
curl --request POST \
  --url http://user:pass@localhost:5984/_cluster_setup \
  --header 'content-type: application/json' \
  --data '{ "action": "finish_cluster" }'
curl http://user:pass@localhost:5984/_cluster_setup

Output (after running commands above, with / request omitted):

{"state":"cluster_enabled"}
{"ok":true}
{"ok":true}
{"error":"unknown_error","reason":"undef","ref":1124911208}
{"state":"cluster_enabled"}

Expected Behaviour

The finish_cluster request should complete and the state should be cluster_finished.

Your Environment

{"couchdb":"Welcome","version":"3.0.0","git_sha":"03a77db6c","uuid":"80f48d682bf369f142e1bb3632cf20bf","features":["access-ready","partitioned","pluggable-storage-engines","reshard","scheduler"],"vendor":{"name":"The Apache Software Foundation"}}

Additional Context

If a request to / is made before finish_cluster, finish_cluster returns response {"ok": true} and setup state becomes cluster_finished.

Edit:
I realised that I've neglected setting the cookie, after observing that nodes won't reconnect after restart.
I've now added command: "-setcookie cookie" to the Dockerfile but the issue is still reproducible.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions