Skip to content

Conversation

pgj
Copy link
Contributor

@pgj pgj commented May 4, 2025

The --erlang-cookie configuration flag for the dev/run script does not propagate the cookie value for vm.args so that the nodes will not have it configured on starting up. That is why, for example, pinging the Clouseau nodes with user-provided cookie will not work, as well as Clouseau nodes will not be able to connect even though they picked up the right value already.

Add the missing parts to tweak vm.args accordingly and make the Erlang cookie configurable through the Makefile too.

Testing recommendations

There are different ways to see if the change is working. For example, one could launch dev/run directly to start the nodes with a specific Erlang cookie:

% dev/run -a adm:pass -n 1 --erlang-cookie=crumbles
...

Then one should be able to see the cookie configured in dev/lib/node1/etc/vm.args:

% fgrep setcookie dev/lib/node1/etc/vm.args
# -setcookie
-setcookie crumbles

The same could be done with involving Clouseau (assuming that it has been configured):

% dev/run -a adm:pass -n 1 --with-clouseau --erlang-cookie=crumbles
...

Then, besides vm.args being adjusted (as show above), Clouseau should be run with the respective clouseau.cookie parameter:

% ps ax | fgrep clouseau.cookie
91783 s000  S+     0:02.56 /usr/local/openjdk8/bin/java -server -Xmx2G -Dsun.net.inetaddr.ttl=30 -Dsun.net.inetaddr.negative.ttl=30 -XX:OnOutOfMemoryError="kill -9 %p" -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -cp clouseau/lucene-analyzers-kuromoji-4.6.1-cloudant1.jar:clouseau/jetlang-0.2.12.jar:clouseau/commons-logging-1.1.1.jar:clouseau/lucene-analyzers-common-4.6.1-cloudant1.jar:clouseau/metrics-scala_2.9.1-2.2.0.jar:clouseau/lucene-grouping-4.6.1-cloudant1.jar:clouseau/scala-library-2.9.1.jar:clouseau/logback-core-1.2.13.jar:clouseau/clouseau-2.25.0.jar:clouseau/slf4j-api-1.7.2.jar:clouseau/metrics-core-2.2.0.jar:clouseau/lucene-facet-4.6.1-cloudant1.jar:clouseau/lucene-sandbox-4.6.1-cloudant1.jar:clouseau/spatial4j-0.3.jar:clouseau/lucene-spatial-4.6.1-cloudant1.jar:clouseau/lucene-analyzers-stempel-4.6.1-cloudant1.jar:clouseau/lucene-analyzers-smartcn-4.6.1-cloudant1.jar:clouseau/lucene-core-4.6.1-cloudant1.jar:clouseau/lucene-queries-4.6.1-cloudant1.jar:clouseau/lucene-highlighter-4.6.1-cloudant1.jar:clouseau/commons-lang-2.6.jar:clouseau/logback-classic-1.2.13.jar:clouseau/lucene-memory-4.6.1-cloudant1.jar:clouseau/commons-configuration-1.8.jar:clouseau/jakarta-regexp-1.4.jar:clouseau [email protected] -Dclouseau.dir=/Users/gaborpali/projects/github/couchdb/dev/clouseau1/data -Dclouseau.cookie=crumbles com.cloudant.clouseau.Main clouseau/clouseau.ini
93076 s001  S+     0:00.00 fgrep clouseau.cookie

In addition to these, tests should just work with the ERLANG_COOKIE parameter set when running make, for example, with and without Clouseau configured:

% make mango-test ERLANG_COOKIE=crumbles
...
Ran 389 tests in 38.772s

OK (skipped=1)

Copy link
Contributor

@big-r81 big-r81 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Thx! 🙏

@pgj pgj force-pushed the fix/dev/run/complete-erlang-cookie-support branch from 9640cf9 to d023121 Compare May 4, 2025 20:16
@nickva
Copy link
Contributor

nickva commented May 5, 2025

Please hold merging this until we tag the 3.5.0 release

@nickva
Copy link
Contributor

nickva commented May 5, 2025

Thanks for holding! 3.5.0 was tagged and a few release housekeeping PRs merged, main is open again

The `--erlang-cookie` configuration flag for the `dev/run` script
does not propagate the cookie value for `vm.args` so that the
nodes will not have it configured on starting up.  That is why,
for example, pinging the Clouseau nodes with user-provided cookie
will not work, as well as Clouseau nodes will not be able to
connect even though they picked up the right value already.

Add the missing parts to tweak `vm.args` accordingly and make the
Erlang cookie configurable through the `Makefile` too.
@pgj pgj force-pushed the fix/dev/run/complete-erlang-cookie-support branch from d023121 to 13471f2 Compare May 5, 2025 19:08
@pgj pgj merged commit 4608df3 into apache:main May 6, 2025
23 checks passed
@pgj pgj deleted the fix/dev/run/complete-erlang-cookie-support branch May 6, 2025 06:27
jiahuili430 added a commit that referenced this pull request May 12, 2025
We can set cookies using `./dev/run --erlang-cookie=crumbles` or
`vm.args`: `-setcookie crumbles`.

If neither of them is set or we set the cookie in both places, then
the Erlang node will read the cookie from `~/.erlang.cookie`.

Add this mechanism to the `remsh` script to extend its flexibility.

Related PR: #5531
jiahuili430 added a commit that referenced this pull request May 12, 2025
We can set cookies using `./dev/run --erlang-cookie=crumbles` or
`vm.args`: `-setcookie crumbles`.

If neither of them is set or we set the cookie in both places, then
the Erlang node will read the cookie from `~/.erlang.cookie`.

Add this mechanism to the `remsh` script to extend flexibility.

Related PR: #5531
jiahuili430 added a commit that referenced this pull request May 12, 2025
We can set cookies using `./dev/run --erlang-cookie=crumbles` or
`vm.args`: `-setcookie crumbles`.

If neither of them is set or we set the cookie in both places, then
the Erlang node will read the cookie from `~/.erlang.cookie`.

Add this mechanism to the `remsh` script to extend flexibility.

Related PR: #5531
jaydoane pushed a commit to cloudant-labs/clouseau that referenced this pull request Jun 7, 2025
One must be careful with setting the `cookie` value for the
application, because after the naming the JAR file, it expects one
listing the parameters for the application itself.  Hence any
overrides to the configuration must be provided before that.  That
is, in case of the Erlang cookie:

```console
$ java -Dcookie=COOKIE -jar jarfile.jar
```

Also, CouchDB upstream has recently gained full support for passing
around the Erlang cookie [1], so leverage that here too.

[1] apache/couchdb#5531
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants