Repository: kubernetes/minikube
Pull request #12395 (2021-09-02 22:37:08)

Change GitHub issue output to ask user to upload `minikube logs` file
### Start command
**Before:**
```
╭────────────────────────────────────────────────────────────────────╮
│                                                                    │
│    😿  If the above advice does not help, please let us know:      │
│    👉  https://github.com/kubernetes/minikube/issues/new/choose    │
│                                                                    │
│    Please attach the following file to the GitHub issue:           │
│    - /Users/powellsteven/.minikube/logs/lastStart.txt              │
│                                                                    │
╰────────────────────────────────────────────────────────────────────╯
```

**After:**
```
╭──────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                  │
│    😿  If the above advice does not help, please let us know:                                    │
│    👉  https://github.com/kubernetes/minikube/issues/new/choose                                  │
│                                                                                                  │
│    Please run `minikube logs --file=logs.txt` and attach logs.txt to the GitHub issue.           │
│                                                                                                  │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
```

### Non-start command
**Before:**
```
╭─────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                         │
│    😿  If the above advice does not help, please let us know:                           │
│    👉  https://github.com/kubernetes/minikube/issues/new/choose                         │
│                                                                                         │
│    Please attach the following file to the GitHub issue:                                │
│    - /tmp/minikube_dashboard_5fed37a00a23a8e8c684a572c596e3b7c65c5e16_0.log             │
│                                                                                         │
╰─────────────────────────────────────────────────────────────────────────────────────────╯
```

**After:**
```
╭───────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                       │
│    😿  If the above advice does not help, please let us know:                                         │
│    👉  https://github.com/kubernetes/minikube/issues/new/choose                                       │
│                                                                                                       │
│    Please run `minikube logs --file=logs.txt` and attach logs.txt to the GitHub issue.                │
│    Please also attach the following file to the GitHub issue:                                         │
│    - /tmp/minikube_dashboard_5fed37a00a23a8e8c684a572c596e3b7c65c5e16_0.log                           │
│                                                                                                       │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────╯
```


Patch:
diff --git a/Makefile b/Makefile
index acd60490c..53df20ee2 100644
--- a/Makefile
+++ b/Makefile
@@ -23,7 +23,7 @@ KUBERNETES_VERSION ?= $(shell egrep "DefaultKubernetesVersion =" pkg/minikube/co
 KIC_VERSION ?= $(shell egrep "Version =" pkg/drivers/kic/types.go | cut -d \" -f2)
 
 # Default to .0 for higher cache hit rates, as build increments typically don't require new ISO versions
-ISO_VERSION ?= v1.23.0
+ISO_VERSION ?= v1.22.0-1628974786-12268
 # Dashes are valid in semver, but not Linux packaging. Use ~ to delimit alpha/beta
 DEB_VERSION ?= $(subst -,~,$(RAW_VERSION))
 DEB_REVISION ?= 0
diff --git a/hack/jenkins/common.sh b/hack/jenkins/common.sh
index 600e51ece..d1e1d9929 100755
--- a/hack/jenkins/common.sh
+++ b/hack/jenkins/common.sh
@@ -91,7 +91,7 @@ else
 fi
 
 # installing golang so we could do go get for gopogh
-./installers/check_install_golang.sh "/usr/local" || true
+./installers/check_install_golang.sh "1.17" "/usr/local" || true
 
 # install docker and kubectl if not present
 sudo ARCH="$ARCH" ./installers/check_install_docker.sh || true
diff --git a/hack/jenkins/installers/check_install_golang.sh b/hack/jenkins/installers/check_install_golang.sh
index e47055364..4ee97d5b1 100755
--- a/hack/jenkins/installers/check_install_golang.sh
+++ b/hack/jenkins/installers/check_install_golang.sh
@@ -16,14 +16,14 @@
 
 set -eux -o pipefail
 
-if (($# < 1)); then
-  echo "ERROR: given ! ($#) parameters but expected 1."
-  echo "USAGE: ./check_install_golang.sh INSTALL_PATH"
+if (($# < 2)); then
+  echo "ERROR: given ! ($#) number of parameters but expect 2."
+  echo "USAGE: ./check_install_golang.sh VERSION_TO_INSTALL INSTALL_PATH"
   exit 1
 fi
 
-VERSION_TO_INSTALL=$(grep '^GO_VERSION' Makefile | awk '{ print $3 }')
-INSTALL_PATH=${1}
+VERSION_TO_INSTALL=${1}
+INSTALL_PATH=${2}
 
 function current_arch() {
   case $(arch) in
@@ -51,7 +51,7 @@ function check_and_install_golang() {
   fi
 
   # golang has been installed and check its version
-  if [[ $(go version | cut -d' ' -f 3) =~ go(([0-9]+)\.([0-9]+).([0-9]+)*) ]]; then
+  if [[ $(go version) =~ (([0-9]+)\.([0-9]+).([0-9]+).([\.0-9]*)) ]]; then
     HOST_VERSION=${BASH_REMATCH[1]}
     if [ $HOST_VERSION = $VERSION_TO_INSTALL ]; then
       echo "go version on the host looks good : $HOST_VERSION"
diff --git a/hack/jenkins/kicbase_auto_build.sh b/hack/jenkins/kicbase_auto_build.sh
index 57536132a..4a05018df 100755
--- a/hack/jenkins/kicbase_auto_build.sh
+++ b/hack/jenkins/kicbase_auto_build.sh
@@ -24,9 +24,6 @@ docker login -u ${DOCKERHUB_USER} -p ${DOCKERHUB_PASS}
 # Make sure gh is installed and configured
 ./hack/jenkins/installers/check_install_gh.sh
 
-# Make sure golang is installed and configured
-./hack/jenkins/installers/check_install_golang.sh "/usr/local" || true
-
 # Let's make sure we have the newest kicbase reference
 curl -L https://github.com/kubernetes/minikube/raw/master/pkg/drivers/kic/types.go --output types-head.go
 # kicbase tags are of the form VERSION-TIMESTAMP-PR, so this grep finds that TIMESTAMP in the middle
diff --git a/hack/jenkins/minikube_cross_build_and_upload.sh b/hack/jenkins/minikube_cross_build_and_upload.sh
index 81381734a..94750f699 100755
--- a/hack/jenkins/minikube_cross_build_and_upload.sh
+++ b/hack/jenkins/minikube_cross_build_and_upload.sh
@@ -26,7 +26,8 @@ set -eux -o pipefail
 readonly bucket="minikube-builds"
 
 # Make sure the right golang version is installed based on Makefile
-./hack/jenkins/installers/check_install_golang.sh /usr/local
+WANT_GOLANG_VERSION=$(grep '^GO_VERSION' Makefile | awk '{ print $3 }')
+./hack/jenkins/installers/check_install_golang.sh $WANT_GOLANG_VERSION /usr/local
 
 
 declare -rx BUILD_IN_DOCKER=y
diff --git a/hack/jenkins/prbot.sh b/hack/jenkins/prbot.sh
index b88b9878e..0f68772e9 100644
--- a/hack/jenkins/prbot.sh
+++ b/hack/jenkins/prbot.sh
@@ -27,7 +27,7 @@ fi
 ./installers/check_install_gh.sh 
 
 # Make sure go is installed and configured                                            
-./installers/check_install_golang.sh "/usr/local" || true
+./installers/check_install_golang.sh "1.16" "/usr/local" || true
 
 # Grab latest code                                                                    
 git clone https://github.com/kubernetes/minikube.git                                  
diff --git a/hack/jenkins/preload_generation.sh b/hack/jenkins/preload_generation.sh
index b019d6f6e..66e2ba112 100644
--- a/hack/jenkins/preload_generation.sh
+++ b/hack/jenkins/preload_generation.sh
@@ -21,7 +21,8 @@
 set -eux -o pipefail
 
 # Make sure the right golang version is installed based on Makefile
-./hack/jenkins/installers/check_install_golang.sh /usr/local
+WANT_GOLANG_VERSION=$(grep '^GO_VERSION' Makefile | awk '{ print $3 }')
+./hack/jenkins/installers/check_install_golang.sh $WANT_GOLANG_VERSION /usr/local
 
 make upload-preloaded-images-tar
 make clean
diff --git a/hack/update/golang_version/update_golang_version.go b/hack/update/golang_version/update_golang_version.go
index d60ecf2f2..245c801db 100644
--- a/hack/update/golang_version/update_golang_version.go
+++ b/hack/update/golang_version/update_golang_version.go
@@ -111,6 +111,11 @@ var (
 				`(?m)^go .*`: `go {{.StableVersionMM}}`,
 			},
 		},
+		"hack/jenkins/common.sh": {
+			Replace: map[string]string{
+				`\.\/installers\/check_install_golang\.sh \".*\" \"\/usr\/local\" .*`: `./installers/check_install_golang.sh "{{.StableVersion}}" "/usr/local" || true`,
+			},
+		},
 		"Makefile": {
 			Replace: map[string]string{
 				// searching for 1.* so it does NOT match "KVM_GO_VERSION ?= $(GO_VERSION:.0=)" in the Makefile
diff --git a/pkg/minikube/download/iso.go b/pkg/minikube/download/iso.go
index 08f4042ba..ca6f42fc4 100644
--- a/pkg/minikube/download/iso.go
+++ b/pkg/minikube/download/iso.go
@@ -40,7 +40,7 @@ const fileScheme = "file"
 // DefaultISOURLs returns a list of ISO URL's to consult by default, in priority order
 func DefaultISOURLs() []string {
 	v := version.GetISOVersion()
-	isoBucket := "minikube/iso"
+	isoBucket := "minikube-builds/iso/12268"
 	return []string{
 		fmt.Sprintf("https://storage.googleapis.com/%s/minikube-%s.iso", isoBucket, v),
 		fmt.Sprintf("https://github.com/kubernetes/minikube/releases/download/%s/minikube-%s.iso", v, v),
diff --git a/pkg/minikube/out/out.go b/pkg/minikube/out/out.go
index 4706f9a70..01dd5318d 100644
--- a/pkg/minikube/out/out.go
+++ b/pkg/minikube/out/out.go
@@ -33,9 +33,9 @@ import (
 	"github.com/Delta456/box-cli-maker/v2"
 	"github.com/briandowns/spinner"
 	"github.com/mattn/go-isatty"
+	"github.com/spf13/pflag"
 
 	"k8s.io/klog/v2"
-	"k8s.io/minikube/pkg/minikube/localpath"
 	"k8s.io/minikube/pkg/minikube/out/register"
 	"k8s.io/minikube/pkg/minikube/style"
 	"k8s.io/minikube/pkg/minikube/translate"
@@ -381,14 +381,6 @@ func displayError(msg string, err error) {
 }
 
 func latestLogFilePath() (string, error) {
-	if len(os.Args) < 2 {
-		return "", fmt.Errorf("unable to detect command")
-	}
-	cmd := os.Args[1]
-	if cmd == "start" {
-		return localpath.LastStartLog(), nil
-	}
-
 	tmpdir := os.TempDir()
 	files, err := ioutil.ReadDir(tmpdir)
 	if err != nil {
@@ -411,16 +403,32 @@ func latestLogFilePath() (string, error) {
 	return fullPath, nil
 }
 
+func command() (string, error) {
+	if len(pflag.Args()) < 1 {
+		return "", fmt.Errorf("unable to detect command")
+	}
+
+	return pflag.Arg(0), nil
+}
+
 func displayGitHubIssueMessage() {
-	logPath, err := latestLogFilePath()
+	cmd, err := command()
 	if err != nil {
-		klog.Warningf("failed to diplay GitHub issue message: %v", err)
+		klog.Warningf("failed to get command: %v", err)
 	}
 
 	msg := Sprintf(style.Sad, "If the above advice does not help, please let us know:")
 	msg += Sprintf(style.URL, "https://github.com/kubernetes/minikube/issues/new/choose\n")
-	msg += Sprintf(style.Empty, "Please attach the following file to the GitHub issue:")
-	msg += Sprintf(style.Empty, "- {{.logPath}}", V{"logPath": logPath})
+	msg += Sprintf(style.Empty, "Please run `minikube logs --file=logs.txt` and attach logs.txt to the GitHub issue.")
+
+	if cmd != "start" {
+		logPath, err := latestLogFilePath()
+		if err != nil {
+			klog.Warningf("failed to get latest log file path: %v", err)
+		}
+		msg += Sprintf(style.Empty, "Please also attach the following file to the GitHub issue:")
+		msg += Sprintf(style.Empty, "- {{.logPath}}", V{"logPath": logPath})
+	}
 
 	BoxedErr(msg)
 }
diff --git a/site/content/en/docs/commands/start.md b/site/content/en/docs/commands/start.md
index e35c4367b..fc36a9781 100644
--- a/site/content/en/docs/commands/start.md
+++ b/site/content/en/docs/commands/start.md
@@ -65,7 +65,7 @@ minikube start [flags]
       --insecure-registry strings         Insecure Docker registries to pass to the Docker daemon.  The default service CIDR range will automatically be added.
       --install-addons                    If set, install addons. Defaults to true. (default true)
       --interactive                       Allow user prompts for more information (default true)
-      --iso-url strings                   Locations to fetch the minikube ISO from. (default [https://storage.googleapis.com/minikube/iso/minikube-v1.23.0.iso,https://github.com/kubernetes/minikube/releases/download/v1.23.0/minikube-v1.23.0.iso,https://kubernetes.oss-cn-hangzhou.aliyuncs.com/minikube/iso/minikube-v1.23.0.iso])
+      --iso-url strings                   Locations to fetch the minikube ISO from. (default [https://storage.googleapis.com/minikube-builds/iso/12268/minikube-v1.22.0-1628974786-12268.iso,https://github.com/kubernetes/minikube/releases/download/v1.22.0-1628974786-12268/minikube-v1.22.0-1628974786-12268.iso,https://kubernetes.oss-cn-hangzhou.aliyuncs.com/minikube/iso/minikube-v1.22.0-1628974786-12268.iso])
       --keep-context                      This will keep the existing kubectl context and will create a minikube context.
       --kubernetes-version string         The Kubernetes version that the minikube VM will use (ex: v1.2.3, 'stable' for v1.22.1, 'latest' for v1.22.2-rc.0). Defaults to 'stable'.
       --kvm-gpu                           Enable experimental NVIDIA GPU support in minikube


Test patch:
diff --git a/hack/jenkins/build/minikube_build_upload_latest.sh b/hack/jenkins/build/minikube_build_upload_latest.sh
index 91ec72589..b6b50cc86 100755
--- a/hack/jenkins/build/minikube_build_upload_latest.sh
+++ b/hack/jenkins/build/minikube_build_upload_latest.sh
@@ -22,7 +22,8 @@ set -eux -o pipefail
 readonly bucket="minikube/latest"
 
 # Make sure the right golang version is installed based on Makefile
-./hack/jenkins/installers/check_install_golang.sh /usr/local
+WANT_GOLANG_VERSION=$(grep '^GO_VERSION' Makefile | awk '{ print $3 }')
+./hack/jenkins/installers/check_install_golang.sh $WANT_GOLANG_VERSION /usr/local
 
 
 declare -rx GOPATH=/var/lib/jenkins/go
diff --git a/pkg/minikube/out/out_test.go b/pkg/minikube/out/out_test.go
index ea0f729c8..acaf13ac4 100644
--- a/pkg/minikube/out/out_test.go
+++ b/pkg/minikube/out/out_test.go
@@ -21,11 +21,12 @@ import (
 	"os"
 	"path/filepath"
 	"strconv"
+	"strings"
 	"testing"
 
 	"github.com/Delta456/box-cli-maker/v2"
+	"github.com/spf13/pflag"
 
-	"k8s.io/minikube/pkg/minikube/localpath"
 	"k8s.io/minikube/pkg/minikube/style"
 	"k8s.io/minikube/pkg/minikube/tests"
 	"k8s.io/minikube/pkg/minikube/translate"
@@ -130,37 +131,96 @@ func createLogFile() (string, error) {
 	return f.Name(), nil
 }
 
-func TestLatestLogPath(t *testing.T) {
-	filename, err := createLogFile()
+func TestLatestLogFilePath(t *testing.T) {
+	want, err := createLogFile()
 	if err != nil {
 		t.Fatal(err)
 	}
-	defer os.Remove(filename)
+	defer os.Remove(want)
 
+	got, err := latestLogFilePath()
+	if err != nil {
+		t.Errorf("latestLogFilePath() failed with error = %v", err)
+	}
+	if got != want {
+		t.Errorf("latestLogFilePath() = %q; wanted %q", got, want)
+	}
+}
+
+func TestCommand(t *testing.T) {
 	testCases := []struct {
-		args []string
-		want string
+		args        []string
+		want        string
+		shouldError bool
 	}{
 		{
 			[]string{"minikube", "start"},
-			localpath.LastStartLog(),
+			"start",
+			false,
+		},
+		{
+			[]string{"minikube", "--profile", "profile1", "start"},
+			"start",
+			false,
 		},
 		{
-			[]string{"minikube", "status"},
-			filename,
+			[]string{"minikube"},
+			"",
+			true,
 		},
 	}
 
+	pflag.String("profile", "", "")
+
 	for _, tt := range testCases {
 		oldArgs := os.Args
 		defer func() { os.Args = oldArgs }()
 		os.Args = tt.args
-		got, err := latestLogFilePath()
-		if err != nil {
-			t.Fatalf("os.Args = %s; latestLogFilePath() failed with error = %v", tt.args, err)
+		pflag.Parse()
+		got, err := command()
+		if err == nil && tt.shouldError {
+			t.Errorf("os.Args = %s; command() did not fail but was expected to", tt.args)
+		}
+		if err != nil && !tt.shouldError {
+			t.Errorf("os.Args = %s; command() failed with error = %v", tt.args, err)
 		}
 		if got != tt.want {
-			t.Errorf("os.Args = %s; latestLogFilePath() = %q; wanted %q", tt.args, got, tt.want)
+			t.Errorf("os.Args = %s; command() = %q; wanted %q", tt.args, got, tt.want)
+		}
+	}
+}
+
+func TestDisplayGitHubIssueMessage(t *testing.T) {
+	testCases := []struct {
+		args                 []string
+		shouldContainMessage bool
+	}{
+		{
+			[]string{"minikube", "start"},
+			false,
+		},
+		{
+			[]string{"minikube", "delete"},
+			true,
+		},
+	}
+
+	msg := "Please also attach the following file to the GitHub issue:"
+
+	for _, tt := range testCases {
+		oldArgs := os.Args
+		defer func() { os.Args = oldArgs }()
+		os.Args = tt.args
+		pflag.Parse()
+		f := tests.NewFakeFile()
+		SetErrFile(f)
+		displayGitHubIssueMessage()
+		output := f.String()
+		if strings.Contains(output, msg) && !tt.shouldContainMessage {
+			t.Errorf("os.Args = %s; displayGitHubIssueMessage() output = %q; did not expect it to contain = %q", tt.args, output, msg)
+		}
+		if !strings.Contains(output, msg) && tt.shouldContainMessage {
+			t.Errorf("os.Args = %s; displayGitHubIssueMessage() output = %q; expected to contain = %q", tt.args, output, msg)
 		}
 	}
 }