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
Log records show the hostname on which the native executable was generated #14423
Comments
This surely must be a regression; I remember testing this way back. Perhaps relating to switching over to smallrye-common for the host name - maybe a substitution is missing now (i.e. pointing at the wrong class)? |
Hello @dmlloyd,
I guess that's indeed the case - this substitution in smallrye-common is targetting the wrong class https://github.com/smallrye/smallrye-common/blob/master/net/src/main/java/io/smallrye/common/net/Substitutions.java#L19 (target class should have been |
I've raised smallrye/smallrye-common#75 with a patch. Having said that, I don't see how that one substitution alone will prevent the computed host name at build time to not be stored for runtime. |
I've opened #14603 with a potential fix. |
Describe the bug
When a native application is using a log pattern that includes the hostname of the machine, then the hostname displayed is the one of the machine on which the native executable has been generated.
Imagine two machines with the following hostname :
build-time-hostname
: the hostname of the computer used to build the native imageruntime-hostname
: the hostname of the machine running the native imageIf the application uses the following log format :
where
%h
should display the hostname, then log statements as shown belowwill output the following:
Expected behavior
I would expect the
runtime-hostname
to be used in the logsActual behavior
JBoss logging system uses org.wildlfy.common.net.Hostname to get a reference on the hostname.
But the references are stored in a static field which is initialized in a static block
At native image build time, the static block is recorded in the image heap and then the same value is used for any subsequent calls during the runtime of the application notably in the log system.
To Reproduce
I have reproduced the issue by modifying the basic quickstart project here : https://github.com/vietk/quarkus-quickstarts/tree/reproducer/build-time-hostname.
I use docker containers in order to have 2 different machine
Steps to reproduce the behavior:
mvn clean install -Pnative -DskipTests
docker run -h runtime-host-name -it --entrypoint=/target/getting-started-1.0-SNAPSHOT-runner -v $PWD/target:/target -p 8080:8080 quay.io/quarkus/ubi-quarkus-native-image:20.2.0-java11
that override the hostname with-h runtime-host-name
http://localhost:8080/hello/greeting/helloworld
Environment (please complete the following information):
Best regards,
Kevin
The text was updated successfully, but these errors were encountered: