Bump github.com/containers/storage from 1.32.3 to 1.32.5

Bumps [github.com/containers/storage](https://github.com/containers/storage) from 1.32.3 to 1.32.5.
- [Release notes](https://github.com/containers/storage/releases)
- [Changelog](https://github.com/containers/storage/blob/main/docs/containers-storage-changes.md)
- [Commits](https://github.com/containers/storage/compare/v1.32.3...v1.32.5)

---
updated-dependencies:
- dependency-name: github.com/containers/storage
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
Daniel J Walsh
2021-06-25 10:02:34 -04:00
parent 793063e086
commit 05f39af5bd
78 changed files with 661 additions and 903 deletions

View File

@@ -133,11 +133,11 @@ func BuildDockerfiles(ctx context.Context, store storage.Store, options define.B
// pre-process Dockerfiles with ".in" suffix
if strings.HasSuffix(dfile, ".in") {
pData, err := preprocessContainerfileContents(dfile, data, options.ContextDirectory)
pData, err := preprocessContainerfileContents(logger, dfile, data, options.ContextDirectory)
if err != nil {
return "", nil, err
}
data = *pData
data = ioutil.NopCloser(pData)
}
dockerfiles = append(dockerfiles, data)
@@ -208,47 +208,34 @@ func warnOnUnsetBuildArgs(logger *logrus.Logger, node *parser.Node, args map[str
// preprocessContainerfileContents runs CPP(1) in preprocess-only mode on the input
// dockerfile content and will use ctxDir as the base include path.
//
// Note: we cannot use cmd.StdoutPipe() as cmd.Wait() closes it.
func preprocessContainerfileContents(containerfile string, r io.Reader, ctxDir string) (rdrCloser *io.ReadCloser, err error) {
cppPath := "/usr/bin/cpp"
if _, err = os.Stat(cppPath); err != nil {
func preprocessContainerfileContents(logger *logrus.Logger, containerfile string, r io.Reader, ctxDir string) (stdout io.Reader, err error) {
cppCommand := "cpp"
cppPath, err := exec.LookPath(cppCommand)
if err != nil {
if os.IsNotExist(err) {
err = errors.Errorf("error: %s support requires %s to be installed", containerfile, cppPath)
}
return nil, err
}
stdout := bytes.Buffer{}
stderr := bytes.Buffer{}
stdoutBuffer := bytes.Buffer{}
stderrBuffer := bytes.Buffer{}
cmd := exec.Command(cppPath, "-E", "-iquote", ctxDir, "-traditional", "-undef", "-")
cmd.Stdout = &stdout
cmd.Stderr = &stderr
pipe, err := cmd.StdinPipe()
if err != nil {
return nil, err
}
defer pipe.Close()
cmd.Stdin = r
cmd.Stdout = &stdoutBuffer
cmd.Stderr = &stderrBuffer
if err = cmd.Start(); err != nil {
return nil, err
return nil, errors.Wrapf(err, "preprocessing %s", containerfile)
}
if _, err = io.Copy(pipe, r); err != nil {
return nil, err
}
pipe.Close()
if err = cmd.Wait(); err != nil {
if stdout.Len() == 0 {
return nil, errors.Wrapf(err, "error pre-processing Dockerfile")
if stderrBuffer.Len() != 0 {
logger.Warnf("Ignoring %s\n", stderrBuffer.String())
}
if stdoutBuffer.Len() == 0 {
return nil, errors.Wrapf(err, "error preprocessing %s: preprocessor produced no output", containerfile)
}
logrus.Warnf("Ignoring %s\n", stderr.String())
}
rc := ioutil.NopCloser(bytes.NewReader(stdout.Bytes()))
return &rc, nil
return &stdoutBuffer, nil
}

View File

@@ -71,7 +71,7 @@ type Executor struct {
output string
outputFormat string
additionalTags []string
log func(format string, args ...interface{})
log func(format string, args ...interface{}) // can be nil
in io.Reader
out io.Writer
err io.Writer
@@ -116,6 +116,7 @@ type Executor struct {
stagesSemaphore *semaphore.Weighted
jobs int
logRusage bool
rusageLogFile io.Writer
imageInfoLock sync.Mutex
imageInfoCache map[string]imageTypeAndHistoryAndDiffIDs
fromOverride string
@@ -183,6 +184,19 @@ func NewExecutor(logger *logrus.Logger, store storage.Store, options define.Buil
writer = ioutil.Discard
}
var rusageLogFile io.Writer
if options.LogRusage && !options.Quiet {
if options.RusageLogFile == "" {
rusageLogFile = options.Out
} else {
rusageLogFile, err = os.OpenFile(options.RusageLogFile, os.O_TRUNC|os.O_CREATE|os.O_WRONLY, 0644)
if err != nil {
return nil, err
}
}
}
exec := Executor{
logger: logger,
stages: make(map[string]*StageExecutor),
@@ -241,6 +255,7 @@ func NewExecutor(logger *logrus.Logger, store storage.Store, options define.Buil
terminatedStage: make(map[string]struct{}),
jobs: jobs,
logRusage: options.LogRusage,
rusageLogFile: rusageLogFile,
imageInfoCache: make(map[string]imageTypeAndHistoryAndDiffIDs),
fromOverride: options.From,
manifest: options.Manifest,
@@ -252,15 +267,6 @@ func NewExecutor(logger *logrus.Logger, store storage.Store, options define.Buil
if exec.out == nil {
exec.out = os.Stdout
}
if exec.log == nil {
stepCounter := 0
exec.log = func(format string, args ...interface{}) {
stepCounter++
prefix := fmt.Sprintf("STEP %d: ", stepCounter)
suffix := "\n"
fmt.Fprintf(exec.out, prefix+format+suffix, args...)
}
}
for arg := range options.Args {
if _, isBuiltIn := builtinAllowedBuildArgs[arg]; !isBuiltIn {
@@ -295,6 +301,7 @@ func (b *Executor) startStage(ctx context.Context, stage *imagebuilder.Stage, st
stageExec := &StageExecutor{
ctx: ctx,
executor: b,
log: b.log,
index: stage.Position,
stages: stages,
name: stage.Name,
@@ -426,6 +433,25 @@ func (b *Executor) buildStage(ctx context.Context, cleanupStages map[int]*StageE
b.stagesLock.Lock()
stageExecutor := b.startStage(ctx, &stage, stages, output)
if stageExecutor.log == nil {
stepCounter := 0
stageExecutor.log = func(format string, args ...interface{}) {
prefix := ""
if len(stages) > 1 {
prefix += fmt.Sprintf("[%d/%d] ", stageIndex+1, len(stages))
}
if !strings.HasPrefix(format, "COMMIT") {
stepCounter++
prefix += fmt.Sprintf("STEP %d", stepCounter)
if stepCounter <= len(stage.Node.Children)+1 {
prefix += fmt.Sprintf("/%d", len(stage.Node.Children)+1)
}
prefix += ": "
}
suffix := "\n"
fmt.Fprintf(stageExecutor.executor.out, prefix+format+suffix, args...)
}
}
b.stagesLock.Unlock()
// If this a single-layer build, or if it's a multi-layered
@@ -519,6 +545,14 @@ func (b *Executor) Build(ctx context.Context, stages imagebuilder.Stages) (image
}
}
cleanupImages = nil
if b.rusageLogFile != nil && b.rusageLogFile != b.out {
// we deliberately ignore the error here, as this
// function can be called multiple times
if closer, ok := b.rusageLogFile.(interface{ Close() error }); ok {
closer.Close()
}
}
return lastErr
}

View File

@@ -49,6 +49,7 @@ import (
type StageExecutor struct {
ctx context.Context
executor *Executor
log func(format string, args ...interface{})
index int
stages imagebuilder.Stages
name string
@@ -527,7 +528,7 @@ func (s *StageExecutor) prepare(ctx context.Context, from string, initializeIBCo
if initializeIBConfig && rebase {
logrus.Debugf("FROM %#v", displayFrom)
if !s.executor.quiet {
s.executor.log("FROM %s", displayFrom)
s.log("FROM %s", displayFrom)
}
}
@@ -703,8 +704,8 @@ func (s *StageExecutor) Execute(ctx context.Context, base string) (imgID string,
fmt.Fprintf(s.executor.out, "error gathering resource usage information: %v\n", err)
return
}
if !s.executor.quiet && s.executor.logRusage {
fmt.Fprintf(s.executor.out, "%s\n", rusage.FormatDiff(usage.Subtract(resourceUsage)))
if s.executor.rusageLogFile != nil {
fmt.Fprintf(s.executor.rusageLogFile, "%s\n", rusage.FormatDiff(usage.Subtract(resourceUsage)))
}
resourceUsage = usage
}
@@ -740,7 +741,7 @@ func (s *StageExecutor) Execute(ctx context.Context, base string) (imgID string,
}
logrus.Debugf(commitMessage)
if !s.executor.quiet {
s.executor.log(commitMessage)
s.log(commitMessage)
}
}
logCacheHit := func(cacheID string) {
@@ -798,7 +799,7 @@ func (s *StageExecutor) Execute(ctx context.Context, base string) (imgID string,
}
logrus.Debugf("Parsed Step: %+v", *step)
if !s.executor.quiet {
s.executor.log("%s", step.Original)
s.log("%s", step.Original)
}
// Check if there's a --from if the step command is COPY.