You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by wo...@apache.org on 2018/03/26 22:40:49 UTC

[couchdb] branch import-setup-again created (now 423597e)

This is an automated email from the ASF dual-hosted git repository.

wohali pushed a change to branch import-setup-again
in repository https://gitbox.apache.org/repos/asf/couchdb.git.


      at 423597e  Remove couchdb-setup from rebar.config.script

This branch includes the following new commits:

     new 18314a6  Add support for new ensure_dbs_exist option to GET, POST/finish_cluster
     new 92dd9d1  Add new enable_single_node action for cluster_setup endpoint
     new e153d48  address comments from rnewson
     new d61381a  fix typo/compilation error
     new 942c665  chore: whitespace
     new 4b90eca  chore: better log output
     new 4d9bd58  Merge branch '593-setup-single-node' of https://github.com/apache/couchdb-setup
     new 68545af  fix: make sure cluster setups do not exceed n=3 by default
     new 9fd7f44  Merge branch 'fix/node-count' of https://github.com/apache/couchdb-setup
     new e42bf55  couchdb_setup merged in src/setup
     new 423597e  Remove couchdb-setup from rebar.config.script

The 11 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


-- 
To stop receiving notification emails like this one, please contact
wohali@apache.org.

[couchdb] 06/11: chore: better log output

Posted by wo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

wohali pushed a commit to branch import-setup-again
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 4b90eca7ede04abaa72a36e38740cdd9c9b22ebe
Author: Jan Lehnardt <ja...@apache.org>
AuthorDate: Sun Jul 16 17:45:13 2017 +0200

    chore: better log output
---
 src/setup_httpd.erl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/setup_httpd.erl b/src/setup_httpd.erl
index 1f5b7aa..f4e05ce 100644
--- a/src/setup_httpd.erl
+++ b/src/setup_httpd.erl
@@ -94,7 +94,7 @@ handle_action("finish_cluster", Setup) ->
         {error, cluster_finished} ->
             {error, <<"Cluster is already finished">>};
         Else ->
-            couch_log:notice("Else: ~p~n", [Else]),
+            couch_log:notice("finish_cluster: ~p~n", [Else]),
             ok
     end;
 

-- 
To stop receiving notification emails like this one, please contact
wohali@apache.org.

[couchdb] 09/11: Merge branch 'fix/node-count' of https://github.com/apache/couchdb-setup

Posted by wo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

wohali pushed a commit to branch import-setup-again
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 9fd7f448065b4eb29910c9e14d1ac89af589e3c1
Merge: 4d9bd58 68545af
Author: Joan Touzet <jo...@atypical.net>
AuthorDate: Sun Jul 30 17:15:08 2017 -0400

    Merge branch 'fix/node-count' of https://github.com/apache/couchdb-setup

 src/setup.erl | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

-- 
To stop receiving notification emails like this one, please contact
wohali@apache.org.

[couchdb] 02/11: Add new enable_single_node action for cluster_setup endpoint

Posted by wo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

wohali pushed a commit to branch import-setup-again
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 92dd9d10b6d3f94bf3295fd85bcc0375e8298828
Author: Joan Touzet <wo...@apache.org>
AuthorDate: Mon Jul 10 16:31:17 2017 -0700

    Add new enable_single_node action for cluster_setup endpoint
---
 README.md             | 17 +++++++++------
 src/setup.erl         | 60 ++++++++++++++++++++++++++++++++++++++++++---------
 src/setup_httpd.erl   | 41 ++++++++++++++++++++++++++++++-----
 test/t-single-node.sh | 46 +++++++++++++++++++++++++++++++++++++++
 4 files changed, 143 insertions(+), 21 deletions(-)

diff --git a/README.md b/README.md
index a6c6d18..e30c400 100644
--- a/README.md
+++ b/README.md
@@ -2,21 +2,26 @@ This module implements /_cluster_setup and manages the setting up, duh, of a Cou
 
 ### Testing
 
-```
+```bash
 git clone https://git-wip-us.apache.org/repos/asf/couchdb.git
 cd couchdb
 git checkout setup
 ./configure
 make
+dev/run --no-join -n 2 --admin a:b
+```
 
-# in dev/run comment out the line `connect_nodes("127.0.0.1", 15984)`
+Then, in a new terminal:
 
-dev/run --admin a:b
+    $ src/setup/test/t.sh
 
-# in a new terminal
-src/setup/test/t.sh
+Before running each test, kill the `dev/run` script, then reset the
+CouchDB instances with:
 
-```
+    $ rm -rf dev/lib/ dev/logs/
+    $ dev/run --no-join -n 2 --admin a:b
+
+before running the next shell script.
 
 The Plan:
 
diff --git a/src/setup.erl b/src/setup.erl
index dd7410a..7aeac3e 100644
--- a/src/setup.erl
+++ b/src/setup.erl
@@ -14,6 +14,7 @@
 
 -export([enable_cluster/1, finish_cluster/1, add_node/1, receive_cookie/1]).
 -export([is_cluster_enabled/0, has_cluster_system_dbs/1, cluster_system_dbs/0]).
+-export([enable_single_node/1, is_single_node_enabled/1]).
 
 -include_lib("../couch/include/couch_db.hrl").
 
@@ -49,6 +50,15 @@ is_cluster_enabled() ->
         {_,_} -> ok
     end.
 
+is_single_node_enabled(Dbs) ->
+    % admins != empty AND dbs exist
+    Admins = config:get("admins"),
+    HasDbs = has_cluster_system_dbs(Dbs),
+    case {Admins, HasDbs} of
+        {[], _} -> no;
+        {_, no} -> no;
+        {_,_} -> ok
+    end.
 
 cluster_system_dbs() ->
     ["_users", "_replicator", "_global_changes"].
@@ -129,18 +139,27 @@ enable_cluster_int(Options, no) ->
           Pw -> Pw
         end
     },
+    ok = require_admins(CurrentAdmins, NewCredentials),
 
     % if bind_address == 127.0.0.1 and no bind_address in req -> error
     CurrentBindAddress = config:get("chttpd","bind_address"),
     NewBindAddress = proplists:get_value(bind_address, Options),
-    ok = require_admins(CurrentAdmins, NewCredentials),
     ok = require_bind_address(CurrentBindAddress, NewBindAddress),
 
+    NodeCount = couch_util:get_value(node_count, Options),
+    ok = require_node_count(NodeCount),
+
+    Port = proplists:get_value(port, Options),
+
+    setup_node(NewCredentials, NewBindAddress, NodeCount, Port),
+    couch_log:notice("Enable Cluster: ~p~n", [Options]).
+
+setup_node(NewCredentials, NewBindAddress, NodeCount, Port) ->
     case NewCredentials of
         {undefined, undefined} ->
             ok;
         {Username, Password} ->
-            set_admin(Username, Password)
+            config:set("admins", binary_to_list(Username), binary_to_list(Password))
     end,
 
     case NewBindAddress of
@@ -150,11 +169,8 @@ enable_cluster_int(Options, no) ->
             config:set("chttpd", "bind_address", binary_to_list(NewBindAddress))
     end,
 
-    NodeCount = couch_util:get_value(node_count, Options),
-    ok = require_node_count(NodeCount),
     config:set_integer("cluster", "n", NodeCount),
 
-    Port = proplists:get_value(port, Options),
     case Port of
         undefined ->
             ok;
@@ -162,11 +178,7 @@ enable_cluster_int(Options, no) ->
             config:set("chttpd", "port", binary_to_list(Port));
         Port when is_integer(Port) ->
             config:set_integer("chttpd", "port", Port)
-    end,
-    couch_log:notice("Enable Cluster: ~p~n", [Options]).
-
-set_admin(Username, Password) ->
-  config:set("admins", binary_to_list(Username), binary_to_list(Password)).
+    end.
 
 
 finish_cluster(Options) ->
@@ -184,6 +196,34 @@ finish_cluster_int(Dbs, no) ->
     lists:foreach(fun fabric:create_db/1, Dbs).
 
 
+enable_single_node(Options) ->
+    % if no admin in config and no admin in req -> error
+    CurrentAdmins = config:get("admins"),
+    NewCredentials = {
+        proplists:get_value(username, Options),
+        case proplists:get_value(password_hash, Options) of
+          undefined -> proplists:get_value(password, Options);
+          Pw -> Pw
+        end
+    },
+    ok = require_admins(CurrentAdmins, NewCredentials),
+
+    % skip bind_address validation, anything is fine
+    NewBindAddress = proplists:get_value(bind_address, Options),
+
+    Port = proplists:get_value(port, Options),
+
+    setup_node(NewCredentials, NewBindAddress, 1, Port),
+    Dbs = proplists:get_value(ensure_dbs_exist, Options),
+    case Dbs of
+        undefined ->
+            finish_cluster_int(cluster_system_dbs(), has_cluster_system_dbs(cluster_system_dbs()));
+        Dbs ->
+            finish_cluster_int(Dbs, has_cluster_system_dbs(Dbs))
+    end,
+    couch_log:notice("Enable Single Node: ~p~n", [Options]).
+
+
 add_node(Options) ->
     add_node_int(Options, is_cluster_enabled()).
 
diff --git a/src/setup_httpd.erl b/src/setup_httpd.erl
index 59ed5c7..a5a8157 100644
--- a/src/setup_httpd.erl
+++ b/src/setup_httpd.erl
@@ -30,16 +30,27 @@ handle_setup_req(#httpd{method='POST'}=Req) ->
 handle_setup_req(#httpd{method='GET'}=Req) ->
     ok = chttpd:verify_is_server_admin(Req),
     Dbs = chttpd:qs_json_value(Req, "ensure_dbs_exist", setup:cluster_system_dbs()),
-    case setup:is_cluster_enabled() of
+    couch_log:notice("Dbs: ~p~n", [Dbs]),
+    case erlang:list_to_integer(config:get("cluster", "n", undefined)) of
+    1 ->
+        case setup:is_single_node_enabled(Dbs) of
+        no ->
+            chttpd:send_json(Req, 200, {[{state, single_node_disabled}]});
+        ok ->
+            chttpd:send_json(Req, 200, {[{state, single_node_enabled}]})
+        end;
+    _ -> 
+        case setup:is_cluster_enabled() of
         no ->
             chttpd:send_json(Req, 200, {[{state, cluster_disabled}]});
         ok ->
             case setup:has_cluster_system_dbs(Dbs) of
-                no ->
-                    chttpd:send_json(Req, 200, {[{state, cluster_enabled}]});
-                ok ->
-                    chttpd:send_json(Req, 200, {[{state, cluster_finished}]})
+            no ->
+                chttpd:send_json(Req, 200, {[{state, cluster_enabled}]});
+            ok ->
+                chttpd:send_json(Req, 200, {[{state, cluster_finished}]})
             end
+        end
     end;
 handle_setup_req(#httpd{}=Req) ->
     chttpd:send_method_not_allowed(Req, "GET,POST").
@@ -87,6 +98,26 @@ handle_action("finish_cluster", Setup) ->
             ok
     end;
 
+handle_action("enable_single_node", Setup) ->
+    couch_log:notice("enable_single_node: ~p~n", [Setup]),
+
+    Options = get_options([
+        {ensure_dbs_exist, <<"ensure_dbs_exist">>},
+        {username, <<"username">>},
+        {password, <<"password">>},
+        {password_hash, <<"password_hash">>},
+        {bind_address, <<"bind_address">>},
+        {port, <<"port">>}
+    ], Setup),
+    case setup:enable_single_node(Options) of
+        {error, cluster_finished} ->
+            {error, <<"Cluster is already finished">>};
+        Else ->
+            couch_log:notice("Else: ~p~n", [Else]),
+            ok
+    end;
+
+
 handle_action("add_node", Setup) ->
     couch_log:notice("add_node: ~p~n", [Setup]),
 
diff --git a/test/t-single-node.sh b/test/t-single-node.sh
new file mode 100755
index 0000000..d490437
--- /dev/null
+++ b/test/t-single-node.sh
@@ -0,0 +1,46 @@
+#!/bin/sh -ex
+# Licensed under the Apache License, Version 2.0 (the "License"); you may not
+# use this file except in compliance with the License. You may obtain a copy of
+# the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations under
+# the License.
+
+HEADERS="-HContent-Type:application/json"
+# show cluster state:
+curl a:b@127.0.0.1:15986/_nodes/_all_docs
+curl a:b@127.0.0.1:15984/_cluster_setup
+
+# Enable Cluster on single node
+curl a:b@127.0.0.1:15984/_cluster_setup -d '{"action":"enable_single_node","username":"foo","password":"baz","bind_address":"127.0.0.1"}' $HEADERS
+
+# Show cluster state:
+curl a:b@127.0.0.1:15986/_nodes/_all_docs
+curl a:b@127.0.0.1:15984/_all_dbs
+curl a:b@127.0.0.1:15984/_cluster_setup
+
+# Delete a database
+curl -X DELETE a:b@127.0.0.1:15984/_global_changes
+
+# Should show single_node_disabled
+curl a:b@127.0.0.1:15984/_cluster_setup
+
+# Change the check
+curl -g 'a:b@127.0.0.1:15984/_cluster_setup?ensure_dbs_exist=["_replicator","_users"]'
+
+# delete all the things
+curl -X DELETE a:b@127.0.0.1:15984/_replicator
+curl -X DELETE a:b@127.0.0.1:15984/_users
+
+# setup only creating _users
+curl -g a:b@127.0.0.1:15984/_cluster_setup -d '{"action":"enable_single_node","username":"foo","password":"baz","bind_address":"127.0.0.1","ensure_dbs_exist":["_users"]}' $HEADERS
+
+# check it
+curl -g 'a:b@127.0.0.1:15984/_cluster_setup?ensure_dbs_exist=["_users"]'
+
+echo "YAY ALL GOOD"

-- 
To stop receiving notification emails like this one, please contact
wohali@apache.org.

[couchdb] 08/11: fix: make sure cluster setups do not exceed n=3 by default

Posted by wo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

wohali pushed a commit to branch import-setup-again
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 68545afed1000d69cdebbe36c4b7962e6305473b
Author: Jan Lehnardt <ja...@apache.org>
AuthorDate: Sun Jul 30 10:07:46 2017 +0200

    fix: make sure cluster setups do not exceed n=3 by default
    
    Single node setups want an n=1 setting, but that is the only
    time the number of nodes and the number of replicas is linked.
    
    In larger clusters, the values should not be the same. This
    patch ensures that for clusters >3 nodes, we do not have to
    tell the users to set node_count to 3 in the _cluster_setup
    API.
    
    More context for this in https://issues.apache.org/jira/browse/COUCHDB-2594
---
 src/setup.erl | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/setup.erl b/src/setup.erl
index d0ecd2c..9433186 100644
--- a/src/setup.erl
+++ b/src/setup.erl
@@ -169,7 +169,9 @@ setup_node(NewCredentials, NewBindAddress, NodeCount, Port) ->
             config:set("chttpd", "bind_address", binary_to_list(NewBindAddress))
     end,
 
-    config:set_integer("cluster", "n", NodeCount),
+    % for single node setups, set n=1, for larger setups, don’t
+    % exceed n=3 as a default
+    config:set_integer("cluster", "n", min(NodeCount, 3)),
 
     case Port of
         undefined ->

-- 
To stop receiving notification emails like this one, please contact
wohali@apache.org.

[couchdb] 01/11: Add support for new ensure_dbs_exist option to GET, POST/finish_cluster

Posted by wo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

wohali pushed a commit to branch import-setup-again
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 18314a6daa56a13f4b4e6f71ce61224a8940f925
Author: Joan Touzet <wo...@apache.org>
AuthorDate: Mon Jul 10 13:52:45 2017 -0700

    Add support for new ensure_dbs_exist option to GET, POST/finish_cluster
    
    Addresses apache/couchdb:593
---
 .gitignore          |  2 ++
 src/setup.erl       | 24 ++++++++++++++----------
 src/setup_httpd.erl |  9 +++++++--
 3 files changed, 23 insertions(+), 12 deletions(-)

diff --git a/.gitignore b/.gitignore
index 1dbfa4b..f84f14c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,4 @@
 ebin
 .rebar
+*~
+*.swp
diff --git a/src/setup.erl b/src/setup.erl
index 5a71004..dd7410a 100644
--- a/src/setup.erl
+++ b/src/setup.erl
@@ -12,8 +12,8 @@
 
 -module(setup).
 
--export([enable_cluster/1, finish_cluster/0, add_node/1, receive_cookie/1]).
--export([is_cluster_enabled/0, has_cluster_system_dbs/0]).
+-export([enable_cluster/1, finish_cluster/1, add_node/1, receive_cookie/1]).
+-export([is_cluster_enabled/0, has_cluster_system_dbs/1, cluster_system_dbs/0]).
 
 -include_lib("../couch/include/couch_db.hrl").
 
@@ -54,9 +54,6 @@ cluster_system_dbs() ->
     ["_users", "_replicator", "_global_changes"].
 
 
-has_cluster_system_dbs() ->
-    has_cluster_system_dbs(cluster_system_dbs()).
-
 has_cluster_system_dbs([]) ->
     ok;
 has_cluster_system_dbs([Db|Dbs]) ->
@@ -172,12 +169,19 @@ set_admin(Username, Password) ->
   config:set("admins", binary_to_list(Username), binary_to_list(Password)).
 
 
-finish_cluster() ->
-    finish_cluster_int(has_cluster_system_dbs()).
-finish_cluster_int(ok) ->
+finish_cluster(Options) ->
+    Dbs = proplists:get_value(ensure_dbs_exist, Options),
+    case Dbs of
+        undefined ->
+            finish_cluster_int(cluster_system_dbs(), has_cluster_system_dbs(cluster_system_dbs()));
+        Dbs ->
+            finish_cluster_int(Dbs, has_cluster_system_dbs(Dbs))
+    end.
+
+finish_cluster_int(_Dbs, ok) ->
     {error, cluster_finished};
-finish_cluster_int(no) ->
-    lists:foreach(fun fabric:create_db/1, cluster_system_dbs()).
+finish_cluster_int(Dbs, no) ->
+    lists:foreach(fun fabric:create_db/1, Dbs).
 
 
 add_node(Options) ->
diff --git a/src/setup_httpd.erl b/src/setup_httpd.erl
index a23a3e2..59ed5c7 100644
--- a/src/setup_httpd.erl
+++ b/src/setup_httpd.erl
@@ -29,11 +29,12 @@ handle_setup_req(#httpd{method='POST'}=Req) ->
     end;
 handle_setup_req(#httpd{method='GET'}=Req) ->
     ok = chttpd:verify_is_server_admin(Req),
+    Dbs = chttpd:qs_json_value(Req, "ensure_dbs_exist", setup:cluster_system_dbs()),
     case setup:is_cluster_enabled() of
         no ->
             chttpd:send_json(Req, 200, {[{state, cluster_disabled}]});
         ok ->
-            case setup:has_cluster_system_dbs() of
+            case setup:has_cluster_system_dbs(Dbs) of
                 no ->
                     chttpd:send_json(Req, 200, {[{state, cluster_enabled}]});
                 ok ->
@@ -74,7 +75,11 @@ handle_action("enable_cluster", Setup) ->
 
 handle_action("finish_cluster", Setup) ->
     couch_log:notice("finish_cluster: ~p~n", [Setup]),
-    case setup:finish_cluster() of
+
+    Options = get_options([
+        {ensure_dbs_exist, <<"ensure_dbs_exist">>}
+    ], Setup),
+    case setup:finish_cluster(Options) of
         {error, cluster_finished} ->
             {error, <<"Cluster is already finished">>};
         Else ->

-- 
To stop receiving notification emails like this one, please contact
wohali@apache.org.

[couchdb] 04/11: fix typo/compilation error

Posted by wo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

wohali pushed a commit to branch import-setup-again
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit d61381a094a7f67ea688c58edacb3b204babcaa9
Author: Jan Lehnardt <ja...@apache.org>
AuthorDate: Sun Jul 16 17:24:55 2017 +0200

    fix typo/compilation error
---
 src/setup.erl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/setup.erl b/src/setup.erl
index 0d17109..d0ecd2c 100644
--- a/src/setup.erl
+++ b/src/setup.erl
@@ -208,7 +208,7 @@ enable_single_node(Options) ->
 
     setup_node(NewCredentials, NewBindAddress, 1, Port),
     Dbs = proplists:get_value(ensure_dbs_exist, Options, cluster_system_dbs()),
-    finish_cluster_int(Dbs, has_cluster_system_dbs(Dbs))
+    finish_cluster_int(Dbs, has_cluster_system_dbs(Dbs)),
     couch_log:notice("Enable Single Node: ~p~n", [Options]).
 
 

-- 
To stop receiving notification emails like this one, please contact
wohali@apache.org.

[couchdb] 10/11: couchdb_setup merged in src/setup

Posted by wo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

wohali pushed a commit to branch import-setup-again
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit e42bf55014a2bb5168d6d49e1f5ec7a93ef44086
Merge: e7c48b3 9fd7f44
Author: Joan Touzet <jo...@atypical.net>
AuthorDate: Mon Mar 26 18:38:04 2018 -0400

    couchdb_setup merged in src/setup

 src/setup/.gitignore                   |   4 +
 src/setup/LICENSE                      | 203 +++++++++++++++++++++++
 src/setup/README.md                    | 193 ++++++++++++++++++++++
 src/setup/src/setup.app.src            |  27 +++
 src/setup/src/setup.erl                | 289 +++++++++++++++++++++++++++++++++
 src/setup/src/setup_app.erl            |  28 ++++
 src/setup/src/setup_epi.erl            |  49 ++++++
 src/setup/src/setup_httpd.erl          | 169 +++++++++++++++++++
 src/setup/src/setup_httpd_handlers.erl |  22 +++
 src/setup/src/setup_sup.erl            |  38 +++++
 src/setup/test/t-frontend-setup.sh     |  63 +++++++
 src/setup/test/t-single-node.sh        |  46 ++++++
 src/setup/test/t.sh                    |  63 +++++++
 13 files changed, 1194 insertions(+)

diff --cc src/setup/.gitignore
index 0000000,f84f14c..f84f14c
mode 000000,100644..100644
--- a/src/setup/.gitignore
+++ b/src/setup/.gitignore
diff --cc src/setup/LICENSE
index 0000000,94ad231..94ad231
mode 000000,100644..100644
--- a/src/setup/LICENSE
+++ b/src/setup/LICENSE
diff --cc src/setup/README.md
index 0000000,e30c400..e30c400
mode 000000,100644..100644
--- a/src/setup/README.md
+++ b/src/setup/README.md
diff --cc src/setup/src/setup.app.src
index 0000000,ae685c9..ae685c9
mode 000000,100644..100644
--- a/src/setup/src/setup.app.src
+++ b/src/setup/src/setup.app.src
diff --cc src/setup/src/setup.erl
index 0000000,9433186..9433186
mode 000000,100644..100644
--- a/src/setup/src/setup.erl
+++ b/src/setup/src/setup.erl
diff --cc src/setup/src/setup_app.erl
index 0000000,3304501..3304501
mode 000000,100644..100644
--- a/src/setup/src/setup_app.erl
+++ b/src/setup/src/setup_app.erl
diff --cc src/setup/src/setup_epi.erl
index 0000000,c3f2636..c3f2636
mode 000000,100644..100644
--- a/src/setup/src/setup_epi.erl
+++ b/src/setup/src/setup_epi.erl
diff --cc src/setup/src/setup_httpd.erl
index 0000000,f4e05ce..f4e05ce
mode 000000,100644..100644
--- a/src/setup/src/setup_httpd.erl
+++ b/src/setup/src/setup_httpd.erl
diff --cc src/setup/src/setup_httpd_handlers.erl
index 0000000,994c217..994c217
mode 000000,100644..100644
--- a/src/setup/src/setup_httpd_handlers.erl
+++ b/src/setup/src/setup_httpd_handlers.erl
diff --cc src/setup/src/setup_sup.erl
index 0000000,b81aa3a..b81aa3a
mode 000000,100644..100644
--- a/src/setup/src/setup_sup.erl
+++ b/src/setup/src/setup_sup.erl
diff --cc src/setup/test/t-frontend-setup.sh
index 0000000,52056a3..52056a3
mode 000000,100755..100755
--- a/src/setup/test/t-frontend-setup.sh
+++ b/src/setup/test/t-frontend-setup.sh
diff --cc src/setup/test/t-single-node.sh
index 0000000,d490437..d490437
mode 000000,100755..100755
--- a/src/setup/test/t-single-node.sh
+++ b/src/setup/test/t-single-node.sh
diff --cc src/setup/test/t.sh
index 0000000,6bd74cd..6bd74cd
mode 000000,100755..100755
--- a/src/setup/test/t.sh
+++ b/src/setup/test/t.sh

-- 
To stop receiving notification emails like this one, please contact
wohali@apache.org.

[couchdb] 03/11: address comments from rnewson

Posted by wo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

wohali pushed a commit to branch import-setup-again
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit e153d485b6b195054c87bbfcca1c2a5f54d979eb
Author: Joan Touzet <wo...@apache.org>
AuthorDate: Tue Jul 11 16:04:46 2017 -0700

    address comments from rnewson
---
 src/setup.erl       | 56 +++++++++++++++++++++--------------------------------
 src/setup_httpd.erl | 36 +++++++++++++++++-----------------
 2 files changed, 40 insertions(+), 52 deletions(-)

diff --git a/src/setup.erl b/src/setup.erl
index 7aeac3e..0d17109 100644
--- a/src/setup.erl
+++ b/src/setup.erl
@@ -45,9 +45,9 @@ is_cluster_enabled() ->
     BindAddress = config:get("chttpd", "bind_address"),
     Admins = config:get("admins"),
     case {BindAddress, Admins} of
-        {"127.0.0.1", _} -> no;
-        {_,[]} -> no;
-        {_,_} -> ok
+        {"127.0.0.1", _} -> false;
+        {_,[]} -> false;
+        {_,_} -> true
     end.
 
 is_single_node_enabled(Dbs) ->
@@ -55,9 +55,9 @@ is_single_node_enabled(Dbs) ->
     Admins = config:get("admins"),
     HasDbs = has_cluster_system_dbs(Dbs),
     case {Admins, HasDbs} of
-        {[], _} -> no;
-        {_, no} -> no;
-        {_,_} -> ok
+        {[], _} -> false;
+        {_, false} -> false;
+        {_,_} -> true
     end.
 
 cluster_system_dbs() ->
@@ -65,11 +65,11 @@ cluster_system_dbs() ->
 
 
 has_cluster_system_dbs([]) ->
-    ok;
+    true;
 has_cluster_system_dbs([Db|Dbs]) ->
     case catch fabric:get_db_info(Db) of
         {ok, _} -> has_cluster_system_dbs(Dbs);
-        _ -> no
+        _ -> false
     end.
 
 enable_cluster(Options) ->
@@ -126,9 +126,9 @@ enable_cluster_http(Options) ->
             {error, Else}
     end.
 
-enable_cluster_int(_Options, ok) ->
+enable_cluster_int(_Options, true) ->
     {error, cluster_enabled};
-enable_cluster_int(Options, no) ->
+enable_cluster_int(Options, false) ->
 
     % if no admin in config and no admin in req -> error
     CurrentAdmins = config:get("admins"),
@@ -140,26 +140,26 @@ enable_cluster_int(Options, no) ->
         end
     },
     ok = require_admins(CurrentAdmins, NewCredentials),
-
     % if bind_address == 127.0.0.1 and no bind_address in req -> error
     CurrentBindAddress = config:get("chttpd","bind_address"),
     NewBindAddress = proplists:get_value(bind_address, Options),
     ok = require_bind_address(CurrentBindAddress, NewBindAddress),
-
     NodeCount = couch_util:get_value(node_count, Options),
     ok = require_node_count(NodeCount),
-
     Port = proplists:get_value(port, Options),
 
     setup_node(NewCredentials, NewBindAddress, NodeCount, Port),
     couch_log:notice("Enable Cluster: ~p~n", [Options]).
 
+set_admin(Username, Password) ->
+    config:set("admins", binary_to_list(Username), binary_to_list(Password)).
+
 setup_node(NewCredentials, NewBindAddress, NodeCount, Port) ->
     case NewCredentials of
         {undefined, undefined} ->
             ok;
         {Username, Password} ->
-            config:set("admins", binary_to_list(Username), binary_to_list(Password))
+            set_admin(Username, Password)
     end,
 
     case NewBindAddress of
@@ -182,17 +182,12 @@ setup_node(NewCredentials, NewBindAddress, NodeCount, Port) ->
 
 
 finish_cluster(Options) ->
-    Dbs = proplists:get_value(ensure_dbs_exist, Options),
-    case Dbs of
-        undefined ->
-            finish_cluster_int(cluster_system_dbs(), has_cluster_system_dbs(cluster_system_dbs()));
-        Dbs ->
-            finish_cluster_int(Dbs, has_cluster_system_dbs(Dbs))
-    end.
+    Dbs = proplists:get_value(ensure_dbs_exist, Options, cluster_system_dbs()),
+    finish_cluster_int(Dbs, has_cluster_system_dbs(Dbs)).
 
-finish_cluster_int(_Dbs, ok) ->
+finish_cluster_int(_Dbs, true) ->
     {error, cluster_finished};
-finish_cluster_int(Dbs, no) ->
+finish_cluster_int(Dbs, false) ->
     lists:foreach(fun fabric:create_db/1, Dbs).
 
 
@@ -207,29 +202,22 @@ enable_single_node(Options) ->
         end
     },
     ok = require_admins(CurrentAdmins, NewCredentials),
-
     % skip bind_address validation, anything is fine
     NewBindAddress = proplists:get_value(bind_address, Options),
-
     Port = proplists:get_value(port, Options),
 
     setup_node(NewCredentials, NewBindAddress, 1, Port),
-    Dbs = proplists:get_value(ensure_dbs_exist, Options),
-    case Dbs of
-        undefined ->
-            finish_cluster_int(cluster_system_dbs(), has_cluster_system_dbs(cluster_system_dbs()));
-        Dbs ->
-            finish_cluster_int(Dbs, has_cluster_system_dbs(Dbs))
-    end,
+    Dbs = proplists:get_value(ensure_dbs_exist, Options, cluster_system_dbs()),
+    finish_cluster_int(Dbs, has_cluster_system_dbs(Dbs))
     couch_log:notice("Enable Single Node: ~p~n", [Options]).
 
 
 add_node(Options) ->
     add_node_int(Options, is_cluster_enabled()).
 
-add_node_int(_Options, no) ->
+add_node_int(_Options, false) ->
     {error, cluster_not_enabled};
-add_node_int(Options, ok) ->
+add_node_int(Options, true) ->
     couch_log:notice("add node_int: ~p~n", [Options]),
     ErlangCookie = erlang:get_cookie(),
 
diff --git a/src/setup_httpd.erl b/src/setup_httpd.erl
index a5a8157..a9cbfe8 100644
--- a/src/setup_httpd.erl
+++ b/src/setup_httpd.erl
@@ -32,25 +32,25 @@ handle_setup_req(#httpd{method='GET'}=Req) ->
     Dbs = chttpd:qs_json_value(Req, "ensure_dbs_exist", setup:cluster_system_dbs()),
     couch_log:notice("Dbs: ~p~n", [Dbs]),
     case erlang:list_to_integer(config:get("cluster", "n", undefined)) of
-    1 ->
-        case setup:is_single_node_enabled(Dbs) of
-        no ->
-            chttpd:send_json(Req, 200, {[{state, single_node_disabled}]});
-        ok ->
-            chttpd:send_json(Req, 200, {[{state, single_node_enabled}]})
-        end;
-    _ -> 
-        case setup:is_cluster_enabled() of
-        no ->
-            chttpd:send_json(Req, 200, {[{state, cluster_disabled}]});
-        ok ->
-            case setup:has_cluster_system_dbs(Dbs) of
-            no ->
-                chttpd:send_json(Req, 200, {[{state, cluster_enabled}]});
-            ok ->
-                chttpd:send_json(Req, 200, {[{state, cluster_finished}]})
+        1 ->
+            case setup:is_single_node_enabled(Dbs) of
+                false ->
+                    chttpd:send_json(Req, 200, {[{state, single_node_disabled}]});
+                true ->
+                    chttpd:send_json(Req, 200, {[{state, single_node_enabled}]})
+            end;
+        _ -> 
+            case setup:is_cluster_enabled() of
+                false ->
+                    chttpd:send_json(Req, 200, {[{state, cluster_disabled}]});
+                true ->
+                    case setup:has_cluster_system_dbs(Dbs) of
+                        false ->
+                            chttpd:send_json(Req, 200, {[{state, cluster_enabled}]});
+                        true ->
+                            chttpd:send_json(Req, 200, {[{state, cluster_finished}]})
+                    end
             end
-        end
     end;
 handle_setup_req(#httpd{}=Req) ->
     chttpd:send_method_not_allowed(Req, "GET,POST").

-- 
To stop receiving notification emails like this one, please contact
wohali@apache.org.

[couchdb] 11/11: Remove couchdb-setup from rebar.config.script

Posted by wo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

wohali pushed a commit to branch import-setup-again
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 423597ea31ceb83f75d3cde01dd040b13bd08861
Author: Joan Touzet <jo...@atypical.net>
AuthorDate: Mon Mar 26 18:40:39 2018 -0400

    Remove couchdb-setup from rebar.config.script
---
 rebar.config.script | 1 -
 1 file changed, 1 deletion(-)

diff --git a/rebar.config.script b/rebar.config.script
index 4f6f82d..e97e458 100644
--- a/rebar.config.script
+++ b/rebar.config.script
@@ -51,7 +51,6 @@ DepDescs = [
 {ets_lru,          "ets-lru",          {tag, "1.0.0"}},
 {khash,            "khash",            {tag, "1.0.1"}},
 {snappy,           "snappy",           {tag, "CouchDB-1.0.0"}},
-{setup,            "setup",            {tag, "1.0.1"}},
 {ioq,              "ioq",              {tag, "1.0.1"}},
 
 %% Non-Erlang deps

-- 
To stop receiving notification emails like this one, please contact
wohali@apache.org.

[couchdb] 05/11: chore: whitespace

Posted by wo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

wohali pushed a commit to branch import-setup-again
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 942c665c6e44c4f954a77d72a59aac856f20a6f3
Author: Jan Lehnardt <ja...@apache.org>
AuthorDate: Sun Jul 16 17:44:51 2017 +0200

    chore: whitespace
---
 src/setup_httpd.erl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/setup_httpd.erl b/src/setup_httpd.erl
index a9cbfe8..1f5b7aa 100644
--- a/src/setup_httpd.erl
+++ b/src/setup_httpd.erl
@@ -39,7 +39,7 @@ handle_setup_req(#httpd{method='GET'}=Req) ->
                 true ->
                     chttpd:send_json(Req, 200, {[{state, single_node_enabled}]})
             end;
-        _ -> 
+        _ ->
             case setup:is_cluster_enabled() of
                 false ->
                     chttpd:send_json(Req, 200, {[{state, cluster_disabled}]});

-- 
To stop receiving notification emails like this one, please contact
wohali@apache.org.

[couchdb] 07/11: Merge branch '593-setup-single-node' of https://github.com/apache/couchdb-setup

Posted by wo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

wohali pushed a commit to branch import-setup-again
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 4d9bd589fe68d6108021ef8417f3e5d91e4d113e
Merge: c38d7aa 4b90eca
Author: Joan Touzet <jo...@atypical.net>
AuthorDate: Sun Jul 16 12:32:41 2017 -0400

    Merge branch '593-setup-single-node' of https://github.com/apache/couchdb-setup

 .gitignore            |  2 ++
 README.md             | 17 ++++++----
 src/setup.erl         | 88 +++++++++++++++++++++++++++++++++++----------------
 src/setup_httpd.erl   | 56 ++++++++++++++++++++++++++------
 test/t-single-node.sh | 46 +++++++++++++++++++++++++++
 5 files changed, 165 insertions(+), 44 deletions(-)

-- 
To stop receiving notification emails like this one, please contact
wohali@apache.org.