You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by wi...@apache.org on 2019/12/11 14:58:29 UTC

[couchdb] branch remsh created (now 484200b)

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

willholley pushed a change to branch remsh
in repository https://gitbox.apache.org/repos/asf/couchdb.git.


      at 484200b  Remsh: attempt to auto-locate Erlang cookie

This branch includes the following new commits:

     new dba2df1  Ignore `ERL_FLAGS` in remsh
     new 484200b  Remsh: attempt to auto-locate Erlang cookie

The 2 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.



[couchdb] 01/02: Ignore `ERL_FLAGS` in remsh

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

willholley pushed a commit to branch remsh
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit dba2df164d311524d216809d2caffb089bed7ecd
Author: Will Holley <wi...@gmail.com>
AuthorDate: Wed Dec 11 12:43:41 2019 +0000

    Ignore `ERL_FLAGS` in remsh
    
    If an environment uses `ERL_FLAGS` to configure CouchDB it can
    conflict with the parameters passed to `erl` in `remsh`. This was
    observed in a containerized CouchDB cluster, as the CouchDB
    Dockerfile uses `ERL_FLAGS` to set the node name and cookie, as does
    the Helm chart. When running `remsh` in these containers, additional
    `-name` and `-setcookie` parameters were silently added to
    the `erl` invocation, preventing the shell from connecting to the
    CouchDB node.
---
 rel/overlay/bin/remsh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/rel/overlay/bin/remsh b/rel/overlay/bin/remsh
index 963c16a..a02fd5d 100755
--- a/rel/overlay/bin/remsh
+++ b/rel/overlay/bin/remsh
@@ -71,6 +71,7 @@ if [ ! -z "$VERBOSE" ]; then
   set -x
 fi
 
-exec "$BINDIR/erl" -boot "$ROOTDIR/releases/$APP_VSN/start_clean" \
+# clear ERL_FLAGS to avoid conflicts with the cli parameters
+exec env ERL_FLAGS="" "$BINDIR/erl" -boot "$ROOTDIR/releases/$APP_VSN/start_clean" \
     -name remsh$$@$LHOST -remsh $NODE -hidden -setcookie $COOKIE \
     "$@"


[couchdb] 02/02: Remsh: attempt to auto-locate Erlang cookie

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

willholley pushed a commit to branch remsh
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 484200bf1ce9a76227c6b7622c39a97495d094d2
Author: Will Holley <wi...@gmail.com>
AuthorDate: Wed Dec 11 14:56:27 2019 +0000

    Remsh: attempt to auto-locate Erlang cookie
    
    Attempts to find the Erlang cookie from ERL_FLAGS or the
    standard vm.args location. If not present, fall back to the default
    (monster).
---
 rel/overlay/bin/remsh | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/rel/overlay/bin/remsh b/rel/overlay/bin/remsh
index a02fd5d..2444331 100755
--- a/rel/overlay/bin/remsh
+++ b/rel/overlay/bin/remsh
@@ -23,8 +23,19 @@ BINDIR=$ROOTDIR/erts-$ERTS_VSN/bin
 PROGNAME=${0##*/}
 VERBOSE=""
 NODE="couchdb@127.0.0.1"
-COOKIE=monster
 LHOST=127.0.0.1
+VM_ARGS=$COUCHDB_BIN_DIR/../etc/vm.args
+
+# If present, extract cookie from ERL_FLAGS
+# This is used by the CouchDB Dockerfile and Helm chart
+kCOOKIE_REGEX='setcookie ([^ ]+)'
+if [[ $ERL_FLAGS =~ $kCOOKIE_REGEX ]]; then
+  COOKIE="${BASH_REMATCH[1]}"
+elif test -f $VM_ARGS; then
+# else attempt to extract from vm.args
+  COOKIE=$(awk '$1=="-setcookie"{print $2}' $VM_ARGS)
+fi
+COOKIE="${COOKIE:-monster}"
 
 printHelpAndExit() {
   echo "Usage: ${PROGNAME} [OPTION]... [-- <additional Erlang cli options>]"