quarkusio / quarkus

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

Gradle Build Cache fails to restore lambda function.zip native executable #36808

Open snowe2010 opened 1 year ago

snowe2010 commented 1 year ago

Describe the bug

./gradlew build --build-cache caches quarkusBuild task, but does not restore native function.zip output, resulting in a build that does not work (native build outputs nothing)

Expected behavior

When running ./gradlew build --build-cache, I would expect gradle to either restore everything that was cached and result in a short build with the correct outputs, or to run tasks that weren't able to be cached, resulting in the correct outputs.

Actual behavior

Testing locally and in CI using the steps detailed in the gradle docs.

I build the project (with the build cache flag enabled), it runs the native graalvm build using docker. I then run a clean to wipe the build directory I then rerun the exact same command as the initial build.

I would expect to see the function.zip populate in the build directory, but nothing populates there. Looking at the log, gradle is marking the quarkusBuild task as FROM CACHE which is fine since I didn't change anything, but it should be restoring the function.zip then. But if it can't restore the function.zip (per this PR, this is on purpose) then it should not mark the task as up to date. It is causing complete failure in our CI, since gradle refuses to run the quarkusBuild task, but is also refusing to restore the zip we need to actually deploy.

How to Reproduce?

You can reproduce this with any brand new amazon-lambda project, but here is an attached one just in case you don't want to build a new one.

quarkus-bug-oct-31-2023.zip

Steps:

  1. run ./gradlew build -Dquarkus.package.type=native -Dquarkus.native.container-build=true --build-cache
  2. verify that function.zip is in the build folder
  3. run ./gradlew clean --quiet and verify build folder is gone
  4. run ./gradlew build -Dquarkus.package.type=native -Dquarkus.native.container-build=true --build-cache
  5. function.zip will not be present, quarkusBuild will be marked as UP TO DATE even though the outputs are incorrect.

Output of uname -a or ver

Darwin SR-MB-502963 22.6.0 Darwin Kernel Version 22.6.0: Fri Sep 15 13:41:28 PDT 2023; root:xnu-8796.141.3.700.8~1/RELEASE_ARM64_T6000 arm64

Output of java -version

openjdk version "18" 2022-03-22 OpenJDK Runtime Environment (build 18+36-2087) OpenJDK 64-Bit Server VM (build 18+36-2087, mixed mode, sharing)

Mandrel or GraalVM version (if different from Java)

No response

Quarkus version or git rev

both 2.16.4 and 3.5.0

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

Gradle 8.3

Additional information

No response

quarkus-bot[bot] commented 1 year ago

/cc @Karm (mandrel), @galderz (mandrel), @glefloch, @matejvasek (amazon-lambda), @patriot1burke (amazon-lambda), @quarkusio/devtools, @zakkak (mandrel)

HipsterZipster commented 10 months ago

@snowe2010 I'm having the same issue! Can you please share how you solved or worked around it?

snowe2010 commented 9 months ago

@HipsterZipster I did not solve it nor work around it. I just can't use the build-cache until this is fixed.

galderz commented 9 months ago

@snazy Looking at the code you added, the integration would seem to take care of this and so the native runner should be included? https://github.com/quarkusio/quarkus/blame/main/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusBuildCacheableAppParts.java#L43. Can you look into this?

galderz commented 9 months ago

@HipsterZipster @snowe2010 You could try debugging the builder code with the IDE and see what is going. The above comment hints at some areas that takes care of this.

snowe2010 commented 8 months ago

@galderz I did debug, that's how I found the problem area and the PR.

ghilainm commented 2 months ago

Same issue here.

galderz commented 1 month ago

@geoand @gsmet @aloubyansky Can someone help with this?

geoand commented 1 month ago

My knowledge of Gradle is too limited to be of any help here