Fixed hostname autodetection - resolvable#26037
Draft
dmatej wants to merge 9 commits into
Draft
Conversation
4c1d084 to
2b52bdb
Compare
9a6e663 to
0edb7c3
Compare
- was added in d362b30 Signed-off-by: David Matějček <david.matejcek@omnifish.ee>
Signed-off-by: David Matějček <david.matejcek@omnifish.ee>
Signed-off-by: David Matějček <david.matejcek@omnifish.ee>
- Does not ignore hosts without dots but prefers those which have dots - localhost and loopback is a backup Signed-off-by: David Matějček <david.matejcek@omnifish.ee>
Signed-off-by: David Matějček <david.matejcek@omnifish.ee>
Signed-off-by: David Matějček <david.matejcek@omnifish.ee>
Signed-off-by: David Matějček <david.matejcek@omnifish.ee>
- it is not guaranteed that the local host name is resolvable by DNS - but it should be in nearly all cases we use it Signed-off-by: David Matějček <david.matejcek@omnifish.ee>
Signed-off-by: David Matějček <david.matejcek@omnifish.ee>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
All previous versions were good in some scenarios and wrong in others. In #25972 I assumed that computer's host name is usually resolvable by default, localhost is resolvable always to loopback ip address, however all these assumptions may be wrong.
Unfortunately Java doesn't have any tool to just get the name. On Linux based systems there's the
hostnameprogram - in the past were usedHOSTandHOSTNAMEenvironment options set by shell, however modern Linux versions don't set them any more. On Windows there's theCOMPUTERNAMEenvironment option.If the host name is resolvable on this machine - it doesn't mean it is resolvable from the outside. That means there should be a way user could explicitly set the host name as any internal autodetection doesn't have all information.
Special Situations
I have found the GH Actions is a good reproducer of several scenarios which are OS dependent, shell dependent, DNS dependent, and even dependent on order of actions. I will slowly collect some informations.
runnervm3jyl0runnervm3jyl0.fwbxogqxw2hu1gnhcu514ce0ub.bx.internal.cloudapp.net, localhostrunnervmlu3mhrunnervmlu3mh.jmhn0wqfkjtehmf45kke2dh3lh.bx.internal.cloudapp.net- no localhost here!Why Avoid
getLocalHost().getHostName()?It can cause issues when:
--- end of Claude's citation.
I have found yet another problem in docker - network services sometimes start bit later, so the DNS resolution may change.
We Don't Use the Host Name just for Networking