From b17834c96bfd7d75974d9bbc41a442ebf030a82b Mon Sep 17 00:00:00 2001 From: Steven Powell Date: Tue, 14 Dec 2021 13:46:52 -0800 Subject: [PATCH 1/3] added env to suppress Docker performance messages --- hack/jenkins/common.ps1 | 1 + hack/jenkins/common.sh | 1 + pkg/drivers/kic/oci/cli_runner.go | 15 ++++++++++++++- site/content/en/docs/handbook/config.md | 6 ++---- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/hack/jenkins/common.ps1 b/hack/jenkins/common.ps1 index cdb06a80e4..e54e6b3dc9 100644 --- a/hack/jenkins/common.ps1 +++ b/hack/jenkins/common.ps1 @@ -29,6 +29,7 @@ function Write-GithubStatus { $env:SHORT_COMMIT=$env:COMMIT.substring(0, 7) $gcs_bucket="minikube-builds/logs/$env:MINIKUBE_LOCATION/$env:ROOT_JOB_ID" +$env:MINIKUBE_SUPPRESS_DOCKER_PERFORMANCE=true # Docker's kubectl breaks things, and comes earlier in the path than the regular kubectl. So download the expected kubectl and replace Docker's version. (New-Object Net.WebClient).DownloadFile("https://dl.k8s.io/release/v1.20.0/bin/windows/amd64/kubectl.exe", "C:\Program Files\Docker\Docker\resources\bin\kubectl.exe") diff --git a/hack/jenkins/common.sh b/hack/jenkins/common.sh index a616c707bf..6a0f7c6b87 100755 --- a/hack/jenkins/common.sh +++ b/hack/jenkins/common.sh @@ -33,6 +33,7 @@ readonly TEST_HOME="${TEST_ROOT}/${OS_ARCH}-${DRIVER}-${CONTAINER_RUNTIME}-${MIN export GOPATH="$HOME/go" export KUBECONFIG="${TEST_HOME}/kubeconfig" export PATH=$PATH:"/usr/local/bin/:/usr/local/go/bin/:$GOPATH/bin" +export MINIKUBE_SUPPRESS_DOCKER_PERFORMANCE=true readonly TIMEOUT=${1:-120m} diff --git a/pkg/drivers/kic/oci/cli_runner.go b/pkg/drivers/kic/oci/cli_runner.go index 3212c322cc..6fe7c4fef6 100644 --- a/pkg/drivers/kic/oci/cli_runner.go +++ b/pkg/drivers/kic/oci/cli_runner.go @@ -21,8 +21,10 @@ import ( "context" "fmt" "io" + "os" "os/exec" "runtime" + "strconv" "strings" "sync" "time" @@ -84,6 +86,17 @@ func PrefixCmd(cmd *exec.Cmd) *exec.Cmd { return cmd } +func suppressDockerMessage() bool { + envKey := "MINIKUBE_SUPPRESS_DOCKER_PERFORMANCE" + env := os.Getenv(envKey) + suppress, err := strconv.ParseBool(env) + if err != nil { + klog.Errorf("failed to parse bool from the %s env, defaulting to 'false'; received: %s: %v", envKey, env, err) + return false + } + return suppress +} + // runCmd runs a command exec.Command against docker daemon or podman func runCmd(cmd *exec.Cmd, warnSlow ...bool) (*RunResult, error) { cmd = PrefixCmd(cmd) @@ -135,7 +148,7 @@ func runCmd(cmd *exec.Cmd, warnSlow ...bool) (*RunResult, error) { start := time.Now() err := cmd.Run() elapsed := time.Since(start) - if warn && !out.JSON { + if warn && !out.JSON && !suppressDockerMessage() { if elapsed > warnTime { warnLock.Lock() _, ok := alreadyWarnedCmds[rr.Command()] diff --git a/site/content/en/docs/handbook/config.md b/site/content/en/docs/handbook/config.md index 5d6e10e737..b10533cc21 100644 --- a/site/content/en/docs/handbook/config.md +++ b/site/content/en/docs/handbook/config.md @@ -114,14 +114,12 @@ Some features can only be accessed by minikube specific environment variables, h * **MINIKUBE_IN_STYLE** - (bool) manually sets whether or not emoji and colors should appear in minikube. Set to false or 0 to disable this feature, true or 1 to force it to be turned on. -* **MINIKUBE_WANTUPDATENOTIFICATION** - (bool) sets whether the user wants an update notification for new minikube versions - -* **MINIKUBE_REMINDERWAITPERIODINHOURS** - (int) sets the number of hours to check for an update notification - * **CHANGE_MINIKUBE_NONE_USER** - (bool) automatically change ownership of ~/.minikube to the value of $SUDO_USER * **MINIKUBE_ENABLE_PROFILING** - (int, `1` enables it) enables trace profiling to be generated for minikube +* **MINIKUBE_SUPPRESS_DOCKER_PERFORMANCE** - (bool) suppresses Docker performance warnings when Docker is slow + ### Example: Disabling emoji {{% tabs %}} From 5a66196a20495fcea739fa2269164d6910e809c4 Mon Sep 17 00:00:00 2001 From: Steven Powell Date: Wed, 15 Dec 2021 15:58:00 -0800 Subject: [PATCH 2/3] update message --- pkg/drivers/kic/oci/cli_runner.go | 4 +++- site/content/en/docs/tutorials/continuous_integration.md | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/drivers/kic/oci/cli_runner.go b/pkg/drivers/kic/oci/cli_runner.go index 6fe7c4fef6..cebf4f6afc 100644 --- a/pkg/drivers/kic/oci/cli_runner.go +++ b/pkg/drivers/kic/oci/cli_runner.go @@ -91,7 +91,9 @@ func suppressDockerMessage() bool { env := os.Getenv(envKey) suppress, err := strconv.ParseBool(env) if err != nil { - klog.Errorf("failed to parse bool from the %s env, defaulting to 'false'; received: %s: %v", envKey, env, err) + msg := fmt.Sprintf("failed to parse bool from the %s env, defaulting to 'false'; received: %s: %v", envKey, env, err) + klog.Warning(msg) + out.Styled(style.Warning, msg) return false } return suppress diff --git a/site/content/en/docs/tutorials/continuous_integration.md b/site/content/en/docs/tutorials/continuous_integration.md index 16f97819c9..10d07c5628 100644 --- a/site/content/en/docs/tutorials/continuous_integration.md +++ b/site/content/en/docs/tutorials/continuous_integration.md @@ -46,6 +46,6 @@ curl -LO \ https://storage.googleapis.com/kubernetes-release/release/$kv/bin/linux/amd64/kubectl \ && install kubectl /tmp/ -export MINIKUBE_WANTUPDATENOTIFICATION=false +minikube config set WantUpdateNotification false /tmp/minikube-linux-amd64 start --driver=docker ``` From dce1612c330e23593524b82e3d0b2edb0ad3dfe4 Mon Sep 17 00:00:00 2001 From: Steven Powell Date: Wed, 15 Dec 2021 16:39:45 -0800 Subject: [PATCH 3/3] fix binary path in doc --- site/content/en/docs/tutorials/continuous_integration.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site/content/en/docs/tutorials/continuous_integration.md b/site/content/en/docs/tutorials/continuous_integration.md index 10d07c5628..6abe339aec 100644 --- a/site/content/en/docs/tutorials/continuous_integration.md +++ b/site/content/en/docs/tutorials/continuous_integration.md @@ -46,6 +46,6 @@ curl -LO \ https://storage.googleapis.com/kubernetes-release/release/$kv/bin/linux/amd64/kubectl \ && install kubectl /tmp/ -minikube config set WantUpdateNotification false +/tmp/minikube-linux-amd64 config set WantUpdateNotification false /tmp/minikube-linux-amd64 start --driver=docker ```