Merge pull request #892 from cvgw/u/cvgw/dont-break-keep-collecting-cache-keys

Don't exit optimize early; record last cachekey
This commit is contained in:
Cole Wippern 2019-11-27 17:26:39 -08:00 committed by GitHub
commit 034ac9e258
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 3 deletions

View File

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