warn about potential cache-misses explicitly

This commit is contained in:
Martin Zihlmann 2025-05-25 21:59:40 +01:00
parent e4a5153d8b
commit 0e4d69b960
No known key found for this signature in database
GPG Key ID: 0F7784F41354DE99
1 changed files with 7 additions and 0 deletions

View File

@ -434,6 +434,13 @@ func (s *stageBuilder) build() error {
logrus.Debugf("Build: cache key for command %v %v", command.String(), ck) 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 // Push layer to cache (in parallel) now along with new config file
if command.ShouldCacheOutput() && !s.opts.NoPushCache { if command.ShouldCacheOutput() && !s.opts.NoPushCache {
cacheGroup.Go(func() error { cacheGroup.Go(func() error {