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

UnknownHostException #314

Open
hram opened this issue Oct 28, 2021 · 1 comment
Open

UnknownHostException #314

hram opened this issue Oct 28, 2021 · 1 comment

Comments

@hram
Copy link

hram commented Oct 28, 2021

My build failed with an exceptont:
Caused by: java.net.UnknownHostException: teamcity-new: teamcity-new: Name or service not known at io.github.cdsap.talaiot.metrics.HostnameMetric$1.invoke(SimpleMetrics.kt:76) at io.github.cdsap.talaiot.metrics.HostnameMetric$1.invoke(SimpleMetrics.kt:75) at io.github.cdsap.talaiot.metrics.base.Metric.get(Metric.kt:15) at io.github.cdsap.talaiot.provider.MetricsProvider.get(MetricsProvider.kt:45) at io.github.cdsap.talaiot.provider.MetricsProvider.get(MetricsProvider.kt:16) at io.github.cdsap.talaiot.publisher.TalaiotPublisherImpl.publish(TalaiotPublisherImpl.kt:42) at io.github.cdsap.talaiot.TalaiotListener.buildFinished(TalaiotListener.kt:76) at jdk.internal.reflect.GeneratedMethodAccessor656.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36) ... 92 more Caused by: java.net.UnknownHostException: teamcity-new: Name or service not known ... 102 more
talaiot version 1.5.1

This exception throws only on teamcity build agent.
I found discussion about this problem https://stackoverflow.com/questions/1881546/inetaddress-getlocalhost-throws-unknownhostexception and ask devops to configure build agent.
But in my case it is not always possible to configure build agent and this one maybe one of them.

@cdsap
Copy link
Owner

cdsap commented Oct 31, 2021

Hi, thanks for the issue. I merged a quick fix to avoid the exception.
The StackOverflow link that you sent explains the issue:

It seems that InetAddress.getLocalHost() ignores the /etc/resolv.conf, but only looks at the /etc/hosts file (where I hadn't specified anything besides localhost)

Apparently we can rely on NetworkInterface.getNetworkInterfaces() as a fall back when InetAddress.getLocalHost() throws an UnknownHostException. In the initial fix I just catch the exception. I can deploy a new version in a couple days.

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

No branches or pull requests

2 participants