dongjoon-hyun opened a new pull request, #997: URL: https://github.com/apache/spark-kubernetes-operator/pull/997
### What changes were proposed in this pull request? This PR aims to run the `builder` stage of `build-tools/docker/Dockerfile` on `$BUILDPLATFORM`. ```diff -FROM gradle:9.9.1-jdk27-resolute AS builder +FROM --platform=$BUILDPLATFORM gradle:9.9.1-jdk27-resolute AS builder ``` A multi-platform build now runs Gradle once and copies the same jar into every target platform image. The `jlink` and final stages still run per target platform, so each image keeps its own custom JRE. ### Why are the changes needed? Currently, `docker buildx build --platform linux/amd64,linux/arm64` runs one `builder` stage per target platform, and both Gradle processes use the same BuildKit cache mount, `/home/gradle/.gradle/caches`, at the same time. When a Gradle process needs a lock that another process holds, it asks the owner to release it over the loopback interface. With the `docker` driver (the BuildKit built into Docker Engine), each `RUN` container has its own network namespace, so the request never reaches the owner. The waiting build fails if the other Gradle process still holds the lock 60 seconds later. For example, a `linux/amd64,linux/arm64` build of `branch-1.1` on Rancher Desktop (Docker Engine 29.9.2, BuildKit v0.34.0, containerd image store) failed like this: ``` > [linux/amd64 builder 4/4] RUN --mount=type=cache,target=/home/gradle/.gradle/caches gradle --no-daemon clean build -x check: ... 72.18 > Timeout waiting to lock journal cache (/home/gradle/.gradle/caches/journal-1). It is currently in use by another process. 72.18 Owner PID: 52 72.18 Our PID: 76 72.18 Owner Operation: 72.18 Our operation: 72.18 Lock file: /home/gradle/.gradle/caches/journal-1/journal-1.lock ``` The `Publish Snapshot Image` workflow uses the `docker-container` driver and has not failed. However, it builds the same jar twice, and the `linux/arm64` build runs under QEMU. In the [run on 2026-11-12](https://github.com/apache/spark-kubernetes-operator/actions/runs/43126089808): | `builder 4/4` | Duration | | - | - | | `linux/amd64` | 208s | | `linux/arm64` (QEMU) | 914s | The jar does not depend on the CPU architecture. Building it once on the build platform removes the concurrent access and skips the emulated Gradle build. ### Does this PR introduce _any_ user-facing change? No. Only the way the image is built changes. Single-platform builds such as `./gradlew buildDockerImage` and the E2E CI work as before because `BUILDPLATFORM` is the same as `TARGETPLATFORM` there. ### How was this patch tested? Manually on Rancher Desktop (Apple Silicon, `docker` driver, containerd image store). ``` $ docker buildx build --platform linux/amd64,linux/arm64 --no-cache --load \ -t spark-kubernetes-operator:test -f build-tools/docker/Dockerfile . ``` - Before: the build of `branch-1.1` failed twice with the error above. The failure depends on timing. On `main` with a warm cache, a multi-platform build passed because the `linux/arm64` Gradle build finished in 74s. The `linux/amd64` Gradle build under emulation took 290s. - After: passed in 222s. Gradle ran once as `[linux/arm64 builder 4/4]` (88s), and `jlink` ran per platform (`linux/arm64` 24s, `linux/amd64` 116s under emulation). Both images run their own JRE and contain the identical jar. ``` $ for p in linux/amd64 linux/arm64; do docker run --rm --platform $p --entrypoint sh spark-kubernetes-operator:test \ -c 'uname -m; java -version 2>&1 | head -1; sha256sum spark-kubernetes-operator.jar'; done x86_64 openjdk version "27.0.1.0.2" 2026-10-21 47f353af9208442c31b0ecddb7f52df4732f3cd8c307958f502292f8460fbab0 spark-kubernetes-operator.jar aarch64 openjdk version "27.0.1.0.2" 2026-10-21 47f353af9208442c31b0ecddb7f52df4732f3cd8c307958f502292f8460fbab0 spark-kubernetes-operator.jar ``` The cause was also confirmed with `gradle:9.9.1-jdk27-resolute` containers that share a cache volume while one of them holds the lock. A Gradle process in its own network namespace failed after 63 seconds with the same `journal-1` error. A Gradle process started with `--network container:<owner>` got the lock in 2 seconds. ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Claude Opus 5.5 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
