From 030f38e9f7ae7e268c6cb83b22f6bcd7fb9fb961 Mon Sep 17 00:00:00 2001 From: sakshamkhanna Date: Sun, 31 May 2020 02:02:47 +0530 Subject: [PATCH 1/2] added mutex lock over teePrefix() --- pkg/minikube/command/command_runner.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/minikube/command/command_runner.go b/pkg/minikube/command/command_runner.go index 06be22eb36..b3c3505284 100644 --- a/pkg/minikube/command/command_runner.go +++ b/pkg/minikube/command/command_runner.go @@ -37,6 +37,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 +91,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 From 5baa8b7d3fe8b529714b4fac23a09308416d9316 Mon Sep 17 00:00:00 2001 From: sakshamkhanna Date: Sun, 31 May 2020 02:44:31 +0530 Subject: [PATCH 2/2] fix import --- pkg/minikube/command/command_runner.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/minikube/command/command_runner.go b/pkg/minikube/command/command_runner.go index b3c3505284..7de15d0d5f 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" @@ -39,7 +40,7 @@ var ( OutPrefix = "> " // Mutex protects teePrefix from writing to same log buffer parallelly - logMutex &sync.Mutex + logMutex = &sync.Mutex{} ) // RunResult holds the results of a Runner