-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
cache-from working unreliably #1388
Comments
Could you provide a minimal Dockerfile to reproduce the issue? |
Sorry for letting you wait - right now not going the extra step to create a repo-example for this. We debugged this and there is an issue with the cache 100%, removing buildkit here using legacy build fixed the cache issue right away. All we changed was
And everything works as design and expected - no cache layer issues, no fuzziness and no "suddenly outdated container". If of any interest, we are building under azure ( ubuntu-latest ) using the exact steps shown above. |
+1 on this @thaJeztah I enabled We have a monorepo containing several artifacts and all of them have this dockerfile:
This is what happened:
With
This caused a minor incident, I had to disable |
@epk i disabled BUILDKIT and using |
In our case the multi-stage dockerfiles don't really benefit from |
@epk Don't understand your example. This seems exactly expected. Both images use same code to install |
The build for binary B is copying binary A
What's worth pointing out here is, these are static dockerfiles, except for the |
@epk hmm, this doesn't make much sense to me and needs a runnable reproduction. The remote cache was not applied to Something like string |
I spent quite some time trying to figure out why my buildkit images didn't have the files I copied and I reproduced the issue here: https://github.com/gaganpreet/buildkit-wrong-image/. It does not seem related to #1368 since there's only docker image being built here. There's a Github CI action which runs in the repository and runs test.py within the built Docker image. First run (no cache):
Successfully executes test.py at the end. Second run (with cache):
The cached build fails at the last step:
|
I have also been encountering the issue where In the CI If I rerun the same CI job, it will find the previous image and rebuild the same image using On my machine Example of the size after each build:
Image 2 (cache from
|
@gaganpreet can you switch your repro to public repository. I can't see where the cache is being loaded from or verify its contents. |
@tonistiigi I now reproduced the issue in a public repository on Dockerhub. I also added a bash script in my code repository, detailing the exact set of steps I ran to produce the two images. I suspect the issue has something to do with the build args, since I tried to reproduce it by reducing the steps in the Dockerfile, but wasn't able to. Edit: I also redirected the build output while running the script to a file. |
fix in #1568 , please verify if you have hit this |
Hi @tonistiigi don't know if you still need more examples but I was able to reproduce our issue in this repo: https://gitlab.com/AshDevFr/buildkit_exp Really simple example with fake files in it. This pipeline is running when no cache already exist: https://gitlab.com/AshDevFr/buildkit_exp/-/pipelines/167184239 |
@AshDevFr Please check with the patch above and report back if it didn't fix the issue. The fix is based on the repro from @gaganpreet |
full diff: moby/buildkit@dc6afa0...4cb720e - contenthash: ignore system and security xattrs in calculation - fixes moby/buildkit#1330 COPY cache not re-used depending on SELinux environment - fixes moby#39003 (comment) - contenthash: allow security.capability in cache checksum - inline cache: fix handling of duplicate blobs - fixes moby/buildkit#1388 cache-from working unreliably Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
full diff: moby/buildkit@dc6afa0...4cb720e - contenthash: ignore system and security xattrs in calculation - fixes moby/buildkit#1330 COPY cache not re-used depending on SELinux environment - fixes moby/moby#39003 (comment) - contenthash: allow security.capability in cache checksum - inline cache: fix handling of duplicate blobs - fixes moby/buildkit#1388 cache-from working unreliably Signed-off-by: Sebastiaan van Stijn <github@gone.nl> Upstream-commit: 23d47bd12eaeeb93bbc4e9e80020c811e9eb2980 Component: engine
@AshDevFr Have you been able to work around it, other than disabling Buildkit? We are fighting it today :( |
I use Drone CI and also encountered the problem. Is there a fix? |
This specific case was fixed; if you encounter an issue, please open a new ticket instead with details and exact steps to reproduce. |
I'am building an image
foo/app
with the following aspects::build-latest
,:build-latest-master
,build-nr-<buildID>
i build using
Oddly, every time the cache is used, the produced image does not include the right layers, not the one that have been cached - it must be some very old or cut of layer cache.
The second odd thing is, that the cache is used only every second build. This means, that every second build my actual image is not broken but also it is not cached at all, and then my image is outdated (but cache is used).
Could it be that the layer cache is never updated in the registry at all even though i push
docker push foo/app:build-latest-master
since somehow the inline cache is only attached tofoo/app:build-nr-$CI_BUILDNR
and cannot be "tagged and pushed using a diffrent tag name" ?Let me know if you need anything else or more specific to understand the issue
The text was updated successfully, but these errors were encountered: