Merge pull request #12 from mzihlmann/warn-about-cache-misses

warn about potential cache-misses explicitly
This commit is contained in:
mzihlmann 2025-05-26 14:53:25 +01:00 committed by GitHub
commit 176f8f6e0b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 14 additions and 0 deletions

View File

@ -434,6 +434,20 @@ func (s *stageBuilder) build() error {
logrus.Debugf("Build: cache key for command %v %v", command.String(), ck)
// Raise Warnings for commands that are uncacheable
switch command.(type) {
case *commands.RunCommand:
if len(files) == 0 {
logrus.Warn("cache-violation: RUN created an empty layer, this will cause a diff when rebuilding from cache for the first time.")
}
case *commands.WorkdirCommand:
if len(files) > 0 {
logrus.Warn("cache-violation: WORKDIR implicitly created a folder that can't be cached - consider creating it explicitly with RUN instead. https://github.com/GoogleContainerTools/kaniko/issues/3340")
}
case *commands.AddCommand:
logrus.Warn("cache-violation: ADD can't be cached - consider using COPY instead.")
}
// Push layer to cache (in parallel) now along with new config file
if command.ShouldCacheOutput() && !s.opts.NoPushCache {
cacheGroup.Go(func() error {