Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't generate cache key, if not caching builds. #1194

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions integration/dockerfiles/Dockerfile_test_complex_substitution
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
FROM docker.io/library/busybox:latest@sha256:afe605d272837ce1732f390966166c2afff5391208ddd57de10942748694049d
RUN echo ${s%s}
32 changes: 18 additions & 14 deletions pkg/executor/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,9 +334,11 @@ func (s *stageBuilder) build() error {
return errors.Wrap(err, "failed to get files used from context")
}

*compositeKey, err = s.populateCompositeKey(command, files, *compositeKey, s.args, s.cf.Config.Env)
if err != nil {
return err
if s.opts.Cache {
*compositeKey, err = s.populateCompositeKey(command, files, *compositeKey, s.args, s.cf.Config.Env)
if err != nil && s.opts.Cache {
return err
}
}

logrus.Info(command.String())
Expand Down Expand Up @@ -372,19 +374,21 @@ func (s *stageBuilder) build() error {
return errors.Wrap(err, "failed to take snapshot")
}

logrus.Debugf("build: composite key for command %v %v", command.String(), compositeKey)
ck, err := compositeKey.Hash()
if err != nil {
return errors.Wrap(err, "failed to hash composite key")
}
if s.opts.Cache {
logrus.Debugf("build: composite key for command %v %v", command.String(), compositeKey)
ck, err := compositeKey.Hash()
if err != nil {
return errors.Wrap(err, "failed to hash composite key")
}

logrus.Debugf("build: cache key for command %v %v", command.String(), ck)
logrus.Debugf("build: cache key for command %v %v", command.String(), ck)

// Push layer to cache (in parallel) now along with new config file
if s.opts.Cache && command.ShouldCacheOutput() {
cacheGroup.Go(func() error {
return s.pushLayerToCache(s.opts, ck, tarPath, command.String())
})
// Push layer to cache (in parallel) now along with new config file
if command.ShouldCacheOutput() {
cacheGroup.Go(func() error {
return s.pushLayerToCache(s.opts, ck, tarPath, command.String())
})
}
}
if err := s.saveSnapshotToImage(command.String(), tarPath); err != nil {
return errors.Wrap(err, "failed to save snapshot to image")
Expand Down