Skip to content

Commit

Permalink
Execute commands in optimize before updating the composite key. Fixes G…
Browse files Browse the repository at this point in the history
…oogleContainerTools#1910

This seems to be required because otherwise build & optimize calculate
different caches keys.
  • Loading branch information
apollo13 committed Feb 2, 2022
1 parent bde9043 commit 4857eee
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions pkg/executor/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,13 @@ func (s *stageBuilder) optimize(compositeKey CompositeCache, cfg v1.Config) erro
return errors.Wrap(err, "failed to get files used from context")
}

// Mutate the config for any commands that require it.
if command.MetadataOnly() {
if err := command.ExecuteCommand(&cfg, s.args); err != nil {
return err
}
}

compositeKey, err = s.populateCompositeKey(command, files, compositeKey, s.args, cfg.Env)
if err != nil {
return err
Expand Down Expand Up @@ -272,13 +279,6 @@ func (s *stageBuilder) optimize(compositeKey CompositeCache, cfg v1.Config) erro
s.cmds[i] = cacheCmd
}
}

// Mutate the config for any commands that require it.
if command.MetadataOnly() {
if err := command.ExecuteCommand(&cfg, s.args); err != nil {
return err
}
}
}
return nil
}
Expand Down

0 comments on commit 4857eee

Please sign in to comment.