quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.82k stars 2.69k forks source link

Failed to start quarkus with remote Dev and docker build strategy #17993

Open danieloh30 opened 3 years ago

danieloh30 commented 3 years ago

Describe the bug

(Describe the problem clearly and concisely.) Failed to start quarkus when I set the remote dev and docker build strategy configuration at the same time. If I remove the docker build strategy configuration(quarkus.openshift.build-strategy=docker), the quarkus app gets started well.

Expected behavior

(Describe the expected behavior clearly and concisely.) Quarkus should start without an error.

Actual behavior

(Describe the actual behavior clearly and concisely.) Failed to start with the following errors:

2021-06-17 14:04:37,756 ERROR [io.qua.dep.dev.IsolatedDevModeMain] (main) Failed to start quarkus: java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors [error]: Build step io.quarkus.container.image.openshift.deployment.OpenshiftProcessor#openshiftPrepareJvmDockerBuild threw an exception: java.lang.NullPointerException at io.quarkus.container.image.openshift.deployment.OpenshiftProcessor.openshiftPrepareJvmDockerBuild(OpenshiftProcessor.java:93) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:820) at io.quarkus.builder.BuildContext.run(BuildContext.java:277) at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18) at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2442) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1476) at java.base/java.lang.Thread.run(Thread.java:829) at org.jboss.threads.JBossThread.run(JBossThread.java:501)

at io.quarkus.runner.bootstrap.AugmentActionImpl.runAugment(AugmentActionImpl.java:401)
at io.quarkus.runner.bootstrap.AugmentActionImpl.createInitialRuntimeApplication(AugmentActionImpl.java:269)
at io.quarkus.runner.bootstrap.AugmentActionImpl.createInitialRuntimeApplication(AugmentActionImpl.java:66)
at io.quarkus.deployment.dev.IsolatedDevModeMain.firstStart(IsolatedDevModeMain.java:84)
at io.quarkus.deployment.dev.IsolatedDevModeMain.accept(IsolatedDevModeMain.java:409)
at io.quarkus.deployment.dev.IsolatedDevModeMain.accept(IsolatedDevModeMain.java:58)
at io.quarkus.bootstrap.app.CuratedApplication.runInCl(CuratedApplication.java:132)
at io.quarkus.bootstrap.app.CuratedApplication.runInAugmentClassLoader(CuratedApplication.java:89)
at io.quarkus.deployment.mutability.DevModeTask.main(DevModeTask.java:69)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at io.quarkus.bootstrap.runner.DevModeMediator.doStart(DevModeMediator.java:50)
at io.quarkus.bootstrap.runner.DevModeMediator.doDevMode(DevModeMediator.java:29)
at io.quarkus.bootstrap.runner.QuarkusEntryPoint.doRun(QuarkusEntryPoint.java:35)
at io.quarkus.bootstrap.runner.QuarkusEntryPoint.main(QuarkusEntryPoint.java:25)

Caused by: io.quarkus.builder.BuildException: Build failure: Build failed due to errors [error]: Build step io.quarkus.container.image.openshift.deployment.OpenshiftProcessor#openshiftPrepareJvmDockerBuild threw an exception: java.lang.NullPointerException at io.quarkus.container.image.openshift.deployment.OpenshiftProcessor.openshiftPrepareJvmDockerBuild(OpenshiftProcessor.java:93) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:820) at io.quarkus.builder.BuildContext.run(BuildContext.java:277) at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18) at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2442) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1476) at java.base/java.lang.Thread.run(Thread.java:829) at org.jboss.threads.JBossThread.run(JBossThread.java:501)

at io.quarkus.builder.Execution.run(Execution.java:116)
at io.quarkus.builder.BuildExecutionBuilder.execute(BuildExecutionBuilder.java:79)
at io.quarkus.deployment.QuarkusAugmentor.run(QuarkusAugmentor.java:153)
at io.quarkus.runner.bootstrap.AugmentActionImpl.runAugment(AugmentActionImpl.java:399)
... 16 more

Caused by: java.lang.NullPointerException at io.quarkus.container.image.openshift.deployment.OpenshiftProcessor.openshiftPrepareJvmDockerBuild(OpenshiftProcessor.java:93) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:820) at io.quarkus.builder.BuildContext.run(BuildContext.java:277) at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18) at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2442) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1476) at java.base/java.lang.Thread.run(Thread.java:829) at org.jboss.threads.JBossThread.run(JBossThread.java:501)

To Reproduce

Link to a small reproducer (preferably a Maven project if the issue is not Gradle-specific).

Or attach an archive containing the reproducer to the issue.

Steps to reproduce the behavior:

  1. Use getting-started example
  2. Add the below configurations, especially with "quarkus.openshift.build-strategy=docker"
  3. Deploy an app to OpenShift via "mvn clean package -DskipTests -Dquarkus.kubernetes.deploy=true"

Configuration

# Add your application.properties here, if applicable.
quarkus.package.type=mutable-jar
quarkus.live-reload.password=changeit
quarkus.openshift.build-strategy=docker
quarkus.openshift.env-vars.quarkus-launch-devmode.value=true

quarkus.kubernetes-client.trust-certs=true
kubernetes.deployment.target=openshift
quarkus.openshift.route.expose=true
kubernetes.deployment-strategy=None

Screenshots

(If applicable, add screenshots to help explain your problem.) image

Environment (please complete the following information):

OpenShift 4.7.2

Output of uname -a or ver

Darwin Daniels-MacBook-Pro 20.3.0 Darwin Kernel Version 20.3.0: Thu Jan 21 00:07:06 PST 2021; root:xnu-7195.81.3~1/RELEASE_X86_64 x86_64

Output of java -version

java version "11.0.10" 2021-01-19 LTS Java(TM) SE Runtime Environment 18.9 (build 11.0.10+8-LTS-162) Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.10+8-LTS-162, mixed mode)

GraalVM version (if different from Java)

Quarkus version or git rev

2.0.0.CR3

Build tool (ie. output of mvnw --version or gradlew --version)

Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f) Maven home: /Users/danieloh/.m2/wrapper/dists/apache-maven-3.6.3-bin/1iopthnavndlasol9gbrbg6bf2/apache-maven-3.6.3 Java version: 11.0.10, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk-11.0.10.jdk/Contents/Home Default locale: en_US, platform encoding: UTF-8 OS name: "mac os x", version: "10.16", arch: "x86_64", family: "mac"

Additional context

(Add any other context about the problem here.)

quarkus-bot[bot] commented 3 years ago

/cc @geoand

geoand commented 3 years ago

Interesting point.

Unfortunately this won't work, so we should probably just disallow it. WDYT @iocanel ?

danieloh30 commented 3 years ago

@geoand To be clear, is this an intended result? meaning is that the docker build strategy doesn't allow remote-dev?

geoand commented 3 years ago

It's a case of that it can't work, so we should disallow it with a good error message

danieloh30 commented 3 years ago

Understood. I suggest that we need to add a note in document(https://quarkus.io/guides/maven-tooling#remote-development-mode)

danieloh30 commented 3 years ago

Out of curiosity, why can't it work? Any reason?

geoand commented 3 years ago

Because it depends on the dockerfile being present, which it's not in remote-dev (on the server side)

danieloh30 commented 3 years ago

It basically uses dockerfile.jvm file that Quarkus project genereates.

maxandersen commented 3 years ago

This seems unfortunate.

Shouldn't we be able to detect remote dev is being requested and ignore / fallback to something that works ?

Since docker build strategy is a recommended one we at least need to tell the user how he can/should use use remote dev with it?

geoand commented 3 years ago

Fallback to what though?

The docker build strategy needs to the Dockefile to be available (not to mention Docker which there is no guarantee exists on the remote machine).

stuartwdouglas commented 3 years ago

Why is the docker file being used in dev mode anyway? Shouldn't this have a guard to stop it being run for dev/test? You can use the DevModeType to also guard explicitly against remote-dev mode.

danieloh30 commented 3 years ago

what is the "DevModeType"? Is that a sort of configuration we can set in application.properties?

stuartwdouglas commented 3 years ago

It's an internal flag that tracks the type of devmode (normal, remote dev client, remote dev server, tests_only).

geoand commented 3 years ago

Why is the docker file being used in dev mode anyway? Shouldn't this have a guard to stop it being run for dev/test? You can use the DevModeType to also guard explicitly against remote-dev mode.

Yes, that's what I meant when I said we should guard against this