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

FileNotFoundException error getting public host name from:http://169.254.169.254/latest/meta-data/publicHostname #497

Closed
dgbmariano opened this issue Sep 4, 2020 · 5 comments
Assignees
Labels
info: good first issue Good for newcomers priority: high High priority type: bug Something isn't working

Comments

@dgbmariano
Copy link

This issue is related to this issue: micronaut-projects/micronaut-core#2934.
Our app is hosted in Amazon and every time that we start a pod we get two errors:

error getting public host name from:http://169.254.169.254/latest/meta-data/publicHostname


java.io.FileNotFoundException: http://169.254.169.254/latest/meta-data/public-hostname
 	at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1872)
 	at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1474)
 	at io.micronaut.discovery.cloud.aws.AmazonComputeInstanceMetadataResolver.readEc2MetadataUrl(AmazonComputeInstanceMetadataResolver.java:180)
 	at io.micronaut.discovery.cloud.aws.AmazonComputeInstanceMetadataResolver.resolve(AmazonComputeInstanceMetadataResolver.java:113)
 	at io.micronaut.grpc.server.GrpcEmbeddedServer.lambda$start$1(GrpcEmbeddedServer.java:166)
 	at java.util.Optional.ifPresent(Optional.java:159)
 	at io.micronaut.grpc.server.GrpcEmbeddedServer.start(GrpcEmbeddedServer.java:162)
 	at io.micronaut.grpc.server.GrpcEmbeddedServerListener.onApplicationEvent(GrpcEmbeddedServerListener.java:59)
 	at io.micronaut.grpc.server.GrpcEmbeddedServerListener.onApplicationEvent(GrpcEmbeddedServerListener.java:37) 
	at io.micronaut.context.DefaultBeanContext.notifyEventListeners(DefaultBeanContext.java:1302)
 	at io.micronaut.context.DefaultBeanContext.publishEvent(DefaultBeanContext.java:1287)
 	at io.micronaut.http.server.netty.NettyHttpServer.fireStartupEvents(NettyHttpServer.java:495)
 	at io.micronaut.http.server.netty.NettyHttpServer.start(NettyHttpServer.java:341)
 	at io.micronaut.http.server.netty.NettyHttpServer.start(NettyHttpServer.java:110)
 	at io.micronaut.runtime.Micronaut.lambda$start$2(Micronaut.java:70)
 	at java.util.Optional.ifPresent(Optional.java:159)
 	at io.micronaut.runtime.Micronaut.start(Micronaut.java:68)

And:


java.io.FileNotFoundException: http://169.254.169.254/latest/meta-data//network/interfaces/macs/XX:XX:XX:XX:XX:XX/public-ipv4s/
 	at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1872)
 	at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1474)
 	at io.micronaut.discovery.cloud.aws.AmazonComputeInstanceMetadataResolver.readEc2MetadataUrl(AmazonComputeInstanceMetadataResolver.java:180)
 	at io.micronaut.discovery.cloud.aws.AmazonComputeInstanceMetadataResolver.resolve(AmazonComputeInstanceMetadataResolver.java:128)
 	at io.micronaut.grpc.server.GrpcEmbeddedServer.lambda$start$1(GrpcEmbeddedServer.java:166) 	at java.util.Optional.ifPresent(Optional.java:159)
 	at io.micronaut.grpc.server.GrpcEmbeddedServer.start(GrpcEmbeddedServer.java:162)
 	at io.micronaut.grpc.server.GrpcEmbeddedServerListener.onApplicationEvent(GrpcEmbeddedServerListener.java:59)
 	at io.micronaut.grpc.server.GrpcEmbeddedServerListener.onApplicationEvent(GrpcEmbeddedServerListener.java:37)
 	at io.micronaut.context.DefaultBeanContext.notifyEventListeners(DefaultBeanContext.java:1302)
 	at io.micronaut.context.DefaultBeanContext.publishEvent(DefaultBeanContext.java:1287)
 	at io.micronaut.http.server.netty.NettyHttpServer.fireStartupEvents(NettyHttpServer.java:495)
 	at io.micronaut.http.server.netty.NettyHttpServer.start(NettyHttpServer.java:341)
 	at io.micronaut.http.server.netty.NettyHttpServer.start(NettyHttpServer.java:110)
 	at io.micronaut.runtime.Micronaut.lambda$start$2(Micronaut.java:70)
 	at java.util.Optional.ifPresent(Optional.java:159)
 	at io.micronaut.runtime.Micronaut.start(Micronaut.java:68)

For the second error, I believe that the cause is because of the val metadataUrl that is url + "/latest/meta-data/" defined in the file AmazonMetadataConfiguration.java but in the file AmazonComputeInstanceMetadataResolver.java we have:

String vpcId = readEc2MetadataUrl(new URL(ec2InstanceMetadataURL + "/network/interfaces/macs/" + macAddress + "/vpc-id/"), CONNECTION_TIMEOUT_IN_MILLS, READ_TIMEOUT_IN_MILLS);

Causing the double // in the path. I've tried to make the metadataUrl be url + "/latest/meta-data but broke other things, so maybe the way is to fix the paths in AmazonComputeInstanceMetadataResolver.java.

Thanks.

@graemerocher graemerocher transferred this issue from micronaut-projects/micronaut-core Sep 8, 2020
@alvarosanchez alvarosanchez added the type: bug Something isn't working label Sep 10, 2020
@etnishiyama
Copy link

We have the same issue here. Do we have any update on this?

@ttzn
Copy link
Contributor

ttzn commented Nov 19, 2020

If you could provide a minimal example set up that we can reproduce (with dependency versions), it would increase the likelihood that somebody contributes a fix.

@pgressa
Copy link
Contributor

pgressa commented Mar 4, 2021

@etnishiyama @dgbmariano could you please share some example so I can replicate the issue and provide proper fix. Or maybe describe in more depth the context of the issue. I understand that it's happening in K8s only?

@pgressa pgressa added the info: good first issue Good for newcomers label Mar 4, 2021
@dgbmariano
Copy link
Author

Sorry for not updating. I've tried to reproduce locally but I couldn't. The maximum that I could get I described in the description. The enviromnents are: [k8s, cloud, ec2, prod].
Also, we upgraded the micronaut version some months ago and we are not getting this error anymore. Maybe we could close this issue now. Sorry for not updating!

@pgressa
Copy link
Contributor

pgressa commented Mar 8, 2021

Hi @dgbmariano no worries. Ok so I'm going to close this issue now. If you or @etnishiyama will experience this issue once again, please open new issue, ideally with simple example in github. To easily create reproducer in github use the launcher https://micronaut.io/launch/ .. it has the button push-to-github and even the dekorate feature for k8s deployment.

@pgressa pgressa closed this as completed Mar 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
info: good first issue Good for newcomers priority: high High priority type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants