progress: make printer ready only after pausing logrus

This fixes a possible race where messages printed directly after calls
to NewPrinter may appear before the printer starts. With this change, we
delay all of the logs until after.

Signed-off-by: Justin Chadwell <me@jedevc.com>
This commit is contained in:
Justin Chadwell 2023-05-11 15:23:36 +01:00
parent 9b07f6510a
commit be6542911f
1 changed files with 1 additions and 2 deletions

View File

@ -120,9 +120,8 @@ func NewPrinter(ctx context.Context, w io.Writer, out console.File, mode string,
pw.logSourceMap = map[digest.Digest]interface{}{}
pw.logMu.Unlock()
close(pw.ready)
resumeLogs := logutil.Pause(logrus.StandardLogger())
close(pw.ready)
// not using shared context to not disrupt display but let is finish reporting errors
pw.warnings, pw.err = progressui.DisplaySolveStatus(ctx, c, w, pw.status, opt.displayOpts...)
resumeLogs()