Open jamil-s opened 1 year ago
@aaron-prindle I'm not so sure this is related to #1525, this seems like a very specific bug.
It looks to me that this is the part that is responsible on creating the id used for the cache layer: https://github.com/GoogleContainerTools/kaniko/blob/98df8ebfc7834a720c83b81bd0b1d54f4f480477/pkg/executor/build.go#L254
Note that it takes into consideration the command, files, build args and environment, but not other implicit options, like architecture in this case. I imagine this issue can be reproduced with other conditions as well, differences between build runs that are not part of the aforementioned components.
There is however an easy workaround for this issue, I just passed the architechture as a build arg and set it as an ENV
command, which is being taken into consideration when creating the cache layer:
ARG TARGETARCH
ENV ARCH=$TARGETARCH
I chose TARGETARCH
to make it compatible with buildkit syntax as well, which passes this arguments implicitly: https://docs.docker.com/reference/dockerfile/#automatic-platform-args-in-the-global-scope
Actual behavior With caching enabled, we have seen arm64 builds fetch artifacts for amd64 architecture builds.
Expected behavior Cache is architecture aware.
To Reproduce Steps to reproduce the behavior:
--snapshot-mode=redo --cache=true --customPlatform=linux/amd64
and similarly for--customPlatform=linux/arm64
Notice cache hits for different architecture
Triage Notes for the Maintainers
--cache
flag