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

--export-cache option crashes buildkitd on custom frontend #1336

Closed
drodriguezhdez opened this issue Jan 17, 2020 · 3 comments · Fixed by #1382
Closed

--export-cache option crashes buildkitd on custom frontend #1336

drodriguezhdez opened this issue Jan 17, 2020 · 3 comments · Fixed by #1382
Assignees
Labels

Comments

@drodriguezhdez
Copy link

drodriguezhdez commented Jan 17, 2020

OS: macOS Catalina 10.15.2
Docker: Docker version 19.03.5, build 633a0ea
Buildctl: github.com/moby/buildkit 0.6.3
Buildkitd: v0.6.3

Hi,

I'm creating a PoC for a new buildkit frontend for Maven (which download the code and execute the tests).

It seems that the --export-cache option in the buildctl command is crashing the buildkitd container.

After command enters into the export cache phase, it returns the following message

#18 exporting cache
#18 preparing build cache for export
error: failed to receive status: rpc error: code = Unavailable desc = transport is closing

Killing the buildkitd container.

Command to reproduce:

buildctl --addr=docker-container://buildkitd build \
--frontend=gateway.v0 \
--opt source=codescope/mavenfile-test \
--opt context=https://github.com/drodriguezhdez/hello-world.git \
--export-cache type=local,dest=cache \
--output type=local,dest=output

Using export-cache type=registry or inline, it is obtaining the same error.

Is it needed something specific in the frontend code to support this option --export-cache?

Thank you so much.

@drodriguezhdez
Copy link
Author

/cc @fermayo @tonyredondo

@tonistiigi
Copy link
Member

@drodriguezhdez is there source code for codescope/mavenfile-test?

@drodriguezhdez
Copy link
Author

drodriguezhdez commented Jan 21, 2020

Hi @tonistiigi,

I created a repository with the minimum amount of code which reproduces this issue.
Find it here: https://github.com/drodriguezhdez/buildkit-cache-sandbox

Command:

buildctl --addr=docker-container://buildkitd build \
--frontend=gateway.v0 \
--opt source=drodriguezh/cache-sandbox-2-test \
--export-cache type=local,dest=cache \
--output type=local,dest=output

Findings:

It seems that if in the file builder/build.go, in this code

buildInterm := llb.Image("alpine:latest").File(llb.Copy(git, "pom.xml", "pom.xml"))

......

buildFinal := llb.Image("alpine:latest").File(llb.Copy(buildInterm, "pom.xml", "pom.xml"))

makes the --export-cache fails.

But, if the second copy from buildInterm to buildFinal is removed, the --export-cache seems to work fine.

Logs of the failed --export-cache

[+] Building 63.4s (8/9)
 => resolve image config for docker.io/drodriguezh/cache-sandbox-2-test:latest                                                                                                                                                           1.7s
 => docker-image://docker.io/drodriguezh/cache-sandbox-2-test@sha256:a72f0051444f46996ba433fe5c6061fcc0c7c2134aab46c934c55fb03a7a8ad7                                                                                                    1.1s
 => => resolve docker.io/drodriguezh/cache-sandbox-2-test@sha256:a72f0051444f46996ba433fe5c6061fcc0c7c2134aab46c934c55fb03a7a8ad7                                                                                                        0.0s
 => => sha256:a72f0051444f46996ba433fe5c6061fcc0c7c2134aab46c934c55fb03a7a8ad7 528B / 528B                                                                                                                                               0.0s
 => => sha256:c0b3f700501b7670a7c6763239359fbd3f3ef4747d3dc09823a6c07fe538b5a7 4.52MB / 4.52MB                                                                                                                                           0.7s
 => => sha256:2c64ab7b1506ab6f77f6c2c7a8d6426c567265f518fe448e6581bc50ba759bef 1.56kB / 1.56kB                                                                                                                                           0.0s
 => => unpacking docker.io/drodriguezh/cache-sandbox-2-test@sha256:a72f0051444f46996ba433fe5c6061fcc0c7c2134aab46c934c55fb03a7a8ad7                                                                                                      0.2s
 => git://github.com/drodriguezhdez/hello-world.git#master                                                                                                                                                                               1.6s
 => docker-image://docker.io/library/alpine:latest                                                                                                                                                                                       0.6s
 => => resolve docker.io/library/alpine:latest                                                                                                                                                                                           0.6s
 => => sha256:ab00606a42621fb68f2ed6ad3c88be54397f981a7b70a79db3d1172b11c4367d 1.64kB / 1.64kB                                                                                                                                           0.0s
 => => sha256:ddba4d27a7ffc3f86dd6c2f92041af252a1f23a8e742c90e6e1297bfa1bc0c45 528B / 528B                                                                                                                                               0.0s
 => => sha256:c9b1b535fdd91a9855fb7f82348177e5f019329a58c53c47272962dd60f71fc9 2.80MB / 2.80MB                                                                                                                                           0.4s
 => => sha256:e7d92cdc71feacf90708cb59182d0df1b911f8ae022d29e8e95d75ca6a99776a 1.51kB / 1.51kB                                                                                                                                           0.0s
 => => unpacking docker.io/library/alpine:latest                                                                                                                                                                                         0.1s
 => copy /pom.xml /pom.xml                                                                                                                                                                                                               0.2s
 => CACHED copy /pom.xml /pom.xml                                                                                                                                                                                                        0.0s
 => copy /* /                                                                                                                                                                                                                            0.1s
 => exporting to client                                                                                                                                                                                                                  0.2s
 => => copying files 5.61MB                                                                                                                                                                                                              0.1s
 => exporting cache                                                                                                                                                                                                                     56.6s
 => => preparing build cache for export                                                                                                                                                                                                 56.6s
error: failed to receive status: rpc error: code = Unavailable desc = transport is closing

@aiordache aiordache self-assigned this Feb 20, 2020
thaJeztah added a commit to thaJeztah/docker that referenced this issue Jul 8, 2020
….6.4-15-gdc6afa0f)

full diff: moby/buildkit@a7d7b7f...dc6afa0

- solver: avoid recursive loop on cache-export
    - fixes moby/buildkit#1336 --export-cache option crashes buildkitd on custom frontend
    - fixes moby/buildkit#1313 Dockerd / buildkit in a infinite loop and burning cpu
    - fixes / addresses moby#41044 19.03.9 goroutine stack exceeds 1000000000-byte limit
    - fixes / addresses moby#40993 Multistage docker build fails with unexpected EOF

Signed-off-by: Sebastiaan van Stijn <[email protected]>
docker-jenkins pushed a commit to docker-archive/docker-ce that referenced this issue Jul 9, 2020
….6.4-15-gdc6afa0f)

full diff: moby/buildkit@a7d7b7f...dc6afa0

- solver: avoid recursive loop on cache-export
    - fixes moby/buildkit#1336 --export-cache option crashes buildkitd on custom frontend
    - fixes moby/buildkit#1313 Dockerd / buildkit in a infinite loop and burning cpu
    - fixes / addresses moby/moby#41044 19.03.9 goroutine stack exceeds 1000000000-byte limit
    - fixes / addresses moby/moby#40993 Multistage docker build fails with unexpected EOF

Signed-off-by: Sebastiaan van Stijn <[email protected]>
Upstream-commit: e7c2b106ec7785fcb54b1cf80258a2bea25ed020
Component: engine
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants