Skip to content

Commit

Permalink
Merge pull request kubernetes#13168 from spowelljr/supressDockerPerfo…
Browse files Browse the repository at this point in the history
…rmance

Added env to suppress Docker performance messages
  • Loading branch information
spowelljr authored Dec 16, 2021
2 parents a0d4d42 + dce1612 commit 9200267
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 6 deletions.
1 change: 1 addition & 0 deletions hack/jenkins/common.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
1 change: 1 addition & 0 deletions hack/jenkins/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Expand Down
17 changes: 16 additions & 1 deletion pkg/drivers/kic/oci/cli_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ import (
"context"
"fmt"
"io"
"os"
"os/exec"
"runtime"
"strconv"
"strings"
"sync"
"time"
Expand Down Expand Up @@ -84,6 +86,19 @@ 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 {
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
}

// runCmd runs a command exec.Command against docker daemon or podman
func runCmd(cmd *exec.Cmd, warnSlow ...bool) (*RunResult, error) {
cmd = PrefixCmd(cmd)
Expand Down Expand Up @@ -135,7 +150,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()]
Expand Down
6 changes: 2 additions & 4 deletions site/content/en/docs/handbook/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}}
Expand Down
2 changes: 1 addition & 1 deletion site/content/en/docs/tutorials/continuous_integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
/tmp/minikube-linux-amd64 config set WantUpdateNotification false
/tmp/minikube-linux-amd64 start --driver=docker
```

0 comments on commit 9200267

Please sign in to comment.