runfinch / finch

The Finch CLI is an open source client for container development
https://www.runfinch.com
Apache License 2.0
3.51k stars 90 forks source link

Build fails specifying --platform linux/amd64 sometimes "failed to compute cache key", "failed to create snapshot" #801

Closed mil1i closed 7 months ago

mil1i commented 7 months ago

Describe the bug Attempting to build a set of images, some work while others don't. Mostly testing with ubi9/openjdk images.

Specifically happening with registry.access.redhat.com/ubi9/openjdk-11-runtime:latest and registry.access.redhat.com/ubi9/openjdk-11:latest. The build fails on the first RUN command (I tried alterantive first RUN commands as well) with the below error:

 => ERROR [2/3] RUN microdnf update -y   && microdnf clean all   && rm -rf /var/cache/yum                                                                                                                                                                 0.0s
------
 > [2/3] RUN microdnf update -y   && microdnf clean all   && rm -rf /var/cache/yum:
------
Dockerfile:11
--------------------
  10 |
  11 | >>> RUN microdnf update -y \
  12 | >>>   && microdnf clean all \
  13 | >>>   && rm -rf /var/cache/yum
  14 |
--------------------
error: failed to solve: failed to compute cache key: failed to create snapshot: missing parent "finch/34/sha256:c9ac8ed59ad94403e08b349f8fda48ca4a120e90f550186208a4218662062577" bucket: not found
FATA[0000] no image was built
FATA[0001] exit status 1

Exact same Dockerfile + commands builds with both docker and podman.

This does NOT occur on other images though, such as the ubi9/nodejs-16-minimal:latest images. If I remove the --platform linux/amd64 from the build command it is successful, but need to ensure pulling a linux amd64 based image and not a darwin aarch64/arm.

Steps to reproduce

finch build --no-cache -f Dockerfile --platform linux/amd64 -t test:test .
docker build --no-cache -f Dockerfile --platform linux/amd64 -t test:test .
ARG JAVA_VERSION="latest"
ARG JAVA_PROVIDER="ubi9/openjdk-11-runtime"
ARG REGISTRY="registry.access.redhat.com/"

FROM ${REGISTRY}${JAVA_PROVIDER}:${JAVA_VERSION}
USER root

RUN microdnf update -y \
  && microdnf clean all \
  && rm -rf /var/cache/yum

USER me
WORKDIR /home/me

Expected behavior Successful image build completion.

Screenshots or logs

finch build --no-cache -f Dockerfile --platform linux/amd64 -t test:test .
[+] Building 0.2s (5/6)
 => [internal] load build definition from Dockerfile.ubi.java-base                                                                                                                                                                                        0.0s
 => => transferring dockerfile: 1.05kB                                                                                                                                                                                                                    0.0s
 => [internal] load metadata for registry.access.redhat.com/ubi9/openjdk-11-runtime:latest                                                                                                                                                                0.2s
 => [internal] load .dockerignore                                                                                                                                                                                                                         0.0s
 => => transferring context: 2B                                                                                                                                                                                                                           0.0s
 => [1/3] FROM registry.access.redhat.com/ubi9/openjdk-11-runtime:latest@sha256:24f3101434f5460fe28838c0e909f88899918ac1c2062ad754ff333eb96d4491                                                                                                          0.0s
 => => resolve registry.access.redhat.com/ubi9/openjdk-11-runtime:latest@sha256:24f3101434f5460fe28838c0e909f88899918ac1c2062ad754ff333eb96d4491                                                                                                          0.0s
 => => extracting sha256:79c0e7e0bfa04fdbb09d42797804ad021d9db2c4239aedcefefbeb634b91dd15                                                                                                                                                                 0.0s
 => ERROR [2/3] RUN microdnf update -y   && microdnf clean all   && rm -rf /var/cache/yum                                                                                                                                                                 0.0s
------
 > [2/3] RUN microdnf update -y   && microdnf clean all   && rm -rf /var/cache/yum:
------
Dockerfile:11
--------------------
  10 |
  11 | >>> RUN microdnf update -y \
  12 | >>>   && microdnf clean all \
  13 | >>>   && rm -rf /var/cache/yum
  14 |
--------------------
error: failed to solve: failed to compute cache key: failed to create snapshot: missing parent "finch/34/sha256:c9ac8ed59ad94403e08b349f8fda48ca4a120e90f550186208a4218662062577" bucket: not found
FATA[0000] no image was built
FATA[0001] exit status 1

vs docker (rancher/moby):

docker build --no-cache -f Dockerfile --platform linux/amd64 -t test:test .
[+] Building 9.8s (7/7) FINISHED                                                                                                                                                                                                                docker:default
 => [internal] load .dockerignore                                                                                                                                                                                                                         0.0s
 => => transferring context: 2B                                                                                                                                                                                                                           0.0s
 => [internal] load build definition from Dockerfile                                                                                                                                                                                    0.0s
 => => transferring dockerfile: 1.05kB                                                                                                                                                                                                                    0.0s
 => [internal] load metadata for registry.access.redhat.com/ubi9/openjdk-11-runtime:latest                                                                                                                                                                0.0s
 => CACHED [1/3] FROM registry.access.redhat.com/ubi9/openjdk-11-runtime:latest                                                                                                                                                                           0.0s
 => [2/3] RUN microdnf update -y   && microdnf clean all   && rm -rf /var/cache/yum                                                                                                                                                                       9.5s
 => [3/3] WORKDIR /home/me                                                                                                                                                                                                                               0.0s
 => exporting to image                                                                                                                                                                                                                                    0.3s
 => => exporting layers                                                                                                                                                                                                                                   0.3s
 => => writing image sha256:3be8b0bd3a111c0ee7364c056119ea6407d77695d810f57c64a391a03c89649f                                                                                                                                                              0.0s
 => => naming to docker.io/library/test:test
finch --version
finch version v1.1.1

cat ~/.finch/finch.yaml
cpus: 6
memory: 8GiB
snapshotters:
    - soci
creds_helpers:
    - ecr-login
additional_directories:
    - path: /Volumes
vmType: vz
rosetta: true

sw_vers
ProductName:        macOS
ProductVersion:     14.3
BuildVersion:       23D56
M1 PRO
mil1i commented 7 months ago

Ok well, idk nvm. I tested on a separate macbook, and it worked. Came back to the original macbook, uninstalled finch and deleted my ~/.finch dir then reinstalled.

Now the builds are working.

pendo324 commented 7 months ago

We save container metadata in ~/.finch/.disks/<diskname>, something in your container metadata must have been corrupted. Maybe due to a partial download?