pulumi / pulumi-java

Java support for Pulumi
Apache License 2.0
69 stars 21 forks source link

Pulumi is not started from backed jar file #1307

Open golosegor opened 8 months ago

golosegor commented 8 months ago

What happened?

I'm trying to run pulumi from precompiled jar file (following the guide here: https://github.com/pulumi/pulumi-java/ )

First I'm starting new project and could check that compilation is working and pulumi do the job. Then I'm packaging exactly this project, and building farjar (repro guide is here: https://github.com/golosegor/pulumi-execute-from-jar-issue )

Then I'm trying to run pulumi with complid code from folder nearby: https://github.com/golosegor/pulumi-execute-from-jar-issue/blob/main/repro-folder/Pulumi.yaml and getting GRCP unavailable exception

Example

I've created a repro

https://github.com/golosegor/pulumi-execute-from-jar-issue

Output of pulumi about

CLI
Version 3.100.0 Go Version go1.21.5 Go Compiler gc

Plugins NAME VERSION java unknown

Host
OS ubuntu Version 23.10 Arch x86_64

Additional context

Output looks like that:

I0109 14:52:54.785976 297662 log.go:81] GetRequiredPlugins: plugins=[] I0109 14:52:54.796470 297662 log.go:81] Run: program=. I0109 14:52:54.796485 297662 log.go:73] Language host launching process: /home/eg/.sdkman/candidates/java/current/bin/java-jar ../demo/target/demo-1.0-SNAPSHOT-jar-with-dependencies.jar Jan 09, 2024 2:52:55 PM com.pulumi.deployment.internal.DeploymentImpl$DefaultEngineLogger errorAsync SEVERE: Running program [PID: 297717](/home/eg/.sdkman/candidates/java/17.0.9-tem/bin/java -jar ../demo/target/demo-1.0-SNAPSHOT-jar-with-dependencies.jar) failed with an unhandled exception: io.grpc.StatusRuntimeException: UNAVAILABLE: io exception

Contributing

Vote on this issue by adding a 👍 reaction. To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

justinvp commented 7 months ago

Thanks for opening the issue and providing a repro project @golosegor! I haven't had a chance to try the repro yet, but one quick question: Does it work if you place the .jar within repro-folder and update the path in Pulumi.yaml to not have ../?

golosegor commented 7 months ago

Hello @justinvp . I tried different ways. Absolute path is also not working. So it's not a problem with the path 100%

vooft commented 6 months ago

No idea why exactly is this happening, feels like some funny business inside grpc-netty-shaded and shadow jar plugin.

I debugged through the code, and basically when you run pulumi via gradle, it defaults to dns:// protocol, but when you run it via a far jar, it falls back to unix://, which is invalid.

This happens in io.grpc.internal.ManagedChannelImpl#getNameResolver(java.lang.String, io.grpc.NameResolver.Factory, io.grpc.NameResolver.Args) link, where it says it should fall back to dns://, but it doesn't.

This seems to be a fix for that: https://github.com/grpc/grpc-java/issues/10425 but dumb upgrade of grpc didn't help much.

vooft commented 6 months ago

Interesting, I've just replaced the shadow plugin with spring-boot plugin, which can also generate a fat jar, and it works now! Perhaps it would be good to have an official example project where a fat jar is created and pulumi is executed from it.