Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected short name and net_adm:localhost() differences #8694

Open
essen opened this issue Jul 30, 2024 · 0 comments
Open

Unexpected short name and net_adm:localhost() differences #8694

essen opened this issue Jul 30, 2024 · 0 comments
Assignees
Labels
bug Issue is reported as a bug help wanted Issue not worked on by OTP; help wanted from the community team:VM Assigned to OTP team VM

Comments

@essen
Copy link
Contributor

essen commented Jul 30, 2024

Describe the bug
The local host name used for the node when -sname is set does not always match what net_adm:localhost() returns, when net_adm:localhost() returns a short name.

To Reproduce
In all cases /etc/hostname contains zen.

1 When /etc/hosts contains:

127.0.0.1       localhost
::1             localhost
127.0.0.1       zen.localdomain zen
::1             zen.localdomain zen

I get

% erl -sname abc
Erlang/OTP 26 [erts-14.1.1] [source] [64-bit] [smp:16:16] [ds:16:16:10] [async-threads:1] [jit:ns]

Eshell V14.1.1 (press Ctrl+G to abort, type help(). for help)
(abc@localhost)1> net_adm:localhost().
"zen"
(abc@localhost)2> 

2 When /etc/hosts contains:

127.0.0.1       zen.localdomain zen
::1             zen.localdomain zen
127.0.0.1       localhost
::1             localhost

I get the correct, but unconvenient:

% erl -sname abc     
Erlang/OTP 26 [erts-14.1.1] [source] [64-bit] [smp:16:16] [ds:16:16:10] [async-threads:1] [jit:ns]

Eshell V14.1.1 (press Ctrl+G to abort, type help(). for help)
(abc@zen)1> net_adm:localhost().
"zen.localdomain"
(abc@zen)2> 

3 When /etc/hosts contains:

127.0.0.1       localhost
::1             localhost
127.0.0.1       zen
::1             zen

I get:

% erl -sname abc
Erlang/OTP 26 [erts-14.1.1] [source] [64-bit] [smp:16:16] [ds:16:16:10] [async-threads:1] [jit:ns]

Eshell V14.1.1 (press Ctrl+G to abort, type help(). for help)
(abc@localhost)1> net_adm:localhost().
"zen"
(abc@localhost)2> 

4 Finally, only in the following case where /etc/hosts contains:

127.0.0.1       zen
::1             zen
127.0.0.1       localhost
::1             localhost

I get the same name in both places:

% erl -sname abc
Erlang/OTP 26 [erts-14.1.1] [source] [64-bit] [smp:16:16] [ds:16:16:10] [async-threads:1] [jit:ns]

Eshell V14.1.1 (press Ctrl+G to abort, type help(). for help)
(abc@zen)1> net_adm:localhost().
"zen"
(abc@zen)2> 

5 Bonus, when /etc/hosts contains:

127.0.0.1       zen zen.localdomain
::1             zen zen.localdomain
127.0.0.1       localhost
::1             localhost

I also get the correct:

% erl -sname abc
Erlang/OTP 26 [erts-14.1.1] [source] [64-bit] [smp:16:16] [ds:16:16:10] [async-threads:1] [jit:ns]

Eshell V14.1.1 (press Ctrl+G to abort, type help(). for help)
(abc@zen)1> net_adm:localhost().
"zen"
(abc@zen)2> 

Expected behavior
I expect -sname to use zen instead of localhost when net_adm:localhost() returns "zen". I expect -sname to use localhost only when net_adm:localhost() also returns "localhost".

I do not necessarily expect the hosts to match when net_adm:localhost() returns "zen.localdomain". That one is understandable since -sname uses a short name. In that case I expect -sname to be set to zen (which it already is as seen in the second snippet). It would be more convenient if net_adm:localhost() would return the same value though, when the short name is also configured and/or reachable.

The local host resolution algorithms should agree when possible.

Affected versions
At least OTP 26 and 27.

Additional context
This breaks slave as that module uses remsh only if the host isn't local and because the hosts don't match it thinks it's not local. I know this module is deprecated.

@essen essen added the bug Issue is reported as a bug label Jul 30, 2024
@IngelaAndin IngelaAndin added team:PS Assigned to OTP team PS team:VM Assigned to OTP team VM and removed team:PS Assigned to OTP team PS labels Aug 5, 2024
@jhogberg jhogberg added the help wanted Issue not worked on by OTP; help wanted from the community label Aug 19, 2024
@jhogberg jhogberg self-assigned this Aug 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue is reported as a bug help wanted Issue not worked on by OTP; help wanted from the community team:VM Assigned to OTP team VM
Projects
None yet
Development

No branches or pull requests

3 participants