kaniko icon indicating copy to clipboard operation
kaniko copied to clipboard

Missing lock in cache feature

Open senayuki opened this issue 2 years ago • 2 comments

In my workflow, I first use Kaniko Warmer to cache the base image specified in the 'FROM' instruction, and then proceed with a no-push Kaniko build. However, during this process, I have noticed that the cache feature lacks a file lock. This not only results in redundant image downloads but also leads to errors during the build process with the base image.

I have observed that the cache feature in Kaniko writes to the cache directory after the image download is complete. This creates a situation where multiple concurrent caching tasks perceive the cache was missed, and download the image separately. As a result, some tasks finish faster and proceed to the Kaniko build stage. However, slower caching tasks may complete later and overwrite the existing cache files, that the cache is already in use.

I believe it caused the error during unpacking: error building image: error building stage: failed to get filesystem from image: unexpected EOF

I think a lock is essential for any robust caching feature. I would like to discuss whether the lock feature is necessary and consider the possibility of adding it to Kaniko.

senayuki avatar Jun 20 '23 06:06 senayuki

Hey, anything new about this? we also encounter this.

iTaybb avatar Oct 12 '23 08:10 iTaybb

This pops up every few weeks in my CI pipelines, when multiple kaniko jobs are running on the same host (thus sharing a cache). Is there a known workaround?

DavidAntliff avatar Feb 12 '25 20:02 DavidAntliff