erl_call -q

58 views
Skip to first unread message

Bogdan Andu

unread,
Mar 25, 2022, 5:13:49 AM3/25/22
to Erlang
Hello,

I want to stop a node started with switch -proto_dist inet_tls :
$ /usr/lib/erlang/lib/erl_interface-5.2.1/bin/erl_call -q -c proxy -name 'node-name@host-name'

doesn't kill the node:
$ erl -name node-name@host-name -setcookie proxy -proto_dist inet_tls
Erlang/OTP 24 [erts-12.3] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1]

Eshell V12.3  (abort with ^G)
(node-name@host-name)1> =NOTICE REPORT==== 25-Mar-2022::08:55:56.447550 ===
TLS server: In state hello at tls_record.erl:564 generated SERVER ALERT: Fatal - Unexpected Message
 - {unsupported_record_type,0}

(node-name@host-name)1>

Because the ssl handshake fails the node does not 'catch' the
command to terminate itself.


The execution of command shows the error:
$ /usr/lib/erlang/lib/erl_interface-5.2.1/bin/erl_call -c proxy -name node-name@host-name -a "init stop"
erl_call: failed to connect to node node-name@host-name

Actually the erl_call node connects to 'node-name@host-name'  but is rejected with the same error as above.

Because the erl_call cannot connect to a tls erlang node, erl_call cannot stop suc node.

If the node is started like this:
$ erl -name node-name@host-name -setcookie proxy -proto_dist inet_tcp

erl_call is able to stop it.

Is there a solution to this problem?

Cheers,

Bogdan

Luke Bakken

unread,
Mar 28, 2022, 1:13:40 PM3/28/22
to Bogdan Andu, Erlang
Hello,

I don't believe that erl_call supports the "inet_tls" distribution
protocol - https://www.erlang.org/doc/man/erl_call.html

At least, it's not documented in the manual page.

If I try to connect to a TLS dist node using remsh, but without
specifying certs, I get a function_clause error in
public_key,pkix_decode_cert due to the lack of certificates.

My guess is that, provided that you configure certificates for TLS
distribution, you could accomplish what you want by starting a second
node, connecting the "usual way" via addressing the other node, and
then use the rpc module to stop the node.

Thanks,
Luke

On Fri, Mar 25, 2022 at 2:13 AM Bogdan Andu <bog...@gmail.com> wrote

Bogdan Andu

unread,
Mar 29, 2022, 8:40:33 AM3/29/22
to Luke Bakken, Erlang
Hi,

I tried that before like this:
$ erl -setcookie proxy -proto_dist inet_tls -ssl_dist_optfile file_with_pem -name 'stop-node@host' -s rpc call target-node@host init stop []

Erlang/OTP 24 [erts-12.3] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1]

{"init terminating in do_boot",{undef,[{rpc,call,[['target-node@host',init,stop,'[]']],[]},{init,start_em,1,[]},{init,do_boot,3,[]}]}}
init terminating in do_boot ({undef,[{erpc,call,[[_]],[]},{init,start_em,1,[]},{init,do_boot,3,[]}]})

Crash dump is being written to: erl_crash.dump...done

$

But I looked for an erl_call based solution.

The thing is in that way the signature for rpc:call/4 will never be matched because of the way -s flag
packs the function call and parameters.

Basically, it sends all parameters wrapped into a list, but the signature of rpc:call/4 is this:
rpc:call(Node, Module, Function, Args)
and we get this with -s flag:
rpc:call([Node, Module, Function, Args])

And also the empty list argument needed for rpc:call is wrapped in '' like this: '[]'

Normally, erl_call must be able to talk to tls nodes not only with tcp nodes.

I founded a workaround if you are on elixir node:
$ elixir --name stop-node@host --cookie proxy  --erl "-proto_dist inet_tls" --rpc-eval target-node@host System.stop

Again, it would be nice if erl would have a switch like --rpc-eval

Thanks,

Bogdan

Luke Bakken

unread,
Mar 29, 2022, 8:58:00 AM3/29/22
to Bogdan Andu, Erlang
Give "-eval" a try instead.

Bogdan Andu

unread,
Mar 29, 2022, 9:27:00 AM3/29/22
to Luke Bakken, Erlang
I know erl -eval, but elixir --rpc-eval gives the error also, like this:
--rpc-eval : RPC failed with reason :nodedown
while erl -eval is silent about errors like node down which is very important.

May be a try catch would do the trick but already is too much to pass to eval.

Luke Bakken

unread,
Mar 29, 2022, 9:28:02 AM3/29/22
to Bogdan Andu, Erlang
At this point I would put together a small module, and use -s or -eval
to run the code. erlc is right there!

Bogdan Andu

unread,
Mar 29, 2022, 9:37:34 AM3/29/22
to Luke Bakken, Erlang
But this defeats the purpose of NOT having a dedicated node to run a dedicated module
to just stop nodes. Really? I was expecting this 'solution'.
C'mon man, this is erlang we are talking about!

It could do better than this!



Leo Liu

unread,
Mar 29, 2022, 10:38:46 AM3/29/22
to erlang-q...@erlang.org
On 2022-03-29 16:26 +0300, Bogdan Andu wrote:
> I know erl -eval, but elixir --rpc-eval gives the error also, like this:
> --rpc-eval : RPC failed with reason :nodedown
> while erl -eval is silent about errors like node down which is very
> important.

I was able to get back: {badrpc,nodedown}

erl -name t@host -noinput -eval "io:format(\"~p~n\", [rpc:call('somenode@host', math, sin, [1])]), init:stop()"

If erl_call is based on erl_interface (C-node) then supporting TLS may
be harder because it may have to depend on OpenSSL to handle TLS.

Cheers,
Leo

Bogdan Andu

unread,
Mar 30, 2022, 6:40:35 AM3/30/22
to Erlang
@Leo Liu

> erl -name t@REDACTED -noinput -eval "io:format(\"~p~n\", [rpc:call('somenode@REDACTED', math, sin, [1])]), init:stop()"

Nice hack!

But weird behaviour of -eval. It seems to work only with io:format.
And what is this, undocumented, intimacy between -eval and io:format ?

Isn't suppose -eval to spit out the result of the evaluated block?

Why it needs io:format to do that?

-eval seems to spit out everything io:format throws at it.

io_lib:format/2 is totally ignored, for example.

Rhetorical questions anyway, here. I know -eval will not receive proper love.

Anyway, it helps in my setup.

Thank you!
Bogdan

@erlang-questions mail list:
I didn't receive the mail from Leo Liu in my personal inbox to make a proper reply!
Why is that happening?!?

Leo Liu

unread,
Mar 30, 2022, 7:07:14 AM3/30/22
to erlang-q...@erlang.org
On 2022-03-30 13:40 +0300, Bogdan Andu wrote:
> io_lib:format/2 is totally ignored, for example.

Returning a value has no side-effect thus you see nothing with
io_lib:format. io:format/2 prints to stdout.

> Rhetorical questions anyway, here. I know -eval will not receive
> proper love.

Why not? If you report a bug or feature request they usually get fixed
or implemented.

Leo

Reply all
Reply to author
Forward
0 new messages