GoogleContainerTools / jib

🏗 Build container images for your Java applications.
Apache License 2.0
13.5k stars 1.42k forks source link

No progress after "Container entrypoint set to" with jib-maven-plugin 3.4.3 #4267

Open LeovR opened 1 month ago

LeovR commented 1 month ago

Environment:

Description of the issue: After upgrading to jib-maven-plugin 3.4.3 the progress stops after "Container entrypoint set to". With jib-maven-plugin 3.4.2 the build succeeds.

Expected behavior: The build succeeds.

Steps to reproduce:

  1. skaffold run

jib-maven-plugin Configuration:

            <plugin>
                <groupId>com.google.cloud.tools</groupId>
                <artifactId>jib-maven-plugin</artifactId>
                <version>3.4.3</version>
                <configuration>
                    <skip>false</skip>
                    <containerizingMode>packaged</containerizingMode>
                    <container>
                        <creationTime>USE_CURRENT_TIMESTAMP</creationTime>
                        <mainClass>${start-class}</mainClass>
                    </container>
                    <from>
                        <image>eclipse-temurin:21</image>
                    </from>
                    <to>
                        <image>${docker-registry}/application</image>
                        <tags>
                            <tag>${project.version}</tag>
                            <tag>latest</tag>
                            <tag>${env.CI_COMMIT_SHA}</tag>
                        </tags>
                    </to>
                    <allowInsecureRegistries>true</allowInsecureRegistries>
                </configuration>
                <executions>
                    <execution>
                        <phase>deploy</phase>
                        <goals>
                            <goal>build</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

Log output:

[DEBUG] TIMING  Pulling base image manifest
[INFO] Getting manifest for base image eclipse-temurin:21...
[DEBUG] TIMING  trying mirrors
[DEBUG] TIMED   trying mirrors : 0.0 ms
[DEBUG] TIMING  Preparing application layer builders
[DEBUG] TIMED   Preparing application layer builders : 12.164 ms
[INFO] Building dependencies layer...
[INFO] Building project dependencies layer...
[INFO] Building extra files layer...
[DEBUG] TIMING  Building dependencies layer
[DEBUG] TIMING  Building project dependencies layer
[INFO] Building jvm arg files layer...
[DEBUG] TIMING  Building extra files layer
[DEBUG] TIMING  Building jvm arg files layer
[DEBUG] TIMED   Building jvm arg files layer : 46.44 ms
[DEBUG] TIMED   Building project dependencies layer : 46.752 ms
[DEBUG] TIMED   Building dependencies layer : 60.951 ms
[DEBUG] Building extra files layer built sha256:dfff3e035b17cc725566e639f61f51e44e1bdd662d7a8f6b4c6e55f07ef92d29
[DEBUG] TIMED   Building extra files layer : 107.42 ms
[INFO] Using base image with digest: sha256:ac1545309de7e27001a80d91df2d42865c0bacaec75e016cb4482255d7691187
[DEBUG] Searching for architecture=amd64, os=linux in the base image manifest list
[DEBUG] TIMED   Pulling base image manifest : 1069.014 ms
[DEBUG] TIMING  Pulling base image layer sha256:1ae78fb28ee8ad64497b830c9c46950ab9448341cbdb14f4710d143671487c61
[DEBUG] TIMING  Pulling base image layer sha256:e071b974f417bebf03dcba8690670bce9d7d83d647b1775d42f720b2813da09d
[DEBUG] TIMING  Pulling base image layer sha256:2ec76a50fe7c8d5db9ec25590b9217e14e3920513c6e7b5be55db72a16b55f7c
[DEBUG] TIMING  Pulling base image layer sha256:3c930bd25dd53355206fb22462e8fbde127b1d43483ca67962d2bf2bb4a534c0
[DEBUG] TIMING  Pulling base image layer sha256:eb2b2709c988772d4f722fa842b200b424f5873a64a9b4c5cfaeb86a6293a3b1
[DEBUG] TIMED   Pulling base image layer sha256:eb2b2709c988772d4f722fa842b200b424f5873a64a9b4c5cfaeb86a6293a3b1 : 0.684 ms
[DEBUG] TIMED   Pulling base image layer sha256:3c930bd25dd53355206fb22462e8fbde127b1d43483ca67962d2bf2bb4a534c0 : 1.226 ms
[DEBUG] TIMED   Pulling base image layer sha256:e071b974f417bebf03dcba8690670bce9d7d83d647b1775d42f720b2813da09d : 1.226 ms
[DEBUG] TIMED   Pulling base image layer sha256:2ec76a50fe7c8d5db9ec25590b9217e14e3920513c6e7b5be55db72a16b55f7c : 1.226 ms
[DEBUG] TIMED   Pulling base image layer sha256:1ae78fb28ee8ad64497b830c9c46950ab9448341cbdb14f4710d143671487c61 : 1.226 ms
[DEBUG] TIMING  Building container configuration
[INFO] 
[INFO] Container entrypoint set to [java, -cp, @/app/jib-classpath-file, com.example.Application]
[DEBUG] TIMED   Building container configuration : 1.0 ms

The output for jib-maven-plugin 3.4.2

[DEBUG] TIMING  Pulling base image manifest
[INFO] Getting manifest for base image eclipse-temurin:21...
[DEBUG] TIMING  trying mirrors
[DEBUG] TIMED   trying mirrors : 0.0 ms
[DEBUG] TIMING  Preparing application layer builders
[DEBUG] TIMED   Preparing application layer builders : 11.583 ms
[INFO] Building dependencies layer...
[INFO] Building project dependencies layer...
[DEBUG] TIMING  Building dependencies layer
[DEBUG] TIMING  Building project dependencies layer
[INFO] Building extra files layer...
[DEBUG] TIMING  Building extra files layer
[INFO] Building jvm arg files layer...
[DEBUG] TIMING  Building jvm arg files layer
[DEBUG] TIMED   Building jvm arg files layer : 51.587 ms
[DEBUG] TIMED   Building dependencies layer : 66.647 ms
[DEBUG] TIMED   Building project dependencies layer : 67.966 ms
[DEBUG] Building extra files layer built sha256:dfff3e035b17cc725566e639f61f51e44e1bdd662d7a8f6b4c6e55f07ef92d29
[DEBUG] TIMED   Building extra files layer : 105.634 ms
[INFO] Using base image with digest: sha256:ac1545309de7e27001a80d91df2d42865c0bacaec75e016cb4482255d7691187
[DEBUG] Searching for architecture=amd64, os=linux in the base image manifest list
[DEBUG] TIMED   Pulling base image manifest : 876.057 ms
[DEBUG] TIMING  Pulling base image layer sha256:3c930bd25dd53355206fb22462e8fbde127b1d43483ca67962d2bf2bb4a534c0
[DEBUG] TIMING  Pulling base image layer sha256:2ec76a50fe7c8d5db9ec25590b9217e14e3920513c6e7b5be55db72a16b55f7c
[DEBUG] TIMING  Pulling base image layer sha256:e071b974f417bebf03dcba8690670bce9d7d83d647b1775d42f720b2813da09d
[DEBUG] TIMING  Pulling base image layer sha256:1ae78fb28ee8ad64497b830c9c46950ab9448341cbdb14f4710d143671487c61
[DEBUG] TIMING  Pulling base image layer sha256:eb2b2709c988772d4f722fa842b200b424f5873a64a9b4c5cfaeb86a6293a3b1
[DEBUG] TIMED   Pulling base image layer sha256:1ae78fb28ee8ad64497b830c9c46950ab9448341cbdb14f4710d143671487c61 : 0.53 ms
[DEBUG] TIMED   Pulling base image layer sha256:eb2b2709c988772d4f722fa842b200b424f5873a64a9b4c5cfaeb86a6293a3b1 : 0.53 ms
[DEBUG] TIMED   Pulling base image layer sha256:3c930bd25dd53355206fb22462e8fbde127b1d43483ca67962d2bf2bb4a534c0 : 0.53 ms
[DEBUG] TIMED   Pulling base image layer sha256:2ec76a50fe7c8d5db9ec25590b9217e14e3920513c6e7b5be55db72a16b55f7c : 0.53 ms
[DEBUG] TIMED   Pulling base image layer sha256:e071b974f417bebf03dcba8690670bce9d7d83d647b1775d42f720b2813da09d : 0.53 ms
[DEBUG] TIMING  Building container configuration
[INFO] 
[INFO] Container entrypoint set to [java, -cp, @/app/jib-classpath-file, com.example.Application]
[DEBUG] TIMED   Building container configuration : 1.002 ms
[DEBUG] TIMING  Loading to Docker daemon
[INFO] Loading to Docker daemon...
[DEBUG] Loaded image: xxx:20240605-3829.598137-2-gfa19a177-dirty
The image xxx:local already exists, renaming the old one with ID sha256:cccec99bcdeeaf6a5f7c958a62761ec9a62f75c60fa6947a5df08e7548344317 to empty string
Loaded image: xxx:local

[DEBUG] TIMED   Loading to Docker daemon : 13144.805 ms
[DEBUG] TIMED   Building image to Docker daemon : 14055.52 ms
[INFO] 
[INFO] Built image to Docker daemon as ...

Additional Information:

The build is triggered by skaffold with additional parameter -Djib.to.tags=local.

beskow commented 3 weeks ago

We are facing the same problem when upgrading to jib-maven-plugin 3.4.3.

It seems to be a Windows-only problem (it works correctly when running the command in WSL2/Ubuntu)

Staying on 3.4.2 for now.

bamanuel1 commented 2 weeks ago

Breaking change is addition of the following line. https://github.com/GoogleContainerTools/jib/blob/ec44330c1adbd0e1538fe01ffaa51b8233432635/jib-core/src/main/java/com/google/cloud/tools/jib/builder/steps/StepsRunner.java#L624

This line blocks until docker info -f "{{json .}}" process exits to start reading the inputStream. On windows, it only exits after inputStream is read, resulting in deadlock. https://github.com/GoogleContainerTools/jib/blob/ec44330c1adbd0e1538fe01ffaa51b8233432635/jib-core/src/main/java/com/google/cloud/tools/jib/docker/CliDockerClient.java#L192

Can be reproduced on windows with following code. Only occurs with -f option.

Process process = new ProcessBuilder("docker", "info", "-f", "json").start();
process.waitFor();
chanseokoh commented 1 week ago

@mpeddada1 this I believe was introduced in 3.4.3 and looks to be an important regression issue to fix before making the next release.

mpeddada1 commented 1 week ago

@chanseokoh Assigned this to myself. @beskow My initial hypothesis was that this may have been caused due to some unconventional log warnings we added but this is really helpful information (https://github.com/GoogleContainerTools/jib/issues/4267#issuecomment-2183474967)

This line blocks until docker info -f "{{json .}}" process exits to start reading the inputStream. On windows, it only exits after inputStream is read, resulting in deadlock.

Chris-Frendo commented 1 week ago

We encountered this issue as well. Seems to be working on linux but hanging on windows.

Doing a breakpoint on line 191 in CliDockerClient and calling waitFor() hangs on windows. If you call getInputStream() without calling waitFor() before it, it works as expected.

Downgraded to 3.4.2 in the meantime.