From 02749de984b5456de0f45c7409d621213dfbe022 Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Wed, 3 Jun 2020 14:39:34 -0700 Subject: [PATCH 1/6] detect wsl and add port forward --- pkg/minikube/driver/driver.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/minikube/driver/driver.go b/pkg/minikube/driver/driver.go index f4e6e53697fb..43d1736b6c34 100644 --- a/pkg/minikube/driver/driver.go +++ b/pkg/minikube/driver/driver.go @@ -131,7 +131,12 @@ func NeedsRoot(name string) bool { // NeedsPortForward returns true if driver is unable provide direct IP connectivity func NeedsPortForward(name string) bool { // Docker for Desktop - return IsKIC(name) && (runtime.GOOS == "darwin" || runtime.GOOS == "windows") + return IsKIC(name) && (runtime.GOOS == "darwin" || runtime.GOOS == "windows" || isMicrosoftWSL()) +} + +// isMicrosoftWSL will return true if process is running in WSL in windows +func isMicrosoftWSL() bool { + return os.Getenv("WSL_DISTRO_NAME") != "" } // HasResourceLimits returns true if driver can set resource limits such as memory size or CPU count. From 276f99b5515831038b628bf2a793f5c6a8132e8e Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Wed, 3 Jun 2020 14:40:43 -0700 Subject: [PATCH 2/6] improve comment --- pkg/minikube/driver/driver.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/minikube/driver/driver.go b/pkg/minikube/driver/driver.go index 43d1736b6c34..c2adf3815e42 100644 --- a/pkg/minikube/driver/driver.go +++ b/pkg/minikube/driver/driver.go @@ -135,6 +135,7 @@ func NeedsPortForward(name string) bool { } // isMicrosoftWSL will return true if process is running in WSL in windows +// checking for WSL env var based on this https://github.com/microsoft/WSL/issues/423#issuecomment-608237689 func isMicrosoftWSL() bool { return os.Getenv("WSL_DISTRO_NAME") != "" } From 98d577d22958e6370d194b46e16792705523b0a3 Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Wed, 3 Jun 2020 14:47:43 -0700 Subject: [PATCH 3/6] add more checks for wsl --- pkg/minikube/driver/driver.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/minikube/driver/driver.go b/pkg/minikube/driver/driver.go index c2adf3815e42..9f97058218d4 100644 --- a/pkg/minikube/driver/driver.go +++ b/pkg/minikube/driver/driver.go @@ -136,8 +136,9 @@ func NeedsPortForward(name string) bool { // isMicrosoftWSL will return true if process is running in WSL in windows // checking for WSL env var based on this https://github.com/microsoft/WSL/issues/423#issuecomment-608237689 +// also based on https://github.com/microsoft/vscode/blob/master/resources/win32/bin/code.sh#L24 func isMicrosoftWSL() bool { - return os.Getenv("WSL_DISTRO_NAME") != "" + return os.Getenv("WSL_DISTRO_NAME") != "" || os.Getenv("WSLPATH") != "" || os.Getenv("WSLENV") != "" } // HasResourceLimits returns true if driver can set resource limits such as memory size or CPU count. From 7b01b2aef512b19930cd1d8b9bb1473fd6af3012 Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Wed, 3 Jun 2020 14:50:03 -0700 Subject: [PATCH 4/6] update comment --- pkg/minikube/driver/driver.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/minikube/driver/driver.go b/pkg/minikube/driver/driver.go index 9f97058218d4..1bf5763aa4ee 100644 --- a/pkg/minikube/driver/driver.go +++ b/pkg/minikube/driver/driver.go @@ -136,7 +136,7 @@ func NeedsPortForward(name string) bool { // isMicrosoftWSL will return true if process is running in WSL in windows // checking for WSL env var based on this https://github.com/microsoft/WSL/issues/423#issuecomment-608237689 -// also based on https://github.com/microsoft/vscode/blob/master/resources/win32/bin/code.sh#L24 +// also based on https://github.com/microsoft/vscode/blob/90a39ba0d49d75e9a4d7e62a6121ad946ecebc58/resources/win32/bin/code.sh#L24 func isMicrosoftWSL() bool { return os.Getenv("WSL_DISTRO_NAME") != "" || os.Getenv("WSLPATH") != "" || os.Getenv("WSLENV") != "" } From 9e004d64178f5617ab95f2b0ca2df576fecb684b Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Thu, 4 Jun 2020 10:37:39 -0700 Subject: [PATCH 5/6] add hwlper to integraiotn test too --- test/integration/main.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/test/integration/main.go b/test/integration/main.go index 7a2865fd0878..aa3802997773 100644 --- a/test/integration/main.go +++ b/test/integration/main.go @@ -93,7 +93,14 @@ func KicDriver() bool { // NeedsPortForward returns access to endpoints with this driver needs port forwarding // (Docker on non-Linux platforms requires ports to be forwarded to 127.0.0.1) func NeedsPortForward() bool { - return KicDriver() && (runtime.GOOS == "windows" || runtime.GOOS == "darwin") + return KicDriver() && (runtime.GOOS == "windows" || runtime.GOOS == "darwin") || isMicrosoftWSL() +} + +// isMicrosoftWSL will return true if process is running in WSL in windows +// checking for WSL env var based on this https://github.com/microsoft/WSL/issues/423#issuecomment-608237689 +// also based on https://github.com/microsoft/vscode/blob/90a39ba0d49d75e9a4d7e62a6121ad946ecebc58/resources/win32/bin/code.sh#L24 +func isMicrosoftWSL() bool { + return os.Getenv("WSL_DISTRO_NAME") != "" || os.Getenv("WSLPATH") != "" || os.Getenv("WSLENV") != "" } // CanCleanup returns if cleanup is allowed From 6b29b784f2b87e6b47aff2080c6465d8cc14e147 Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Thu, 4 Jun 2020 11:39:28 -0700 Subject: [PATCH 6/6] address review comments --- pkg/minikube/driver/driver.go | 6 +++--- test/integration/main.go | 11 +++-------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/pkg/minikube/driver/driver.go b/pkg/minikube/driver/driver.go index 1bf5763aa4ee..f9ee03f91853 100644 --- a/pkg/minikube/driver/driver.go +++ b/pkg/minikube/driver/driver.go @@ -131,13 +131,13 @@ func NeedsRoot(name string) bool { // NeedsPortForward returns true if driver is unable provide direct IP connectivity func NeedsPortForward(name string) bool { // Docker for Desktop - return IsKIC(name) && (runtime.GOOS == "darwin" || runtime.GOOS == "windows" || isMicrosoftWSL()) + return IsKIC(name) && (runtime.GOOS == "darwin" || runtime.GOOS == "windows" || IsMicrosoftWSL()) } -// isMicrosoftWSL will return true if process is running in WSL in windows +// IsMicrosoftWSL will return true if process is running in WSL in windows // checking for WSL env var based on this https://github.com/microsoft/WSL/issues/423#issuecomment-608237689 // also based on https://github.com/microsoft/vscode/blob/90a39ba0d49d75e9a4d7e62a6121ad946ecebc58/resources/win32/bin/code.sh#L24 -func isMicrosoftWSL() bool { +func IsMicrosoftWSL() bool { return os.Getenv("WSL_DISTRO_NAME") != "" || os.Getenv("WSLPATH") != "" || os.Getenv("WSLENV") != "" } diff --git a/test/integration/main.go b/test/integration/main.go index aa3802997773..0c1f2e70d982 100644 --- a/test/integration/main.go +++ b/test/integration/main.go @@ -24,6 +24,8 @@ import ( "strings" "testing" "time" + + "k8s.io/minikube/pkg/minikube/driver" ) // General configuration: used to set the VM Driver @@ -93,14 +95,7 @@ func KicDriver() bool { // NeedsPortForward returns access to endpoints with this driver needs port forwarding // (Docker on non-Linux platforms requires ports to be forwarded to 127.0.0.1) func NeedsPortForward() bool { - return KicDriver() && (runtime.GOOS == "windows" || runtime.GOOS == "darwin") || isMicrosoftWSL() -} - -// isMicrosoftWSL will return true if process is running in WSL in windows -// checking for WSL env var based on this https://github.com/microsoft/WSL/issues/423#issuecomment-608237689 -// also based on https://github.com/microsoft/vscode/blob/90a39ba0d49d75e9a4d7e62a6121ad946ecebc58/resources/win32/bin/code.sh#L24 -func isMicrosoftWSL() bool { - return os.Getenv("WSL_DISTRO_NAME") != "" || os.Getenv("WSLPATH") != "" || os.Getenv("WSLENV") != "" + return KicDriver() && (runtime.GOOS == "windows" || runtime.GOOS == "darwin") || driver.IsMicrosoftWSL() } // CanCleanup returns if cleanup is allowed