diff --git a/pkg/minikube/command/command_runner.go b/pkg/minikube/command/command_runner.go index 06be22eb364a309147d17e6c50ef970fbc8df174..7de15d0d5fae6f221b7b546fa051692a2035884d 100644 --- a/pkg/minikube/command/command_runner.go +++ b/pkg/minikube/command/command_runner.go @@ -25,6 +25,7 @@ import ( "os/exec" "strconv" "strings" + "sync" "time" "github.com/pkg/errors" @@ -37,6 +38,9 @@ var ( // OutPrefix notes output OutPrefix = "> " + + // Mutex protects teePrefix from writing to same log buffer parallelly + logMutex = &sync.Mutex{} ) // RunResult holds the results of a Runner @@ -88,6 +92,9 @@ func (rr RunResult) Output() string { // teePrefix copies bytes from a reader to writer, logging each new line. func teePrefix(prefix string, r io.Reader, w io.Writer, logger func(format string, args ...interface{})) error { + logMutex.Lock() + defer logMutex.Unlock() + scanner := bufio.NewScanner(r) scanner.Split(bufio.ScanBytes) var line bytes.Buffer