From 0e4d69b9606ccca5ccc1c5ce2c0122b50f2c5720 Mon Sep 17 00:00:00 2001 From: Martin Zihlmann Date: Sun, 25 May 2025 21:59:40 +0100 Subject: [PATCH] warn about potential cache-misses explicitly --- pkg/executor/build.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkg/executor/build.go b/pkg/executor/build.go index 86a14e090..7e7a3d012 100644 --- a/pkg/executor/build.go +++ b/pkg/executor/build.go @@ -434,6 +434,13 @@ func (s *stageBuilder) build() error { logrus.Debugf("Build: cache key for command %v %v", command.String(), ck) + // Raise Warnings for commands that are uncacheable + if _, ok := command.(*commands.WorkdirCommand); ok { + logrus.Warn("cache-violation: WORKDIR implicitly creates a folder that can't be cached - consider creating it explicitly with RUN instead.\nhttps://github.com/GoogleContainerTools/kaniko/issues/3340") + } + if _, ok := command.(*commands.AddCommand); ok { + logrus.Warn("cache-violation: ADD can't be cached - consider using COPY instead.\nhttps://github.com/GoogleContainerTools/kaniko/issues/3340") + } // Push layer to cache (in parallel) now along with new config file if command.ShouldCacheOutput() && !s.opts.NoPushCache { cacheGroup.Go(func() error {