Skip to content

Commit

Permalink
Merge pull request #892 from cvgw/u/cvgw/dont-break-keep-collecting-c…
Browse files Browse the repository at this point in the history
…ache-keys

Don't exit optimize early; record last cachekey
  • Loading branch information
cvgw authored Nov 28, 2019
2 parents ee376c7 + 54635c3 commit 034ac9e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pkg/executor/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func (s *stageBuilder) optimize(compositeKey CompositeCache, cfg v1.Config) erro
layerCache := &cache.RegistryCache{
Opts: s.opts,
}

stopCache := false
// Possibly replace commands with their cached implementations.
// We walk through all the commands, running any commands that only operate on metadata.
// We throw the metadata away after, but we need it to properly track command dependencies
Expand All @@ -167,13 +167,14 @@ func (s *stageBuilder) optimize(compositeKey CompositeCache, cfg v1.Config) erro
return err
}
s.finalCacheKey = ck
if command.ShouldCacheOutput() {
if command.ShouldCacheOutput() && !stopCache {
img, err := layerCache.RetrieveLayer(ck)
if err != nil {
logrus.Debugf("Failed to retrieve layer: %s", err)
logrus.Infof("No cached layer found for cmd %s", command.String())
logrus.Debugf("Key missing was: %s", compositeKey.Key())
break
stopCache = true
continue
}

if cacheCmd := command.CacheCommand(img); cacheCmd != nil {
Expand Down

0 comments on commit 034ac9e

Please sign in to comment.