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

Allows Linux-only extensions on Windows with Linux builder image #28412

Merged
merged 1 commit into from Oct 10, 2022

Conversation

Karm
Copy link
Member

@Karm Karm commented Oct 5, 2022

fixes #28335

Running on Windows host

There is a correct exception explaining that this is not going to work:

[ERROR] Failed to execute goal io.quarkus:quarkus-maven-plugin:999-SNAPSHOT:build (default) on project awt-graphics-rest-quickstart: Failed to build quarkus application: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
[ERROR]         [error]: Build step io.quarkus.deployment.pkg.steps.NativeImageBuildStep#build threw an exception: java.lang.RuntimeException: Failed to build native image
[ERROR]         at io.quarkus.deployment.pkg.steps.NativeImageBuildStep.build(NativeImageBuildStep.java:281)
[ERROR]         at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR]         at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
[ERROR]         at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR]         at java.base/java.lang.reflect.Method.invoke(Method.java:568)
[ERROR]         at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:909)
[ERROR]         at io.quarkus.builder.BuildContext.run(BuildContext.java:281)
[ERROR]         at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
[ERROR]         at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
[ERROR]         at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
[ERROR]         at java.base/java.lang.Thread.run(Thread.java:833)
[ERROR]         at org.jboss.threads.JBossThread.run(JBossThread.java:501)
[ERROR] Caused by: java.lang.UnsupportedOperationException: Windows AWT integration is not ready in native-image and would result in java.lang.UnsatisfiedLinkError: no awt in java.library.path.
[ERROR]         at io.quarkus.deployment.pkg.steps.NativeImageBuildStep$NativeImageInvokerInfo$Builder.build(NativeImageBuildStep.java:882)
[ERROR]         at io.quarkus.deployment.pkg.steps.NativeImageBuildStep.build(NativeImageBuildStep.java:249)
[ERROR]         ... 11 more
[ERROR] -> [Help 1]

Running on Windows with podman

This is allowed now because the build happens in Linux userland:

C:\tmp\quarkus-quickstarts\awt-graphics-rest-quickstart(development -> origin)                  
                                                                                                                          
λ mvnw package -DskipTests -Pnative -Dquarkus.native.container-build=true -Dquarkus.native.builder-image=quay.io/quarkus/ubi-quarkus-mandrel:22.2-java17 -Dquarkus.native.container-runtime=podman                        
[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildStep] Running Quarkus native-image plugin on native-image 22.2.0.0-Final Mandrel Distribution (Java Version 17.0.4+8)
[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildRunner] podman run --env LANG=C --rm -v /c/tmp/quarkus-quickstarts/awt-graphics-rest-quickstart/target/awt-graphics-rest-quickstart-1.0.0-SNAPSHOT-native-image-source-jar:/project:z --name build-native-VshPN quay.io/quarkus/ubi-quarkus-mandrel:22.2-java17 -J-Djava.util.logging.manager=org.jboss.logmanager.LogManager -J-Dsun.nio.ch.maxUpdateArraySize=100 -J-Dlogging.initial-configurator.min-level=500 -J-Dvertx.logger-delegate-factory-class-name=io.quarkus.vertx.core.runtime.VertxLogDelegateFactory -J-Dvertx.disableDnsResolver=true -J-Dio.netty.leakDetection.level=DISABLED -J-Dio.netty.allocator.maxOrder=3 -J-Duser.language=en -J-Duser.country=US -J-Dfile.encoding=UTF-8 --features=io.quarkus.runner.Feature,io.quarkus.awt.runtime.graal.AwtFeature,io.quarkus.runtime.graal.ResourcesFeature,io.quarkus.awt.runtime.graal.DarwinAwtFeature,io.quarkus.runtime.graal.DisableLoggingFeature -J--add-exports=java.security.jgss/sun.security.krb5=ALL-UNNAMED -J--add-opens=java.base/java.text=ALL-UNNAMED -J--add-opens=java.base/java.io=ALL-UNNAMED -J--add-opens=java.base/java.lang.invoke=ALL-UNNAMED -J--add-opens=java.base/java.util=ALL-UNNAMED -H:+AllowFoldMethods -J-Djava.awt.headless=true --no-fallback --link-at-build-time -H:+ReportExceptionStackTraces -H:-AddAllCharsets --enable-url-protocols=http -H:-UseServiceLoaderFeature -H:+StackTrace -J--add-exports=org.graalvm.nativeimage.builder/com.oracle.svm.core.jni=ALL-UNNAMED -J--add-exports=org.graalvm.sdk/org.graalvm.nativeimage.impl=ALL-UNNAMED -J--add-exports=org.graalvm.nativeimage.builder/com.oracle.svm.core.jdk=ALL-UNNAMED -J--add-exports=org.graalvm.nativeimage.builder/com.oracle.svm.core.configure=ALL-UNNAMED -J--add-exports=org.graalvm.nativeimage.builder/com.oracle.svm.core.jdk.localization=ALL-UNNAMED awt-graphics-rest-quickstart-1.0.0-SNAPSHOT-runner -jar awt-graphics-rest-quickstart-1.0.0-SNAPSHOT-runner.jar
========================================================================================================================
GraalVM Native Image: Generating 'awt-graphics-rest-quickstart-1.0.0-SNAPSHOT-runner' (executable)...
========================================================================================================================
[1/7] Initializing...                                                                                   (27.0s @ 0.31GB)
 Version info: 'GraalVM 22.2.0.0-Final Java 17 Mandrel Distribution'
 Java version info: '17.0.4+8'
 C compiler: gcc (redhat, x86_64, 8.5.0)
 Garbage collector: Serial GC
 6 user-specific feature(s)
 - io.quarkus.awt.runtime.graal.AwtFeature
 - io.quarkus.awt.runtime.graal.DarwinAwtFeature
 - io.quarkus.runner.Feature: Auto-generated class by Quarkus from the existing extensions
 - io.quarkus.runtime.graal.DisableLoggingFeature: Disables INFO logging during the analysis phase for the [org.jboss.threads] categories
 - io.quarkus.runtime.graal.ResourcesFeature: Register each line in META-INF/quarkus-native-resources.txt as a resource on Substrate VM
 - org.graalvm.home.HomeFinderFeature: Finds GraalVM paths and its version number
[2/7] Performing analysis...  [*********]                                                               (98.1s @ 1.00GB)
  12,055 (88.91%) of 13,558 classes reachable
  20,154 (62.15%) of 32,430 fields reachable
  71,264 (60.87%) of 117,082 methods reachable
     492 classes,   120 fields, and 1,719 methods registered for reflection
     178 classes, 1,535 fields, and 2,092 methods registered for JNI access
       7 native libraries: dl, freetype, m, pthread, rt, stdc++, z
[3/7] Building universe...                                                                              (12.5s @ 1.49GB)
[4/7] Parsing methods...      [***]                                                                      (9.9s @ 1.25GB)
[5/7] Inlining methods...     [***]                                                                      (6.8s @ 2.35GB)
[6/7] Compiling methods...    [*********]                                                               (80.7s @ 1.84GB)
[7/7] Creating image...                                                                                 (23.9s @ 2.10GB)
  31.73MB (49.80%) for code area:    50,858 compilation units
  29.16MB (45.77%) for image heap:  335,899 objects and 19 resources
   2.82MB ( 4.42%) for other data
  63.70MB in total
------------------------------------------------------------------------------------------------------------------------
Top 10 packages in code area:                               Top 10 object types in image heap:
   6.36MB com.oracle.svm.jni                                   6.63MB byte[] for code metadata
   1.65MB sun.security.ssl                                     3.25MB java.lang.String
   1.01MB java.util                                            3.20MB byte[] for java.lang.String
 759.95KB sun.font                                             2.93MB java.lang.Class
 732.23KB com.sun.crypto.provider                              2.86MB byte[] for general heap data
 566.26KB java.lang.invoke                                     1.28MB byte[] for embedded resources
 488.79KB java.awt.image                                       1.01MB com.oracle.svm.core.hub.DynamicHubCompanion
 472.18KB java.lang                                          701.41KB byte[] for reflection metadata
 460.85KB com.sun.imageio.plugins.tiff                       652.77KB java.lang.String[]
 458.75KB sun.security.x509                                  632.02KB java.util.HashMap$Node
  18.48MB for 438 more packages                                5.10MB for 2684 more object types
------------------------------------------------------------------------------------------------------------------------
                        13.9s (5.1% of total time) in 49 GCs | Peak RSS: 4.44GB | CPU load: 3.13
------------------------------------------------------------------------------------------------------------------------
Produced artifacts:
 /project/awt-graphics-rest-quickstart-1.0.0-SNAPSHOT-runner (executable)
 /project/awt-graphics-rest-quickstart-1.0.0-SNAPSHOT-runner.build_artifacts.txt (txt)
========================================================================================================================
Finished generating 'awt-graphics-rest-quickstart-1.0.0-SNAPSHOT-runner' in 4m 27s.
[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildRunner] podman run --env LANG=C --rm -v /c/tmp/quarkus-quickstarts/awt-graphics-rest-quickstart/target/awt-graphics-rest-quickstart-1.0.0-SNAPSHOT-native-image-source-jar:/project:z --entrypoint /bin/bash quay.io/quarkus/ubi-quarkus-mandrel:22.2-java17 -c objcopy --strip-debug awt-graphics-rest-quickstart-1.0.0-SNAPSHOT-runner
[INFO] [io.quarkus.deployment.QuarkusAugmentor] Quarkus augmentation completed in 374199ms
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  06:19 min
[INFO] Finished at: 2022-10-05T13:36:10-07:00
[INFO] ------------------------------------------------------------------------

@quarkus-bot

This comment has been minimized.

@Karm
Copy link
Member Author

Karm commented Oct 6, 2022

Hmmm, I wonder if I broke that on Mac?

/Users/githubactions/actions-runner/_work/_temp/155ed903-a9b0-4c42-96c5-e45de292a9c1.sh: line 1: devtools/gradle/gradlew: No such file or directory
Error: Process completed with exit code 1.

Perhaps it should be explicitly matched to Win?

@@ -875,7 +875,8 @@ public NativeImageInvokerInfo build() {
}

if (unsupportedOSes != null && !unsupportedOSes.isEmpty()) {
final String errs = unsupportedOSes.stream().filter(o -> o.os.active).map(o -> o.error)
final String errs = unsupportedOSes.stream().filter(o -> o.os.active && !nativeConfig.isContainerBuild())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if the unsupported OS is Linux?

IMHO you're making a general infrastructure extremely specific with this change.

Copy link
Member Author

@Karm Karm Oct 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the extension is Windows-specific and the unsupported OS is Linux, then my patch doesn't work when executed in a Linux container on a Windows host.

I am making a baold assumption that we have only Linux builder images (e.g. no Windows Server Core based ones) and that all extensions work on Linux as a baseline.

Coming from that, if you run on Mac or Windows, you are always going to be using a Linux builder image...


I can add a logic to the Native Image Config that would report the Builder Image's OS and then let the UnsupportedOS compare to that.

I think it is an overkill right now when it comes to OS. On the other hand, it might be useful as a check for the architecture. Supporting/Not supporting amd64 vs. aarch64 builder image on Mac comes to mind.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So yes, the assumption of Linux container can be made. We make it in other places.

My problem with your patch:

  • let's assume a feature is unsupported on Linux
  • let's assume we are on Linux in a container build
  • o.os.active is true
  • !nativeConfig.isContainerBuild() is false
  • this feature doesn't work as expected

I think you will have to special case Linux somehow for this feature to keep being working in all cases.

The condition should be something like: (nativeConfig.isContainerBuild() && o.os == linux) || o.os.active (in pseudo code).
Does it make sense to you?

BTW, I approved the PR by mistake, it was a request for changes.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack. I got the point. Lemme take a second look....and I guess also to add a test so as the context of this change is not lost like tears in rain.

BTW: It seems that the time it takes to build Quarkus on I/O bound Windows VMs is getting slightly out of hand :-( Not sure what to do about it.

@Karm Karm marked this pull request as draft October 6, 2022 14:07
@Karm Karm marked this pull request as ready for review October 7, 2022 13:43
@Karm Karm requested a review from gsmet October 7, 2022 13:49
@Karm
Copy link
Member Author

Karm commented Oct 7, 2022

@gsmet
When there is an extension unsupported on LINUX and you run it on Windows in a builder image, it fails 👍

C:\tmp\quarkus-quickstarts\awt-graphics-rest-quickstart(development -> origin)
λ mvnw clean package -DskipTests -Pnative -Dquarkus.native.container-build=true -Dquarkus.native.builder-image=quay.io/quarkus/ubi-quarkus-mandrel:22.2-java17 -Dquarkus.native.container-runtime=podman
[INFO] Scanning for projects...
...
[ERROR] Caused by: java.lang.UnsupportedOperationException: LINUX FAKE integration is not ready in native-image

I also attempted to comment the "logic" so as we can remember this tomorrow....

@Karm
Copy link
Member Author

Karm commented Oct 7, 2022

...and it behaves on Linux as expected too.

@quarkus-bot

This comment has been minimized.

@quarkus-bot
Copy link

quarkus-bot bot commented Oct 8, 2022

Failing Jobs - Building 00392e7

Status Name Step Failures Logs Raw logs
✔️ JVM Tests - JDK 11
✔️ JVM Tests - JDK 17
JVM Tests - JDK 17 MacOS M1 Set up runner ⚠️ Check → Logs Raw logs
✔️ JVM Tests - JDK 18

@gsmet gsmet merged commit e487e3a into quarkusio:main Oct 10, 2022
@quarkus-bot quarkus-bot bot added this to the 2.14 - main milestone Oct 10, 2022
@gsmet gsmet modified the milestones: 2.14 - main, 2.13.2.Final Oct 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Native awt build fails on Windows also when running with native-build-container
2 participants