cloudant/couchdb-setup

Name: couchdb-setup

Owner: Cloudant

Description: Mirror of Apache CouchDB Setup

Created: 2015-07-03 14:58:25.0

Updated: 2015-07-03 14:58:25.0

Pushed: 2016-03-01 17:54:11.0

Homepage: null

Size: 35

Language: Erlang

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

This module implements /_cluster_setup and manages the setting up, duh, of a CouchDB cluster.

Testing
clone https://git-wip-us.apache.org/repos/asf/couchdb.git
ouchdb
checkout setup
nfigure


 dev/run comment out the line `connect_nodes("127.0.0.1", 15984)`

run --admin a:b

 a new terminal
setup/test/t.sh

The Plan:

N. End User Action

From here on, there are two paths, one is via Fauxton (a) the other is using a HTTP endpoint (b). Fauxton just uses the HTTP endpoint in (b). (b) can be used to set up a cluster programmatically.

2.a. Go to Fauxton. There is a ?Cluster Setup? tab in the sidebar. Go to the tab and get presented with a form that asks you to enter an admin username, admin password and optionally a bind_address and port to bind to publicly. Submit the form with the [Enable Cluster] button.

If this is a single node install that already has an admin set up, there is no need to ask for admin credentials here. If the bind_address is != 127.0.0.1, we can skip this entirely and Fauxton can show the add_node UI right away.

This sets up the admin user on the current node and binds to 0.0.0.0:5984 or the specified ip:port. Logs admin user into Fauxton automatically.

2.b. POST to /_setup as shown above.

Repeat on all nodes.

a. Go to Fauxton / Cluster Setup, once we have enabled the cluster, the UI shows an ?Add Node? interface with the fields admin, and node:

b. as in a, but without the Fauxton bits, just POST to /_setup

4.a. When all nodes are added, click the [Finish Cluster Setup] button in Fauxton.

b. Same as in a.

The Setup Endpoint

This is not a REST-y endpoint, it is a simple state machine operated by HTTP POST with JSON bodies that have an action field.

State 1: No Cluster Enabled

This is right after starting a node for the first time, and any time before the cluster is enabled as outlined above.

/_setup
ate": "cluster_disabled"}

 /_setup {"action":"enable_cluster"...} -> Transition to State 2
 /_setup {"action":"enable_cluster"...} with empty admin user/pass or invalid host/post or host/port not available -> Error
 /_setup {"action":"anything_but_enable_cluster"...} -> Error
State 2: Cluster enabled, admin user set, waiting for nodes to be added.
/_setup
ate":"cluster_enabled","nodes":[]}

 /_setup {"action":"enable_cluster"...} -> Error
 /_setup {"action":"add_node"...} -> Stay in State 2, but return "nodes":["node B"}] on GET
 /_setup {"action":"add_node"...} -> if target node not available, Error
 /_setup {"action":"finish_cluster"} with no nodes set up -> Error
 /_setup {"action":"finish_cluster"} -> Transition to State 3
 /_setup {"action":"delete_node"...} -> Stay in State 2, but delete node from /nodes, reflect the change in GET /_setup
 /_setup {"action":"delete_node","node":"unknown"} -> Error Unknown Node
State 3: Cluster set up, all nodes operational
/_setup
ate":"cluster_finished","nodes":["node a", "node b", ...]}

 /_setup {"action":"enable_cluster"...} -> Error
 /_setup {"action":"finish_cluster"...} -> Stay in State 3, do nothing
 /_setup {"action":"add_node"...} -> Error
 /_setup?i_know_what_i_am_doing=true {"action":"add_node"...} -> Add node, stay in State 3.
 /_setup {"action":"delete_node"...} -> Stay in State 3, but delete node from /nodes, reflect the change in GET /_setup
 /_setup {"action":"delete_node","node":"unknown"} -> Error Unknown Node

// TBD: we need to persist the setup state somewhere.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.