kaniko: when replacing a folder by symlink : i get corrupt images when pulling : failed to mknod("somefile", S_IFCHR, 0): no such file or directory

Actual behavior

When replacing a folder by symlink i get corrupt images , docker pull will fail with : Failed to register layer: Error processing tar file(exit status 1): failed to mknod(“/etc/fail2ban/action.d”, S_IFCHR, 0): no such file or directory

Expected behavior Be able to pull the image

To Reproduce

The error doesn’t seems t happen with every files/folder. I tried disabling all caches to be sure

The build/pull works when using the dockerfile directly with docker build command The build works with kaniko but appears corrupt as i can t pull it

Additional Information

  • Dockerfile

FROM quay.io/centos/centos:stream9 RUN dnf -y update && dnf -y install systemd RUN /usr/bin/systemctl mask systemd-logind && /usr/bin/systemctl mask systemd-hostnamed && /usr/bin/systemctl mask dbus- RUN ln -s /data/git_conf/conf/systemd/journald.conf.d /etc/systemd/journald.conf.d RUN dnf install -y rsyslog && mv -f /etc/rsyslog.d /etc/rsyslog.d.orig && ln -s /data/git_conf/conf/rsyslog/rsyslog.d /etc/rsyslog.d RUN systemctl enable rsyslog RUN dnf -y install procps net-tools STOPSIGNAL SIGRTMIN+3 CMD [ “/sbin/init” ]

This one build and pull fine even with the the broken symlink that will lead to a mounted volume set in docker compose

FROM previousdockerimage RUN dnf -y update && dnf install -y epel-release && dnf -y install fail2ban && systemctl enable fail2ban && dnf clean all RUN rm -rf /etc/fail2ban && ln -s /data/git_conf/conf/fail2ban /etc/fail2ban STOPSIGNAL SIGRTMIN+3 EXPOSE 22 CMD [ “/sbin/init” ]

When pulling this one errors with Error processing tar file(exit status 1): failed to mknod(“/etc/fail2ban/action.d”, S_IFCHR, 0): no such file or directory The folder action.d isn’t supposed to be there anymore.

  • Build Context

Nothing special, here is the gitlab ci/cd, but i get the same error running it manually

make_fail2ban: stage: make_fail2ban image: name: gcr.io/kaniko-project/executor:v1.9.1-debug entrypoint: [“”] script: - /kaniko/executor -c /workspace --dockerfile https://mygitlab/mydockerfile --destination “${CI_REGISTRY_IMAGE}/fail2ban:${CI_COMMIT_TAG}”

  • Kaniko Image (fully qualified with digest)

gcr.io/kaniko-project/executor:v1.9.1-debug sha256:ac169723b2076f9d5804f4bc05c98397e286da6fdcdd5a09fdc179f06ccb3be1

Triage Notes for the Maintainers

Description Yes/No
Please check if this a new feature you are proposing
  • - [ ]
Please check if the build works in docker but not in kaniko
  • - [ ]
Please check if this error is seen when you use --cache flag
  • - [ ]
Please check if your dockerfile is a multistage dockerfile
  • - [ ]

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 22 (13 by maintainers)

Commits related to this issue

Most upvoted comments

Oopsie. I think I know what the problem is and I’ll prepare a fix

Hmm not sure about, I refactored the strange whiteout files once to be clearer, there was lots of old stuff laying around, but I think that commit came afterwards? My refactor was about to track correctly deleted and new files for each layer and act on these two lists later in the process when the tar for the layer is created. #2066 I dont have time this week, maybe I can have a look at it next week.

Info: the line RUN rm -Rfv /a && ln -sf /b /a should create a whiteout (thats a deletion of a file) file and at the same time in the next command create a normal symlink a -> /b and I suspect these two things do not play nice with each other. I suspect that maybe there is no creation of a new file a detected because of symlink following and the whiteout for a is not discarded, resulting in a whiteout and a writing of the symlink into the tar because the tar mechanism is kind of different (???), something along these lines

@andreasf Found some time to test your fixed image (docker.io/andreasfleig/kaniko-executor:debug) with the Dockerfile which lead me here and it fixes the issue for me 🎉

I specified a different registry for cache and it works with the cache as well. So i guess a bad layer was still in cache. (in gitlab registry deletion is not instant).

@andreasf : Sorry I was mistaken, everything works fine, /a symlink and /b are added to the add list in the last layer, all seams correct.

Minimal reproducer:

Dockerfile

FROM busybox

RUN mkdir /a /b /c && echo a > /a/a
RUN rm -Rfv /a && ln -sf /b /a

Build with:

podman run --rm -ti --volume $PWD:/workspace gcr.io/kaniko-project/executor:v1.9.1-debug --tar-path /workspace/out.tar --no-push --destination dummy:latest

The resulting tar file cannot be loaded into podman/docker:

$ podman --debug load -i out.tar
INFO[0000] podman filtering at log level debug
DEBU[0000] Called load.PersistentPreRunE(podman --debug load -i out.tar)
DEBU[0000] Merged system config "/usr/share/containers/containers.conf"
DEBU[0000] Using conmon: "/usr/bin/conmon"
DEBU[0000] Initializing boltdb state at /home/tobias/.local/share/containers/storage/libpod/bolt_state.db
DEBU[0000] Using graph driver overlay
DEBU[0000] Using graph root /home/tobias/.local/share/containers/storage
DEBU[0000] Using run root /tmp/containers-user-1000/containers
DEBU[0000] Using static dir /home/tobias/.local/share/containers/storage/libpod
DEBU[0000] Using tmp dir /tmp/podman-run-1000/libpod/tmp
DEBU[0000] Using volume path /home/tobias/.local/share/containers/storage/volumes
DEBU[0000] Set libpod namespace to ""
DEBU[0000] Not configuring container store
DEBU[0000] Initializing event backend file
DEBU[0000] Configured OCI runtime runsc initialization failed: no valid executable found for OCI runtime runsc: invalid argument
DEBU[0000] Configured OCI runtime krun initialization failed: no valid executable found for OCI runtime krun: invalid argument
DEBU[0000] Configured OCI runtime runj initialization failed: no valid executable found for OCI runtime runj: invalid argument
DEBU[0000] Configured OCI runtime kata initialization failed: no valid executable found for OCI runtime kata: invalid argument
DEBU[0000] Using OCI runtime "/usr/bin/crun"
INFO[0000] Setting parallel job count to 7
INFO[0000] podman filtering at log level debug
DEBU[0000] Called load.PersistentPreRunE(podman --debug load -i out.tar)
DEBU[0000] Merged system config "/usr/share/containers/containers.conf"
DEBU[0000] Using conmon: "/usr/bin/conmon"
DEBU[0000] Initializing boltdb state at /home/tobias/.local/share/containers/storage/libpod/bolt_state.db
DEBU[0000] Overriding run root "/tmp/podman-run-1000/containers" with "/tmp/containers-user-1000/containers" from database
DEBU[0000] Using graph driver overlay
DEBU[0000] Using graph root /home/tobias/.local/share/containers/storage
DEBU[0000] Using run root /tmp/containers-user-1000/containers
DEBU[0000] Using static dir /home/tobias/.local/share/containers/storage/libpod
DEBU[0000] Using tmp dir /tmp/podman-run-1000/libpod/tmp
DEBU[0000] Using volume path /home/tobias/.local/share/containers/storage/volumes
DEBU[0000] Set libpod namespace to ""
DEBU[0000] [graphdriver] trying provided driver "overlay"
DEBU[0000] Cached value indicated that overlay is supported
DEBU[0000] Cached value indicated that overlay is supported
DEBU[0000] Cached value indicated that metacopy is not being used
DEBU[0000] Cached value indicated that native-diff is usable
DEBU[0000] backingFs=extfs, projectQuotaSupported=false, useNativeDiff=true, usingMetacopy=false
DEBU[0000] Initializing event backend file
DEBU[0000] Configured OCI runtime runsc initialization failed: no valid executable found for OCI runtime runsc: invalid argument
DEBU[0000] Configured OCI runtime krun initialization failed: no valid executable found for OCI runtime krun: invalid argument
DEBU[0000] Configured OCI runtime runj initialization failed: no valid executable found for OCI runtime runj: invalid argument
DEBU[0000] Configured OCI runtime kata initialization failed: no valid executable found for OCI runtime kata: invalid argument
DEBU[0000] Using OCI runtime "/usr/bin/crun"
INFO[0000] Setting parallel job count to 7
DEBU[0000] Loading image from "out.tar"
DEBU[0000] -> Attempting to load "out.tar" as an OCI directory
DEBU[0000] Normalized platform linux/amd64 to {amd64 linux  [] }
DEBU[0000] parsed reference into "[overlay@/home/tobias/.local/share/containers/storage+/tmp/containers-user-1000/containers]localhost/out.tar:latest"
DEBU[0000] Copying source image out.tar: to destination image [overlay@/home/tobias/.local/share/containers/storage+/tmp/containers-user-1000/containers]localhost/out.tar:latest
DEBU[0000] Error loading out.tar (oci): initializing source oci:out.tar:: open out.tar/index.json: not a directory
DEBU[0000] -> Attempting to load "out.tar" as an OCI archive
DEBU[0000] Normalized platform linux/amd64 to {amd64 linux  [] }
DEBU[0000] Error deleting temporary directory: <nil>
DEBU[0000] Error loading out.tar (oci-archive): loading index: open /var/tmp/oci784683435/index.json: no such file or directory
DEBU[0000] -> Attempting to load "out.tar" as a Docker archive
DEBU[0000] No compression detected
DEBU[0000] Normalized platform linux/amd64 to {amd64 linux  [] }
DEBU[0000] parsed reference into "[overlay@/home/tobias/.local/share/containers/storage+/tmp/containers-user-1000/containers]localhost/dummy:latest"
DEBU[0000] Copying source image out.tar:docker.io/library/dummy:latest to destination image [overlay@/home/tobias/.local/share/containers/storage+/tmp/containers-user-1000/containers]localhost/dummy:latest
DEBU[0000] Using blob info cache at /home/tobias/.local/share/containers/cache/blob-info-cache-v1.boltdb
DEBU[0000] Detected compression format gzip
DEBU[0000] Detected compression format gzip
DEBU[0000] Detected compression format gzip
DEBU[0000] IsRunningImageAllowed for image docker-archive:
DEBU[0000]  Using default policy section
DEBU[0000]  Requirement 0: allowed
DEBU[0000] Overall: allowed
Getting image source signatures
DEBU[0000] Manifest has MIME type application/vnd.docker.distribution.manifest.v2+json, ordered candidate list [application/vnd.docker.distribution.manifest.v2+json, application/vnd.docker.distribution.manifest.v1+prettyjws, application/vnd.oci.image.manifest.v1+json, application/vnd.docker.distribution.manifest.v1+json]
DEBU[0000] ... will first try using the original manifest unmodified
DEBU[0000] Checking if we can reuse blob sha256:b16b83b3d83f480e19392177a22e7b8525a8127c0d724da41a041c595cd06025: general substitution = true, compression for MIME type "application/vnd.docker.image.rootfs.diff.tar.gzip" = true
DEBU[0000] Checking if we can reuse blob sha256:b64792c17e4ad443d16b218afb3a8f5d03ca0f4ec49b11c1a7aebe17f6c3c1d2: general substitution = true, compression for MIME type "application/vnd.docker.image.rootfs.diff.tar.gzip" = true
DEBU[0000] Checking if we can reuse blob sha256:d5c80c0fdbc4e9e39c554da5acba3e6b069facc36da2715c704ccb10c3c9c069: general substitution = true, compression for MIME type "application/vnd.docker.image.rootfs.diff.tar.gzip" = true
DEBU[0000] Skipping blob sha256:b64792c17e4ad443d16b218afb3a8f5d03ca0f4ec49b11c1a7aebe17f6c3c1d2 (already present):
DEBU[0000] Skipping blob sha256:d5c80c0fdbc4e9e39c554da5acba3e6b069facc36da2715c704ccb10c3c9c069 (already present):
DEBU[0000] Detected compression format gzip
DEBU[0000] No compression detected
DEBU[0000] Using original blob without modification
Copying blob b16b83b3d83f done
Copying blob b64792c17e4a skipped: already exists
Copying blob d5c80c0fdbc4 skipped: already exists
DEBU[0000] Cached value indicated that idmapped mounts for overlay are not supported
DEBU[0000] Check for idmapped mounts support
DEBU[0000] Applying tar in /home/tobias/.local/share/containers/storage/overlay/f3a8ff84ddd4014d5adb37278167168c82798082c2b34a1da51e1dd8f29ccad3/diff
DEBU[0000] Error loading out.tar (docker-archive): writing blob: adding layer with blob "sha256:b16b83b3d83f480e19392177a22e7b8525a8127c0d724da41a041c595cd06025": processing tar file(no such file or directory): exit status 1
DEBU[0000] -> Attempting to load "out.tar" as a Docker dir
DEBU[0000] Normalized platform linux/amd64 to {amd64 linux  [] }
DEBU[0000] Error loading out.tar (dir): open out.tar/manifest.json: not a directory
Error: payload does not match any of the supported image formats:
 * oci: initializing source oci:out.tar:: open out.tar/index.json: not a directory
 * oci-archive: loading index: open /var/tmp/oci784683435/index.json: no such file or directory
 * docker-archive: writing blob: adding layer with blob "sha256:b16b83b3d83f480e19392177a22e7b8525a8127c0d724da41a041c595cd06025": processing tar file(no such file or directory): exit status 1
 * dir: open out.tar/manifest.json: not a directory