Skip to content

Commit

Permalink
Fixing TestProxy Setup
Browse files Browse the repository at this point in the history
making sure minikube is deleted before setup to avoid kubernetes#4132
  • Loading branch information
josedonizetti authored and medyagh committed Jun 4, 2019
1 parent 432035c commit b906f95
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 34 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ checksum:
clean:
rm -rf $(BUILD_DIR)
rm -f pkg/minikube/assets/assets.go
rm -rf ./vendor

.PHONY: gendocs
gendocs: out/docs/minikube.md
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ minikube's [primary goals](https://github.com/kubernetes/minikube/blob/master/do

## News

:mega: **Please fill out our [fast 5-question survey](https://forms.gle/Gg3hG5ZySw8c1C24A)** so that we can learn how & why you use minikube, and what improvements we should make. Thank you! :dancers:

* 2019-05-21 - v1.1.0 released! [[download](https://github.com/kubernetes/minikube/releases/tag/v1.1.0)] [[release notes](https://github.com/kubernetes/minikube/blob/master/CHANGELOG.md#version-110---2019-05-21)]
* 2019-04-29 - v1.0.1 released! [[download](https://github.com/kubernetes/minikube/releases/tag/v1.0.1)] [[release notes](https://github.com/kubernetes/minikube/blob/master/CHANGELOG.md#version-101---2019-04-29)]
* 2019-03-27 - v1.0.0 released! [[download](https://github.com/kubernetes/minikube/releases/tag/v1.0.0)] [[release notes](https://github.com/kubernetes/minikube/blob/master/CHANGELOG.md#version-1000---2019-03-27)]

## Features

minikube runs the official stable release of Kubernetes, with support for standard Kubernetes features like:
minikube runs the latest stable release of Kubernetes, with support for standard Kubernetes features like:

* [LoadBalancer](https://github.com/kubernetes/minikube/blob/master/docs/tunnel.md) - using `minikube tunnel`
* Multi-cluster - using `minikube start -p <name>`
Expand Down
28 changes: 20 additions & 8 deletions cmd/minikube/cmd/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ import (
"regexp"
"time"

"github.com/docker/machine/libmachine/mcnerror"
"github.com/golang/glog"
"github.com/pkg/browser"
"github.com/pkg/errors"
"github.com/spf13/cobra"
configcmd "k8s.io/minikube/cmd/minikube/cmd/config"
"k8s.io/minikube/pkg/minikube/cluster"
"k8s.io/minikube/pkg/minikube/config"
pkg_config "k8s.io/minikube/pkg/minikube/config"
"k8s.io/minikube/pkg/minikube/console"
"k8s.io/minikube/pkg/minikube/exit"
Expand Down Expand Up @@ -60,10 +60,6 @@ var dashboardCmd = &cobra.Command{
console.ErrLn("Error loading profile config: %v", err)
}

kubectl, err := exec.LookPath("kubectl")
if err != nil {
exit.WithCode(exit.NoInput, "kubectl not found in PATH, but is required for the dashboard. Installation guide: https://kubernetes.io/docs/tasks/tools/install-kubectl/")
}
api, err := machine.NewAPIClient()
defer func() {
err := api.Close()
Expand All @@ -75,13 +71,29 @@ var dashboardCmd = &cobra.Command{
if err != nil {
exit.WithError("Error getting client", err)
}
cluster.EnsureMinikubeRunningOrExit(api, 1)

if _, err = api.Load(pkg_config.GetMachineName()); err != nil {
switch err := errors.Cause(err).(type) {
case mcnerror.ErrHostDoesNotExist:
console.OutStyle(console.Meh, "%q cluster does not exist", pkg_config.GetMachineName())
os.Exit(exit.Unavailable)
default:
exit.WithError("Error getting cluster", err)
}
}

err = proxy.ExcludeIP(cc.KubernetesConfig.NodeIP) // to be used for http get calls
if err != nil {
glog.Errorf("Error excluding IP from proxy: %s", err)
}

kubectl, err := exec.LookPath("kubectl")
if err != nil {
exit.WithCode(exit.NoInput, "kubectl not found in PATH, but is required for the dashboard. Installation guide: https://kubernetes.io/docs/tasks/tools/install-kubectl/")
}

cluster.EnsureMinikubeRunningOrExit(api, 1)

// Send status messages to stderr for folks re-using this output.
console.ErrStyle(console.Enabling, "Enabling dashboard ...")
// Enable the dashboard add-on
Expand Down Expand Up @@ -128,9 +140,9 @@ var dashboardCmd = &cobra.Command{
// kubectlProxy runs "kubectl proxy", returning host:port
func kubectlProxy(path string) (*exec.Cmd, string, error) {
// port=0 picks a random system port
// config.GetMachineName() respects the -p (profile) flag
// pkg_config.GetMachineName() respects the -p (profile) flag

cmd := exec.Command(path, "--context", config.GetMachineName(), "proxy", "--port=0")
cmd := exec.Command(path, "--context", pkg_config.GetMachineName(), "proxy", "--port=0")

stdoutPipe, err := cmd.StdoutPipe()
if err != nil {
Expand Down
20 changes: 10 additions & 10 deletions docs/contributors/roadmap.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,41 +6,41 @@ Please send a PR to suggest any improvements to it.

## (#1) User-friendly and accessible

- [ ] Creation of a user-centric minikube website for installation & documentation
- [ ] Localized output to 5+ written languages
- [ ] Creation of a user-centric minikube website for installation & documentation [#4388](https://github.com/kubernetes/minikube/issues/4388)
- [ ] Localized output to 5+ written languages [#4186](https://github.com/kubernetes/minikube/issues/4186) [#4185](https://github.com/kubernetes/minikube/issues/4185)
- [x] Make minikube usable in environments with challenging connectivity requirements
- [ ] Support lightweight deployment methods for environments where VM's are impractical
- [ ] Support lightweight deployment methods for environments where VM's are impractical [#4389](https://github.com/kubernetes/minikube/issues/4389) [#4390](https://github.com/kubernetes/minikube/issues/4390)
- [x] Add offline support

## (#2) Inclusive and community-driven

- [x] Increase community involvement in planning and decision making
- [ ] Make the continuous integration and release infrastructure publicly available
- [ ] Make the continuous integration and release infrastructure publicly available [#3256](https://github.com/kubernetes/minikube/issues/4390)
- [x] Double the number of active maintainers

## (#3) Cross-platform

- [ ] Simplified installation process across all supported platforms
- [ ] Users should never need to separately install supporting binaries
- [ ] Users should never need to separately install supporting binaries [#3975](https://github.com/kubernetes/minikube/issues/3975) [#4391](https://github.com/kubernetes/minikube/issues/4391)
- [ ] Simplified installation process across all supported platforms

## (#4) Support all Kubernetes features

- [ ] Add multi-node support
- [ ] Add multi-node support [#94](https://github.com/kubernetes/minikube/issues/94)

## (#5) High-fidelity

- [ ] Reduce guest VM overhead by 50%
- [ ] Reduce guest VM overhead by 50% [#3207](https://github.com/kubernetes/minikube/issues/3207)
- [x] Disable swap in the guest VM

## (#6) Compatible with all supported Kubernetes releases

- [x] Continuous Integration testing across all supported Kubernetes releases
- [ ] Automatic PR generation for updating the default Kubernetes release minikube uses
- [ ] Automatic PR generation for updating the default Kubernetes release minikube uses [#4392](https://github.com/kubernetes/minikube/issues/4392)

## (#7) Support for all Kubernetes-friendly container runtimes

- [x] Run all integration tests across all supported container runtimes
- [ ] Support for Kata Containers (help wanted!)
- [ ] Support for Kata Containers [#4347](https://github.com/kubernetes/minikube/issues/4347)

## (#8) Stable and easy to debug

Expand Down
1 change: 1 addition & 0 deletions docs/drivers.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ In case the default network doesn't exist you can define it.
```shell
curl https://raw.githubusercontent.com/libvirt/libvirt/master/src/network/default.xml > kvm-default.xml
virsh net-define kvm-default.xml
virsh net-start default
```

## Hyperkit driver
Expand Down
2 changes: 1 addition & 1 deletion pkg/drivers/kvm/gpu.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ func isIsolated(device string) bool {
iommuGroupPath := filepath.Join(sysFsPCIDevicesPath, device, "iommu_group", "devices")
otherDevices, err := ioutil.ReadDir(iommuGroupPath)
if err != nil {
log.Infof("Error reading %q: %v", iommuGroupPath)
log.Infof("Error reading %q: %v", iommuGroupPath, err)
return false
}

Expand Down
3 changes: 2 additions & 1 deletion pkg/minikube/bootstrapper/certs.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package bootstrapper

import (
"fmt"
"net"
"path"
"path/filepath"
Expand Down Expand Up @@ -66,7 +67,7 @@ func SetupCerts(cmd CommandRunner, k8s config.KubernetesConfig) error {

kubeCfgSetup := &util.KubeConfigSetup{
ClusterName: k8s.NodeName,
ClusterServerAddress: "https://localhost:8443",
ClusterServerAddress: fmt.Sprintf("https://localhost:%d", k8s.NodePort),
ClientCertificate: path.Join(util.DefaultCertPath, "apiserver.crt"),
ClientKey: path.Join(util.DefaultCertPath, "apiserver.key"),
CertificateAuthority: path.Join(util.DefaultCertPath, "ca.crt"),
Expand Down
1 change: 0 additions & 1 deletion test/integration/addons_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ func readLineWithTimeout(b *bufio.Reader, timeout time.Duration) (string, error)
}

func testDashboard(t *testing.T) {
t.Parallel()
minikubeRunner := NewMinikubeRunner(t)
cmd, out := minikubeRunner.RunDaemon("dashboard --url")
defer func() {
Expand Down
34 changes: 22 additions & 12 deletions test/integration/proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,17 @@ func TestProxy(t *testing.T) {
t.Fatalf("Failed to set up the test proxy: %s", err)
}

defer func(t *testing.T) { // Clean up after setting up proxy
// making sure there is no running miniukube to avoid https://github.com/kubernetes/minikube/issues/4132
r := NewMinikubeRunner(t)
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Minute)
defer cancel()
_, _, err = r.RunWithContext(ctx, "delete")
if err != nil {
t.Logf("Error deleting minikube before test setup %s : ", err)
}

// Clean up after setting up proxy
defer func(t *testing.T) {
err = os.Setenv("HTTP_PROXY", origHP)
if err != nil {
t.Errorf("Error reverting the HTTP_PROXY env")
Expand All @@ -82,28 +92,29 @@ func TestProxy(t *testing.T) {
if err != nil {
t.Errorf("Error shutting down the http proxy")
}

_, _, err = r.RunWithContext(ctx, "delete")
if err != nil {
t.Logf("Error deleting minikube when cleaning up proxy setup: %s", err)
}
}(t)

t.Run("ConsoleWarnning", testProxyWarning)
t.Run("DashboardProxy", testDashboard)
t.Run("Proxy Console Warnning", testProxyWarning)
t.Run("Proxy Dashboard", testProxyDashboard)

}

// testProxyWarning checks user is warned correctly about the proxy related env vars
func testProxyWarning(t *testing.T) {
mk := NewMinikubeRunner(t)
// Start a timer for all remaining commands, to display failure output before a panic.
ctx, cancel := context.WithTimeout(context.Background(), 13*time.Minute)
r := NewMinikubeRunner(t)
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
defer cancel()
startCmd := fmt.Sprintf("start %s %s %s", mk.StartArgs, mk.Args, "--alsologtostderr --v=5")
stdout, stderr, err := mk.RunWithContext(ctx, startCmd)
startCmd := fmt.Sprintf("start %s %s %s", r.StartArgs, r.Args, "--alsologtostderr --v=5")
stdout, stderr, err := r.RunWithContext(ctx, startCmd)
if err != nil {
t.Fatalf("start: %v\nstdout: %s\nstderr: %s", err, stdout, stderr)
}
mk.EnsureRunning()

// Pre-cleanup: this usually fails, because no instance is running.
// mk.RunWithContext(ctx, "delete")
msg := "Found network options:"
if !strings.Contains(stdout, msg) {
t.Errorf("Proxy wranning (%s) is missing from the output: %s", msg, stderr)
Expand All @@ -113,5 +124,4 @@ func testProxyWarning(t *testing.T) {
if !strings.Contains(stderr, msg) {
t.Errorf("Proxy wranning (%s) is missing from the output: %s", msg, stderr)
}

}

0 comments on commit b906f95

Please sign in to comment.