From bb0417c6f2dda010b0e834fe290a82b1a7a7bd70 Mon Sep 17 00:00:00 2001 From: Ben Ebsworth Date: Sat, 29 Jun 2019 18:17:41 +1000 Subject: [PATCH 01/16] added integration tests for registry addon --- .../addons/registry/registry-proxy.yaml.tmpl | 3 +- test/integration/addons_test.go | 42 +++++++++++++++++++ test/integration/functional_test.go | 27 ++++++------ test/integration/util/util.go | 22 ++++++++++ 4 files changed, 80 insertions(+), 14 deletions(-) diff --git a/deploy/addons/registry/registry-proxy.yaml.tmpl b/deploy/addons/registry/registry-proxy.yaml.tmpl index b5ab736e34..2131be3826 100644 --- a/deploy/addons/registry/registry-proxy.yaml.tmpl +++ b/deploy/addons/registry/registry-proxy.yaml.tmpl @@ -2,7 +2,7 @@ apiVersion: extensions/v1beta1 kind: DaemonSet metadata: labels: - kubernetes.io/minikube-addons: registry + kubernetes.io/minikube-addons: registry-proxy addonmanager.kubernetes.io/mode: Reconcile name: registry-proxy namespace: kube-system @@ -10,6 +10,7 @@ spec: template: metadata: labels: + kubernetes.io/minikube-addons: registry-proxy addonmanager.kubernetes.io/mode: Reconcile spec: containers: diff --git a/test/integration/addons_test.go b/test/integration/addons_test.go index 85b56a1c71..ad5c0b6793 100644 --- a/test/integration/addons_test.go +++ b/test/integration/addons_test.go @@ -190,7 +190,49 @@ func testServicesList(t *testing.T) { t.Fatalf(err.Error()) } } +func testRegistry(t *testing.T) { + t.Parallel() + minikubeRunner := NewMinikubeRunner(t) + kubectlRunner := util.NewKubectlRunner(t) + minikubeRunner.RunCommand("addons enable registry", true) + t.Log("wait for registry to come up") + if err := util.WaitForDockerRegistryRunning(t); err != nil { + t.Fatalf("waiting for registry to be up: %v", err) + } + checkExternalAccess := func() error { + t.Log("checking registry access from outside cluster") + expectedStr := "200" + runCmd := fmt.Sprintf("curl -sS -o /dev/null -w '%%{http_code}' http://127.0.0.1:5000") + externalCheckOutput, _ := minikubeRunner.SSH(runCmd) + if !strings.Contains(externalCheckOutput, expectedStr) { + return fmt.Errorf("ExpectedStr externalCheckOutput to be: %s. Output was: %s", expectedStr, externalCheckOutput) + } + return nil + } + if err := util.Retry(t, checkExternalAccess, 2*time.Second, 5); err != nil { + t.Fatalf(err.Error()) + } + // checkInternalAccess := func() error { + t.Log("checking registry access from inside cluster") + expectedStr := "200" + // cmd := fmt.Sprintf("wget --spider -S 'http://registry.kube-system.svc.cluster.local' 2>&1 | grep 'HTTP/' | awk '{print $2}'") + out, _ := kubectlRunner.RunCommand([]string{"run", "registry-test", "--restart=Never", "--image=busybox", "-it", "--", "sh", "-c", "wget --spider -S 'http://registry.kube-system.svc.cluster.local' 2>&1 | grep 'HTTP/' | awk '{print $2}'"}) + internalCheckOutput := string(out) + if !strings.Contains(internalCheckOutput, expectedStr) { + t.Fatalf("ExpectedStr internalCheckOutput to be: %s. Output was: %s", expectedStr, internalCheckOutput) + } + // return nil + // } + + defer func() { + if _, err := kubectlRunner.RunCommand([]string{"delete", "pod", "registry-test"}); err != nil { + t.Fatalf("failed to delete pod registry-test") + } + }() + + minikubeRunner.RunCommand("addons disable registry", true) +} func testGvisor(t *testing.T) { minikubeRunner := NewMinikubeRunner(t) minikubeRunner.RunCommand("addons enable gvisor", true) diff --git a/test/integration/functional_test.go b/test/integration/functional_test.go index a8ced7a510..bb39ea3461 100644 --- a/test/integration/functional_test.go +++ b/test/integration/functional_test.go @@ -33,20 +33,21 @@ func TestFunctional(t *testing.T) { // before we run any other tests. t.Run("Status", testClusterStatus) - t.Run("DNS", testClusterDNS) - t.Run("Logs", testClusterLogs) - t.Run("Addons", testAddons) - t.Run("Dashboard", testDashboard) - t.Run("ServicesList", testServicesList) - t.Run("Provisioning", testProvisioning) - t.Run("Tunnel", testTunnel) + // t.Run("DNS", testClusterDNS) + // t.Run("Logs", testClusterLogs) + // t.Run("Addons", testAddons) + t.Run("Registry", testRegistry) + // t.Run("Dashboard", testDashboard) + // t.Run("ServicesList", testServicesList) + // t.Run("Provisioning", testProvisioning) + // t.Run("Tunnel", testTunnel) - if !usingNoneDriver(r) { - t.Run("EnvVars", testClusterEnv) - t.Run("SSH", testClusterSSH) - t.Run("IngressController", testIngressController) - t.Run("Mounting", testMounting) - } + // if !usingNoneDriver(r) { + // t.Run("EnvVars", testClusterEnv) + // t.Run("SSH", testClusterSSH) + // t.Run("IngressController", testIngressController) + // t.Run("Mounting", testMounting) + // } } func TestFunctionalContainerd(t *testing.T) { diff --git a/test/integration/util/util.go b/test/integration/util/util.go index 08e1cebb27..056928b6cb 100644 --- a/test/integration/util/util.go +++ b/test/integration/util/util.go @@ -359,6 +359,28 @@ func WaitForIngressControllerRunning(t *testing.T) error { return nil } +// WaitForDockerRegistryRunning waits until docker registry pod to be running +func WaitForDockerRegistryRunning(t *testing.T) error { + client, err := commonutil.GetClient() + if err != nil { + return errors.Wrap(err, "getting kubernetes client") + } + + if err := commonutil.WaitForRCToStabilize(client, "kube-system", "registry", time.Minute*10); err != nil { + return errors.Wrap(err, "waiting for registry replicacontroller to stabilize") + } + + registrySelector := labels.SelectorFromSet(labels.Set(map[string]string{"kubernetes.io/minikube-addons": "registry"})) + if err := commonutil.WaitForPodsWithLabelRunning(client, "kube-system", registrySelector); err != nil { + return errors.Wrap(err, "waiting for registry pods") + } + proxySelector := labels.SelectorFromSet(labels.Set(map[string]string{"kubernetes.io/minikube-addons": "registry-proxy"})) + if err := commonutil.WaitForPodsWithLabelRunning(client, "kube-system", proxySelector); err != nil { + return errors.Wrap(err, "waiting for registry-proxy pods") + } + return nil +} + // WaitForIngressDefaultBackendRunning waits until ingress default backend pod to be running func WaitForIngressDefaultBackendRunning(t *testing.T) error { client, err := commonutil.GetClient() From de424fe8e8c9795bc51a9472621b678bcc812494 Mon Sep 17 00:00:00 2001 From: Ben Ebsworth Date: Sat, 29 Jun 2019 18:17:41 +1000 Subject: [PATCH 02/16] added integration tests for registry addon --- .../addons/registry/registry-proxy.yaml.tmpl | 3 +- test/integration/addons_test.go | 50 +++++++++++++++++++ test/integration/functional_test.go | 1 + test/integration/util/util.go | 22 ++++++++ 4 files changed, 75 insertions(+), 1 deletion(-) diff --git a/deploy/addons/registry/registry-proxy.yaml.tmpl b/deploy/addons/registry/registry-proxy.yaml.tmpl index b5ab736e34..2131be3826 100644 --- a/deploy/addons/registry/registry-proxy.yaml.tmpl +++ b/deploy/addons/registry/registry-proxy.yaml.tmpl @@ -2,7 +2,7 @@ apiVersion: extensions/v1beta1 kind: DaemonSet metadata: labels: - kubernetes.io/minikube-addons: registry + kubernetes.io/minikube-addons: registry-proxy addonmanager.kubernetes.io/mode: Reconcile name: registry-proxy namespace: kube-system @@ -10,6 +10,7 @@ spec: template: metadata: labels: + kubernetes.io/minikube-addons: registry-proxy addonmanager.kubernetes.io/mode: Reconcile spec: containers: diff --git a/test/integration/addons_test.go b/test/integration/addons_test.go index 85b56a1c71..629401cf83 100644 --- a/test/integration/addons_test.go +++ b/test/integration/addons_test.go @@ -190,7 +190,57 @@ func testServicesList(t *testing.T) { t.Fatalf(err.Error()) } } +func testRegistry(t *testing.T) { + t.Parallel() + minikubeRunner := NewMinikubeRunner(t) + kubectlRunner := util.NewKubectlRunner(t) + minikubeRunner.RunCommand("addons enable registry", true) + t.Log("wait for registry to come up") + if err := util.WaitForDockerRegistryRunning(t); err != nil { + t.Fatalf("waiting for registry to be up: %v", err) + } + + // Check access from outside the cluster on port 5000, validing connectivity via registry-proxy + checkExternalAccess := func() error { + t.Log("checking registry access from outside cluster") + expectedStr := "200" + runCmd := fmt.Sprintf("curl -sS -o /dev/null -w '%%{http_code}' http://127.0.0.1:5000") + externalCheckOutput, _ := minikubeRunner.SSH(runCmd) + if !strings.Contains(externalCheckOutput, expectedStr) { + return fmt.Errorf("ExpectedStr externalCheckOutput to be: %s. Output was: %s", expectedStr, externalCheckOutput) + } + return nil + } + + if err := util.Retry(t, checkExternalAccess, 2*time.Second, 5); err != nil { + t.Fatalf(err.Error()) + } + // check access from inside the cluster via a busybox container running inside cluster + t.Log("checking registry access from inside cluster") + expectedStr := "200" + out, _ := kubectlRunner.RunCommand([]string{ + "run", + "registry-test", + "--restart=Never", + "--image=busybox", + "-it", + "--", + "sh", + "-c", + "wget --spider -S 'http://registry.kube-system.svc.cluster.local' 2>&1 | grep 'HTTP/' | awk '{print $2}'"}) + internalCheckOutput := string(out) + if !strings.Contains(internalCheckOutput, expectedStr) { + t.Fatalf("ExpectedStr internalCheckOutput to be: %s. Output was: %s", expectedStr, internalCheckOutput) + } + + defer func() { + if _, err := kubectlRunner.RunCommand([]string{"delete", "pod", "registry-test"}); err != nil { + t.Fatalf("failed to delete pod registry-test") + } + }() + minikubeRunner.RunCommand("addons disable registry", true) +} func testGvisor(t *testing.T) { minikubeRunner := NewMinikubeRunner(t) minikubeRunner.RunCommand("addons enable gvisor", true) diff --git a/test/integration/functional_test.go b/test/integration/functional_test.go index a8ced7a510..5186eae177 100644 --- a/test/integration/functional_test.go +++ b/test/integration/functional_test.go @@ -36,6 +36,7 @@ func TestFunctional(t *testing.T) { t.Run("DNS", testClusterDNS) t.Run("Logs", testClusterLogs) t.Run("Addons", testAddons) + t.Run("Registry", testRegistry) t.Run("Dashboard", testDashboard) t.Run("ServicesList", testServicesList) t.Run("Provisioning", testProvisioning) diff --git a/test/integration/util/util.go b/test/integration/util/util.go index 08e1cebb27..056928b6cb 100644 --- a/test/integration/util/util.go +++ b/test/integration/util/util.go @@ -359,6 +359,28 @@ func WaitForIngressControllerRunning(t *testing.T) error { return nil } +// WaitForDockerRegistryRunning waits until docker registry pod to be running +func WaitForDockerRegistryRunning(t *testing.T) error { + client, err := commonutil.GetClient() + if err != nil { + return errors.Wrap(err, "getting kubernetes client") + } + + if err := commonutil.WaitForRCToStabilize(client, "kube-system", "registry", time.Minute*10); err != nil { + return errors.Wrap(err, "waiting for registry replicacontroller to stabilize") + } + + registrySelector := labels.SelectorFromSet(labels.Set(map[string]string{"kubernetes.io/minikube-addons": "registry"})) + if err := commonutil.WaitForPodsWithLabelRunning(client, "kube-system", registrySelector); err != nil { + return errors.Wrap(err, "waiting for registry pods") + } + proxySelector := labels.SelectorFromSet(labels.Set(map[string]string{"kubernetes.io/minikube-addons": "registry-proxy"})) + if err := commonutil.WaitForPodsWithLabelRunning(client, "kube-system", proxySelector); err != nil { + return errors.Wrap(err, "waiting for registry-proxy pods") + } + return nil +} + // WaitForIngressDefaultBackendRunning waits until ingress default backend pod to be running func WaitForIngressDefaultBackendRunning(t *testing.T) error { client, err := commonutil.GetClient() From ad97983d9ef9a0c9fa94dbbc047b3e6aa59617cc Mon Sep 17 00:00:00 2001 From: Jose Donizetti Date: Fri, 28 Jun 2019 16:15:05 -0300 Subject: [PATCH 03/16] # This is a combination of 8 commits. # This is the 1st commit message: Fix doc comment version.gitCommitID doc # This is the commit message #2: Add hyperkit doc # This is the commit message #3: Add commit id to docker-machine-driver-kvm2 version # This is the commit message #4: removed label selector for registry-proxy daemonset # This is the commit message #5: Add support to custom qemu uri on kvm2 driver # This is the commit message #6: Improve hyperkit vm stop # This is the commit message #7: Make virtualbox DNS settings configurable # This is the commit message #8: added integration tests for registry addon --- Makefile | 11 ++-- cmd/drivers/kvm/main.go | 5 +- cmd/minikube/cmd/start.go | 11 +++- .../addons/registry/registry-proxy.yaml.tmpl | 4 +- docs/drivers.md | 2 +- pkg/drivers/hyperkit/driver.go | 25 +++++++++- pkg/drivers/kvm/domain.go | 8 +-- pkg/drivers/kvm/kvm.go | 8 ++- pkg/drivers/kvm/network.go | 9 ++-- pkg/drivers/kvm/version.go | 8 +++ pkg/minikube/config/types.go | 5 +- pkg/minikube/drivers/kvm/driver.go | 2 +- pkg/minikube/drivers/kvm2/driver.go | 4 +- pkg/minikube/drivers/virtualbox/driver.go | 4 +- pkg/version/version.go | 2 +- test/integration/addons_test.go | 50 +++++++++++++++++++ test/integration/functional_test.go | 1 + test/integration/start_stop_delete_test.go | 1 + test/integration/util/util.go | 22 ++++++++ 19 files changed, 154 insertions(+), 28 deletions(-) diff --git a/Makefile b/Makefile index 720c51376d..ccc6d1eb87 100755 --- a/Makefile +++ b/Makefile @@ -83,6 +83,9 @@ CMD_SOURCE_DIRS = cmd pkg SOURCE_DIRS = $(CMD_SOURCE_DIRS) test SOURCE_PACKAGES = ./cmd/... ./pkg/... ./test/... +# kvm2 ldflags +KVM2_LDFLAGS := -X k8s.io/minikube/pkg/drivers/kvm.version=$(VERSION) -X k8s.io/minikube/pkg/drivers/kvm.gitCommitID=$(COMMIT) + # $(call DOCKER, image, command) define DOCKER docker run --rm -e GOCACHE=/app/.cache -e IN_DOCKER=1 --user $(shell id -u):$(shell id -g) -w /app -v $(PWD):/app -v $(GOPATH):/go --entrypoint /bin/bash $(1) -c '$(2)' @@ -387,11 +390,11 @@ release-minikube: out/minikube checksum gsutil cp out/minikube-$(GOOS)-$(GOARCH).sha256 $(MINIKUBE_UPLOAD_LOCATION)/$(MINIKUBE_VERSION)/minikube-$(GOOS)-$(GOARCH).sha256 out/docker-machine-driver-kvm2: - go build \ - -installsuffix "static" \ - -ldflags "-X k8s.io/minikube/pkg/drivers/kvm.version=$(VERSION)" \ + go build \ + -installsuffix "static" \ + -ldflags="$(KVM2_LDFLAGS)" \ -tags libvirt.1.3.1 \ - -o $(BUILD_DIR)/docker-machine-driver-kvm2 \ + -o $(BUILD_DIR)/docker-machine-driver-kvm2 \ k8s.io/minikube/cmd/drivers/kvm chmod +X $@ diff --git a/cmd/drivers/kvm/main.go b/cmd/drivers/kvm/main.go index 2d9134bcef..455404b7c2 100644 --- a/cmd/drivers/kvm/main.go +++ b/cmd/drivers/kvm/main.go @@ -27,8 +27,9 @@ import ( ) func main() { - if len(os.Args) > 1 && os.Args[1] == "--version" { - fmt.Println(kvm.GetVersion()) + if len(os.Args) > 1 && os.Args[1] == "version" { + fmt.Println("version:", kvm.GetVersion()) + fmt.Println("commit:", kvm.GetGitCommitID()) return } diff --git a/cmd/minikube/cmd/start.go b/cmd/minikube/cmd/start.go index 0999d69164..309162120d 100644 --- a/cmd/minikube/cmd/start.go +++ b/cmd/minikube/cmd/start.go @@ -77,6 +77,7 @@ const ( enableDefaultCNI = "enable-default-cni" hypervVirtualSwitch = "hyperv-virtual-switch" kvmNetwork = "kvm-network" + kvmQemuURI = "kvm-qemu-uri" keepContext = "keep-context" createMount = "mount" featureGates = "feature-gates" @@ -97,6 +98,8 @@ const ( embedCerts = "embed-certs" noVTXCheck = "no-vtx-check" downloadOnly = "download-only" + dnsProxy = "dns-proxy" + hostDNSResolver = "host-dns-resolver" ) var ( @@ -122,6 +125,7 @@ func init() { startCmd.Flags().String(hostOnlyCIDR, "192.168.99.1/24", "The CIDR to be used for the minikube VM (only supported with Virtualbox driver)") startCmd.Flags().String(hypervVirtualSwitch, "", "The hyperv virtual switch name. Defaults to first found. (only supported with HyperV driver)") startCmd.Flags().String(kvmNetwork, "default", "The KVM network name. (only supported with KVM driver)") + startCmd.Flags().String(kvmQemuURI, "qemu:///system", "The KVM QEMU connection URI. (works only with kvm2 driver on linux)") startCmd.Flags().String(xhyveDiskDriver, "ahci-hd", "The disk driver to use [ahci-hd|virtio-blk] (only supported with xhyve driver)") startCmd.Flags().StringSlice(nfsShare, []string{}, "Local folders to share with Guest via NFS mounts (Only supported on with hyperkit now)") startCmd.Flags().String(nfsSharesRoot, "/nfsshares", "Where to root the NFS Shares (defaults to /nfsshares, only supported with hyperkit now)") @@ -156,6 +160,8 @@ func init() { startCmd.Flags().Bool(gpu, false, "Enable experimental NVIDIA GPU support in minikube (works only with kvm2 driver on Linux)") startCmd.Flags().Bool(hidden, false, "Hide the hypervisor signature from the guest in minikube (works only with kvm2 driver on Linux)") startCmd.Flags().Bool(noVTXCheck, false, "Disable checking for the availability of hardware virtualization before the vm is started (virtualbox)") + startCmd.Flags().Bool(dnsProxy, false, "Enable proxy for NAT DNS requests (virtualbox)") + startCmd.Flags().Bool(hostDNSResolver, true, "Enable host resolver for NAT DNS requests (virtualbox)") if err := viper.BindPFlags(startCmd.Flags()); err != nil { exit.WithError("unable to bind flags", err) } @@ -520,13 +526,16 @@ func generateConfig(cmd *cobra.Command, k8sVersion string) (cfg.Config, error) { RegistryMirror: registryMirror, HostOnlyCIDR: viper.GetString(hostOnlyCIDR), HypervVirtualSwitch: viper.GetString(hypervVirtualSwitch), - KvmNetwork: viper.GetString(kvmNetwork), + KVMNetwork: viper.GetString(kvmNetwork), + KVMQemuURI: viper.GetString(kvmQemuURI), Downloader: pkgutil.DefaultDownloader{}, DisableDriverMounts: viper.GetBool(disableDriverMounts), UUID: viper.GetString(uuid), GPU: viper.GetBool(gpu), Hidden: viper.GetBool(hidden), NoVTXCheck: viper.GetBool(noVTXCheck), + DNSProxy: viper.GetBool(dnsProxy), + HostDNSResolver: viper.GetBool(hostDNSResolver), }, KubernetesConfig: cfg.KubernetesConfig{ KubernetesVersion: k8sVersion, diff --git a/deploy/addons/registry/registry-proxy.yaml.tmpl b/deploy/addons/registry/registry-proxy.yaml.tmpl index 0a818fd9cb..2131be3826 100644 --- a/deploy/addons/registry/registry-proxy.yaml.tmpl +++ b/deploy/addons/registry/registry-proxy.yaml.tmpl @@ -2,7 +2,7 @@ apiVersion: extensions/v1beta1 kind: DaemonSet metadata: labels: - kubernetes.io/minikube-addons: registry + kubernetes.io/minikube-addons: registry-proxy addonmanager.kubernetes.io/mode: Reconcile name: registry-proxy namespace: kube-system @@ -10,7 +10,7 @@ spec: template: metadata: labels: - kubernetes.io/minikube-addons: registry + kubernetes.io/minikube-addons: registry-proxy addonmanager.kubernetes.io/mode: Reconcile spec: containers: diff --git a/docs/drivers.md b/docs/drivers.md index dfdd3e2b1f..9c2b3fccb7 100644 --- a/docs/drivers.md +++ b/docs/drivers.md @@ -99,7 +99,7 @@ virsh net-start default Make sure you are running the lastest version of your driver. ```shell -docker-machine-driver-kvm2 --version +docker-machine-driver-kvm2 version ``` ## Hyperkit driver diff --git a/pkg/drivers/hyperkit/driver.go b/pkg/drivers/hyperkit/driver.go index 94a729d1f7..884fe0fb9f 100644 --- a/pkg/drivers/hyperkit/driver.go +++ b/pkg/drivers/hyperkit/driver.go @@ -54,6 +54,7 @@ const ( "sudo chown root:wheel %s && sudo chmod u+s %s" ) +// Driver is the machine driver for Hyperkit type Driver struct { *drivers.BaseDriver *pkgdrivers.CommonDriver @@ -69,6 +70,7 @@ type Driver struct { VSockPorts []string } +// NewDriver creates a new driver for a host func NewDriver(hostName, storePath string) *Driver { return &Driver{ BaseDriver: &drivers.BaseDriver{ @@ -98,6 +100,7 @@ func (d *Driver) verifyRootPermissions() error { return nil } +// Create a host using the driver's config func (d *Driver) Create() error { if err := d.verifyRootPermissions(); err != nil { return err @@ -194,6 +197,7 @@ func (d *Driver) Remove() error { return nil } +// Restart a host func (d *Driver) Restart() error { return pkgdrivers.Restart(d) } @@ -342,7 +346,26 @@ func (d *Driver) Stop() error { return err } d.cleanupNfsExports() - return d.sendSignal(syscall.SIGTERM) + err := d.sendSignal(syscall.SIGTERM) + if err != nil { + return errors.Wrap(err, fmt.Sprintf("hyperkit sigterm failed")) + } + + // wait 5s for graceful shutdown + for i := 0; i < 5; i++ { + log.Debug("waiting for graceful shutdown") + time.Sleep(time.Second * 1) + s, err := d.GetState() + if err != nil { + return errors.Wrap(err, fmt.Sprintf("hyperkit waiting graceful shutdown failed")) + } + if s == state.Stopped { + return nil + } + } + + log.Debug("sending sigkill") + return d.Kill() } func (d *Driver) extractKernel(isoPath string) error { diff --git a/pkg/drivers/kvm/domain.go b/pkg/drivers/kvm/domain.go index 50b354a29b..88890fa7b5 100644 --- a/pkg/drivers/kvm/domain.go +++ b/pkg/drivers/kvm/domain.go @@ -128,7 +128,7 @@ func randomMAC() (net.HardwareAddr, error) { } func (d *Driver) getDomain() (*libvirt.Domain, *libvirt.Connect, error) { - conn, err := getConnection() + conn, err := getConnection(d.ConnectionURI) if err != nil { return nil, nil, errors.Wrap(err, "getting domain") } @@ -141,8 +141,8 @@ func (d *Driver) getDomain() (*libvirt.Domain, *libvirt.Connect, error) { return dom, conn, nil } -func getConnection() (*libvirt.Connect, error) { - conn, err := libvirt.NewConnect(qemusystem) +func getConnection(connectionURI string) (*libvirt.Connect, error) { + conn, err := libvirt.NewConnect(connectionURI) if err != nil { return nil, errors.Wrap(err, connectionErrorText) } @@ -186,7 +186,7 @@ func (d *Driver) createDomain() (*libvirt.Domain, error) { return nil, errors.Wrap(err, "executing domain xml") } - conn, err := getConnection() + conn, err := getConnection(d.ConnectionURI) if err != nil { return nil, errors.Wrap(err, "Error getting libvirt connection") } diff --git a/pkg/drivers/kvm/kvm.go b/pkg/drivers/kvm/kvm.go index 24cc914a3d..87ce4a0be6 100644 --- a/pkg/drivers/kvm/kvm.go +++ b/pkg/drivers/kvm/kvm.go @@ -82,6 +82,9 @@ type Driver struct { // XML that needs to be added to passthrough GPU devices. DevicesXML string + + // QEMU Connection URI + ConnectionURI string } const ( @@ -107,12 +110,13 @@ func NewDriver(hostName, storePath string) *Driver { Network: defaultNetworkName, DiskPath: filepath.Join(constants.GetMinipath(), "machines", config.GetMachineName(), fmt.Sprintf("%s.rawdisk", config.GetMachineName())), ISO: filepath.Join(constants.GetMinipath(), "machines", config.GetMachineName(), "boot2docker.iso"), + ConnectionURI: qemusystem, } } // PreCommandCheck checks the connection before issuing a command func (d *Driver) PreCommandCheck() error { - conn, err := getConnection() + conn, err := getConnection(d.ConnectionURI) if err != nil { return errors.Wrap(err, "Error connecting to libvirt socket. Have you added yourself to the libvirtd group?") } @@ -424,7 +428,7 @@ func (d *Driver) Stop() (err error) { // Remove a host func (d *Driver) Remove() error { log.Debug("Removing machine...") - conn, err := getConnection() + conn, err := getConnection(d.ConnectionURI) if err != nil { return errors.Wrap(err, "getting connection") } diff --git a/pkg/drivers/kvm/network.go b/pkg/drivers/kvm/network.go index 8a7e4d98dd..7a46f0ae14 100644 --- a/pkg/drivers/kvm/network.go +++ b/pkg/drivers/kvm/network.go @@ -81,7 +81,7 @@ func setupNetwork(conn *libvirt.Connect, name string) error { // ensureNetwork is called on start of the VM func (d *Driver) ensureNetwork() error { - conn, err := getConnection() + conn, err := getConnection(d.ConnectionURI) if err != nil { return errors.Wrap(err, "getting libvirt connection") } @@ -108,12 +108,11 @@ func (d *Driver) ensureNetwork() error { // createNetwork is called during creation of the VM only (and not on start) func (d *Driver) createNetwork() error { - if d.Network == defaultPrivateNetworkName { return fmt.Errorf("KVM network can't be named %s. This is the name of the private network created by minikube", defaultPrivateNetworkName) } - conn, err := getConnection() + conn, err := getConnection(d.ConnectionURI) if err != nil { return errors.Wrap(err, "getting libvirt connection") } @@ -151,7 +150,7 @@ func (d *Driver) createNetwork() error { } func (d *Driver) deleteNetwork() error { - conn, err := getConnection() + conn, err := getConnection(d.ConnectionURI) if err != nil { return errors.Wrap(err, "getting libvirt connection") } @@ -269,7 +268,7 @@ func (d *Driver) checkDomains(conn *libvirt.Connect) error { } func (d *Driver) lookupIP() (string, error) { - conn, err := getConnection() + conn, err := getConnection(d.ConnectionURI) if err != nil { return "", errors.Wrap(err, "getting connection and domain") } diff --git a/pkg/drivers/kvm/version.go b/pkg/drivers/kvm/version.go index 7b0a3a85ce..edd87dde95 100644 --- a/pkg/drivers/kvm/version.go +++ b/pkg/drivers/kvm/version.go @@ -21,7 +21,15 @@ package kvm // version is a private field and should be set when compiling with --ldflags="-X k8s.io/minikube/pkg/drivers/kvm.version=vX.Y.Z" var version = "v0.0.0-unset" +// gitCommitID is a private field and should be set when compiling with --ldflags="-X k8s.io/minikube/pkg/drivers/kvm.gitCommitID=" +var gitCommitID = "" + // GetVersion returns the current docker-machine-driver-kvm2 version func GetVersion() string { return version } + +// GetGitCommitID returns the git commit id from which it is being built +func GetGitCommitID() string { + return gitCommitID +} diff --git a/pkg/minikube/config/types.go b/pkg/minikube/config/types.go index 0aa61d402a..c7c0cb0051 100644 --- a/pkg/minikube/config/types.go +++ b/pkg/minikube/config/types.go @@ -45,7 +45,8 @@ type MachineConfig struct { RegistryMirror []string HostOnlyCIDR string // Only used by the virtualbox driver HypervVirtualSwitch string - KvmNetwork string // Only used by the KVM driver + KVMNetwork string // Only used by the KVM driver + KVMQemuURI string // Only used by kvm2 Downloader util.ISODownloader `json:"-"` DockerOpt []string // Each entry is formatted as KEY=VALUE. DisableDriverMounts bool // Only used by virtualbox and xhyve @@ -55,6 +56,8 @@ type MachineConfig struct { GPU bool // Only used by kvm2 Hidden bool // Only used by kvm2 NoVTXCheck bool // Only used by virtualbox + DNSProxy bool // Only used by virtualbox + HostDNSResolver bool // Only used by virtualbox } // KubernetesConfig contains the parameters used to configure the VM Kubernetes. diff --git a/pkg/minikube/drivers/kvm/driver.go b/pkg/minikube/drivers/kvm/driver.go index 989e74276f..451712b4c7 100644 --- a/pkg/minikube/drivers/kvm/driver.go +++ b/pkg/minikube/drivers/kvm/driver.go @@ -64,7 +64,7 @@ func createKVMHost(config cfg.MachineConfig) interface{} { }, Memory: config.Memory, CPU: config.CPUs, - Network: config.KvmNetwork, + Network: config.KVMNetwork, PrivateNetwork: "docker-machines", Boot2DockerURL: config.Downloader.GetISOFileURI(config.MinikubeISO), DiskSize: config.DiskSize, diff --git a/pkg/minikube/drivers/kvm2/driver.go b/pkg/minikube/drivers/kvm2/driver.go index 93395611a8..511f277a86 100644 --- a/pkg/minikube/drivers/kvm2/driver.go +++ b/pkg/minikube/drivers/kvm2/driver.go @@ -53,6 +53,7 @@ type kvmDriver struct { DiskPath string GPU bool Hidden bool + ConnectionURI string } func createKVM2Host(config cfg.MachineConfig) interface{} { @@ -64,7 +65,7 @@ func createKVM2Host(config cfg.MachineConfig) interface{} { }, Memory: config.Memory, CPU: config.CPUs, - Network: config.KvmNetwork, + Network: config.KVMNetwork, PrivateNetwork: "minikube-net", Boot2DockerURL: config.Downloader.GetISOFileURI(config.MinikubeISO), DiskSize: config.DiskSize, @@ -72,5 +73,6 @@ func createKVM2Host(config cfg.MachineConfig) interface{} { ISO: filepath.Join(constants.GetMinipath(), "machines", cfg.GetMachineName(), "boot2docker.iso"), GPU: config.GPU, Hidden: config.Hidden, + ConnectionURI: config.KVMQemuURI, } } diff --git a/pkg/minikube/drivers/virtualbox/driver.go b/pkg/minikube/drivers/virtualbox/driver.go index 1a1c50d6c1..78441699d1 100644 --- a/pkg/minikube/drivers/virtualbox/driver.go +++ b/pkg/minikube/drivers/virtualbox/driver.go @@ -54,8 +54,8 @@ func createVirtualboxHost(config cfg.MachineConfig) interface{} { d.NoVTXCheck = config.NoVTXCheck d.NatNicType = defaultVirtualboxNicType d.HostOnlyNicType = defaultVirtualboxNicType - d.DNSProxy = false - d.HostDNSResolver = true + d.DNSProxy = config.DNSProxy + d.HostDNSResolver = config.HostDNSResolver return d } diff --git a/pkg/version/version.go b/pkg/version/version.go index 62727d9237..727035115b 100644 --- a/pkg/version/version.go +++ b/pkg/version/version.go @@ -30,7 +30,7 @@ const VersionPrefix = "v" // version is a private field and should be set when compiling with --ldflags="-X k8s.io/minikube/pkg/version.version=vX.Y.Z" var version = "v0.0.0-unset" -// version is a private field and should be set when compiling with --ldflags="-X k8s.io/minikube/pkg/version.gitCommitID=" +// gitCommitID is a private field and should be set when compiling with --ldflags="-X k8s.io/minikube/pkg/version.gitCommitID=" var gitCommitID = "" // isoVersion is a private field and should be set when compiling with --ldflags="-X k8s.io/minikube/pkg/version.isoVersion=vX.Y.Z" diff --git a/test/integration/addons_test.go b/test/integration/addons_test.go index 85b56a1c71..629401cf83 100644 --- a/test/integration/addons_test.go +++ b/test/integration/addons_test.go @@ -190,7 +190,57 @@ func testServicesList(t *testing.T) { t.Fatalf(err.Error()) } } +func testRegistry(t *testing.T) { + t.Parallel() + minikubeRunner := NewMinikubeRunner(t) + kubectlRunner := util.NewKubectlRunner(t) + minikubeRunner.RunCommand("addons enable registry", true) + t.Log("wait for registry to come up") + if err := util.WaitForDockerRegistryRunning(t); err != nil { + t.Fatalf("waiting for registry to be up: %v", err) + } + + // Check access from outside the cluster on port 5000, validing connectivity via registry-proxy + checkExternalAccess := func() error { + t.Log("checking registry access from outside cluster") + expectedStr := "200" + runCmd := fmt.Sprintf("curl -sS -o /dev/null -w '%%{http_code}' http://127.0.0.1:5000") + externalCheckOutput, _ := minikubeRunner.SSH(runCmd) + if !strings.Contains(externalCheckOutput, expectedStr) { + return fmt.Errorf("ExpectedStr externalCheckOutput to be: %s. Output was: %s", expectedStr, externalCheckOutput) + } + return nil + } + + if err := util.Retry(t, checkExternalAccess, 2*time.Second, 5); err != nil { + t.Fatalf(err.Error()) + } + // check access from inside the cluster via a busybox container running inside cluster + t.Log("checking registry access from inside cluster") + expectedStr := "200" + out, _ := kubectlRunner.RunCommand([]string{ + "run", + "registry-test", + "--restart=Never", + "--image=busybox", + "-it", + "--", + "sh", + "-c", + "wget --spider -S 'http://registry.kube-system.svc.cluster.local' 2>&1 | grep 'HTTP/' | awk '{print $2}'"}) + internalCheckOutput := string(out) + if !strings.Contains(internalCheckOutput, expectedStr) { + t.Fatalf("ExpectedStr internalCheckOutput to be: %s. Output was: %s", expectedStr, internalCheckOutput) + } + + defer func() { + if _, err := kubectlRunner.RunCommand([]string{"delete", "pod", "registry-test"}); err != nil { + t.Fatalf("failed to delete pod registry-test") + } + }() + minikubeRunner.RunCommand("addons disable registry", true) +} func testGvisor(t *testing.T) { minikubeRunner := NewMinikubeRunner(t) minikubeRunner.RunCommand("addons enable gvisor", true) diff --git a/test/integration/functional_test.go b/test/integration/functional_test.go index a8ced7a510..5186eae177 100644 --- a/test/integration/functional_test.go +++ b/test/integration/functional_test.go @@ -36,6 +36,7 @@ func TestFunctional(t *testing.T) { t.Run("DNS", testClusterDNS) t.Run("Logs", testClusterLogs) t.Run("Addons", testAddons) + t.Run("Registry", testRegistry) t.Run("Dashboard", testDashboard) t.Run("ServicesList", testServicesList) t.Run("Provisioning", testProvisioning) diff --git a/test/integration/start_stop_delete_test.go b/test/integration/start_stop_delete_test.go index 7a5b9392e3..5810919359 100644 --- a/test/integration/start_stop_delete_test.go +++ b/test/integration/start_stop_delete_test.go @@ -41,6 +41,7 @@ func TestStartStop(t *testing.T) { // default is the network created by libvirt, if we change the name minikube won't boot // because the given network doesn't exist "--kvm-network=default", + "--kvm-qemu-uri=qemu:///system", }}, {"feature_gates_newest_cni", []string{ "--feature-gates", diff --git a/test/integration/util/util.go b/test/integration/util/util.go index 08e1cebb27..056928b6cb 100644 --- a/test/integration/util/util.go +++ b/test/integration/util/util.go @@ -359,6 +359,28 @@ func WaitForIngressControllerRunning(t *testing.T) error { return nil } +// WaitForDockerRegistryRunning waits until docker registry pod to be running +func WaitForDockerRegistryRunning(t *testing.T) error { + client, err := commonutil.GetClient() + if err != nil { + return errors.Wrap(err, "getting kubernetes client") + } + + if err := commonutil.WaitForRCToStabilize(client, "kube-system", "registry", time.Minute*10); err != nil { + return errors.Wrap(err, "waiting for registry replicacontroller to stabilize") + } + + registrySelector := labels.SelectorFromSet(labels.Set(map[string]string{"kubernetes.io/minikube-addons": "registry"})) + if err := commonutil.WaitForPodsWithLabelRunning(client, "kube-system", registrySelector); err != nil { + return errors.Wrap(err, "waiting for registry pods") + } + proxySelector := labels.SelectorFromSet(labels.Set(map[string]string{"kubernetes.io/minikube-addons": "registry-proxy"})) + if err := commonutil.WaitForPodsWithLabelRunning(client, "kube-system", proxySelector); err != nil { + return errors.Wrap(err, "waiting for registry-proxy pods") + } + return nil +} + // WaitForIngressDefaultBackendRunning waits until ingress default backend pod to be running func WaitForIngressDefaultBackendRunning(t *testing.T) error { client, err := commonutil.GetClient() From 6fa12ea0368d53efc2e654f45bc20f6f1552fd54 Mon Sep 17 00:00:00 2001 From: Ben Ebsworth Date: Sat, 29 Jun 2019 21:33:19 +1000 Subject: [PATCH 04/16] fixed linting --- test/integration/addons_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/integration/addons_test.go b/test/integration/addons_test.go index 629401cf83..f28d3bb05e 100644 --- a/test/integration/addons_test.go +++ b/test/integration/addons_test.go @@ -198,9 +198,9 @@ func testRegistry(t *testing.T) { t.Log("wait for registry to come up") if err := util.WaitForDockerRegistryRunning(t); err != nil { - t.Fatalf("waiting for registry to be up: %v", err) + t.Fatalf("waiting for registry to be up: %v", err) } - + // Check access from outside the cluster on port 5000, validing connectivity via registry-proxy checkExternalAccess := func() error { t.Log("checking registry access from outside cluster") @@ -233,11 +233,11 @@ func testRegistry(t *testing.T) { if !strings.Contains(internalCheckOutput, expectedStr) { t.Fatalf("ExpectedStr internalCheckOutput to be: %s. Output was: %s", expectedStr, internalCheckOutput) } - + defer func() { if _, err := kubectlRunner.RunCommand([]string{"delete", "pod", "registry-test"}); err != nil { t.Fatalf("failed to delete pod registry-test") - } + } }() minikubeRunner.RunCommand("addons disable registry", true) } From 05683a0d01dcb58f132750591cf898b95a03f80f Mon Sep 17 00:00:00 2001 From: Ben Ebsworth Date: Mon, 1 Jul 2019 06:31:52 +1000 Subject: [PATCH 05/16] moved to using retryablehttp --- test/integration/addons_test.go | 27 ++++++++++++++++++++++----- test/integration/functional_test.go | 26 +++++++++++++------------- 2 files changed, 35 insertions(+), 18 deletions(-) diff --git a/test/integration/addons_test.go b/test/integration/addons_test.go index f28d3bb05e..2d80b15ca4 100644 --- a/test/integration/addons_test.go +++ b/test/integration/addons_test.go @@ -204,12 +204,29 @@ func testRegistry(t *testing.T) { // Check access from outside the cluster on port 5000, validing connectivity via registry-proxy checkExternalAccess := func() error { t.Log("checking registry access from outside cluster") - expectedStr := "200" - runCmd := fmt.Sprintf("curl -sS -o /dev/null -w '%%{http_code}' http://127.0.0.1:5000") - externalCheckOutput, _ := minikubeRunner.SSH(runCmd) - if !strings.Contains(externalCheckOutput, expectedStr) { - return fmt.Errorf("ExpectedStr externalCheckOutput to be: %s. Output was: %s", expectedStr, externalCheckOutput) + _, out := minikubeRunner.RunDaemon("ip") + s, err := readLineWithTimeout(out, 180*time.Second) + + if err != nil { + t.Fatalf("failed to read minikubeIP: %v", err) } + + registryEndpoint := "http://" + strings.TrimSpace(s) + "5000" + u, err := url.Parse(registryEndpoint) + + if err != nil { + t.Fatalf("failed to parse %q: %v", s, err) + } + + resp, err := retryablehttp.Get(u.String()) + if err != nil { + t.Fatalf("failed get: %v", err) + } + + if resp.StatusCode != http.StatusOK { + t.Errorf("%s returned status code %d, expected %d.\n", registryEndpoint, resp.StatusCode, http.StatusOK) + } + return nil } diff --git a/test/integration/functional_test.go b/test/integration/functional_test.go index 5186eae177..bb39ea3461 100644 --- a/test/integration/functional_test.go +++ b/test/integration/functional_test.go @@ -33,21 +33,21 @@ func TestFunctional(t *testing.T) { // before we run any other tests. t.Run("Status", testClusterStatus) - t.Run("DNS", testClusterDNS) - t.Run("Logs", testClusterLogs) - t.Run("Addons", testAddons) + // t.Run("DNS", testClusterDNS) + // t.Run("Logs", testClusterLogs) + // t.Run("Addons", testAddons) t.Run("Registry", testRegistry) - t.Run("Dashboard", testDashboard) - t.Run("ServicesList", testServicesList) - t.Run("Provisioning", testProvisioning) - t.Run("Tunnel", testTunnel) + // t.Run("Dashboard", testDashboard) + // t.Run("ServicesList", testServicesList) + // t.Run("Provisioning", testProvisioning) + // t.Run("Tunnel", testTunnel) - if !usingNoneDriver(r) { - t.Run("EnvVars", testClusterEnv) - t.Run("SSH", testClusterSSH) - t.Run("IngressController", testIngressController) - t.Run("Mounting", testMounting) - } + // if !usingNoneDriver(r) { + // t.Run("EnvVars", testClusterEnv) + // t.Run("SSH", testClusterSSH) + // t.Run("IngressController", testIngressController) + // t.Run("Mounting", testMounting) + // } } func TestFunctionalContainerd(t *testing.T) { From 637262cea2dc400960e55640bcb3f4efcb8b7c9e Mon Sep 17 00:00:00 2001 From: Ben Ebsworth Date: Mon, 1 Jul 2019 06:42:19 +1000 Subject: [PATCH 06/16] re-added int testds --- test/integration/functional_test.go | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/test/integration/functional_test.go b/test/integration/functional_test.go index bb39ea3461..5186eae177 100644 --- a/test/integration/functional_test.go +++ b/test/integration/functional_test.go @@ -33,21 +33,21 @@ func TestFunctional(t *testing.T) { // before we run any other tests. t.Run("Status", testClusterStatus) - // t.Run("DNS", testClusterDNS) - // t.Run("Logs", testClusterLogs) - // t.Run("Addons", testAddons) + t.Run("DNS", testClusterDNS) + t.Run("Logs", testClusterLogs) + t.Run("Addons", testAddons) t.Run("Registry", testRegistry) - // t.Run("Dashboard", testDashboard) - // t.Run("ServicesList", testServicesList) - // t.Run("Provisioning", testProvisioning) - // t.Run("Tunnel", testTunnel) + t.Run("Dashboard", testDashboard) + t.Run("ServicesList", testServicesList) + t.Run("Provisioning", testProvisioning) + t.Run("Tunnel", testTunnel) - // if !usingNoneDriver(r) { - // t.Run("EnvVars", testClusterEnv) - // t.Run("SSH", testClusterSSH) - // t.Run("IngressController", testIngressController) - // t.Run("Mounting", testMounting) - // } + if !usingNoneDriver(r) { + t.Run("EnvVars", testClusterEnv) + t.Run("SSH", testClusterSSH) + t.Run("IngressController", testIngressController) + t.Run("Mounting", testMounting) + } } func TestFunctionalContainerd(t *testing.T) { From 8b2d1ec2e648e962248ea688a368724e2d27640a Mon Sep 17 00:00:00 2001 From: Ben Ebsworth Date: Mon, 1 Jul 2019 13:01:28 +1000 Subject: [PATCH 07/16] fixed registryEndpoint string --- pkg/minikube/extract/testdata/test.json | 5 ++++- test/integration/addons_test.go | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/pkg/minikube/extract/testdata/test.json b/pkg/minikube/extract/testdata/test.json index c7a3cf31ed..401e6db3eb 100644 --- a/pkg/minikube/extract/testdata/test.json +++ b/pkg/minikube/extract/testdata/test.json @@ -1,4 +1,7 @@ { + "Hint: This is not a URL, come on.": "", "Holy cow I'm in a loop!": "Something else", - "This was a choice: %s": "Something" + "This is a variable with a string assigned": "", + "This was a choice: %s": "Something", + "Wow another string: %s": "" } \ No newline at end of file diff --git a/test/integration/addons_test.go b/test/integration/addons_test.go index 2d80b15ca4..8949c86242 100644 --- a/test/integration/addons_test.go +++ b/test/integration/addons_test.go @@ -211,7 +211,7 @@ func testRegistry(t *testing.T) { t.Fatalf("failed to read minikubeIP: %v", err) } - registryEndpoint := "http://" + strings.TrimSpace(s) + "5000" + registryEndpoint := "http://" + strings.TrimSpace(s) + ":5000" u, err := url.Parse(registryEndpoint) if err != nil { From 39a136fdb9392262e23f432565b4c86a7bc88bf7 Mon Sep 17 00:00:00 2001 From: Ben Ebsworth Date: Sat, 6 Jul 2019 18:42:40 +1000 Subject: [PATCH 08/16] fix raising fatal error on retryablehttp --- test/integration/addons_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/addons_test.go b/test/integration/addons_test.go index 8949c86242..d4678ec88d 100644 --- a/test/integration/addons_test.go +++ b/test/integration/addons_test.go @@ -220,7 +220,7 @@ func testRegistry(t *testing.T) { resp, err := retryablehttp.Get(u.String()) if err != nil { - t.Fatalf("failed get: %v", err) + t.Errorf("failed get: %v", err) } if resp.StatusCode != http.StatusOK { From 4642b66ebcb7af41697ec32e911e99ed7782ea8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20F=20Bj=C3=B6rklund?= Date: Wed, 10 Jul 2019 13:47:24 +0200 Subject: [PATCH 09/16] Don't lie about creating a VM with none driver --- pkg/minikube/cluster/cluster.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/minikube/cluster/cluster.go b/pkg/minikube/cluster/cluster.go index f1b91d5d12..25bd69fa83 100644 --- a/pkg/minikube/cluster/cluster.go +++ b/pkg/minikube/cluster/cluster.go @@ -346,7 +346,9 @@ To disable this message, run [minikube config set ShowDriverDeprecationNotificat func createHost(api libmachine.API, config cfg.MachineConfig) (*host.Host, error) { preCreateHost(&config) - console.OutStyle(console.StartingVM, "Creating %s VM (CPUs=%d, Memory=%dMB, Disk=%dMB) ...", config.VMDriver, config.CPUs, config.Memory, config.DiskSize) + if config.VMDriver != constants.DriverNone { + console.OutStyle(console.StartingVM, "Creating %s VM (CPUs=%d, Memory=%dMB, Disk=%dMB) ...", config.VMDriver, config.CPUs, config.Memory, config.DiskSize) + } def, err := registry.Driver(config.VMDriver) if err != nil { if err == registry.ErrDriverNotFound { From fdb4f9b167b4fc338e8e5324617a2b8a2bfed072 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20F=20Bj=C3=B6rklund?= Date: Wed, 10 Jul 2019 17:27:21 +0200 Subject: [PATCH 10/16] Show "localhost" information for none driver --- go.mod | 1 + go.sum | 2 ++ pkg/minikube/cluster/cluster.go | 13 +++++++++++++ 3 files changed, 16 insertions(+) diff --git a/go.mod b/go.mod index 3bf3145d4d..602798f547 100644 --- a/go.mod +++ b/go.mod @@ -73,6 +73,7 @@ require ( github.com/r2d4/external-storage v0.0.0-20171222174501-8c0e8605dc7b github.com/russross/blackfriday v0.0.0-20151117072312-300106c228d5 // indirect github.com/samalba/dockerclient v0.0.0-20160414174713-91d7393ff859 // indirect + github.com/shirou/gopsutil v2.18.12+incompatible github.com/shurcooL/sanitized_anchor_name v0.0.0-20151028001915-10ef21a441db // indirect github.com/sirupsen/logrus v1.4.1 // indirect github.com/spf13/afero v0.0.0-20160816080757-b28a7effac97 // indirect diff --git a/go.sum b/go.sum index fb9399dd7a..c7af4fd316 100644 --- a/go.sum +++ b/go.sum @@ -161,6 +161,8 @@ github.com/russross/blackfriday v0.0.0-20151117072312-300106c228d5 h1:+6eORf9Bt4 github.com/russross/blackfriday v0.0.0-20151117072312-300106c228d5/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= github.com/samalba/dockerclient v0.0.0-20160414174713-91d7393ff859 h1:XRl74t6xHKI5EVIjDI5nPlHRq0bHED9/TjQuD8/UMkE= github.com/samalba/dockerclient v0.0.0-20160414174713-91d7393ff859/go.mod h1:yeYR4SlaRZJct6lwNRKR+qd0CocnxxWDE7Vh5dxsn/w= +github.com/shirou/gopsutil v2.18.12+incompatible h1:1eaJvGomDnH74/5cF4CTmTbLHAriGFsTZppLXDX93OM= +github.com/shirou/gopsutil v2.18.12+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/shurcooL/sanitized_anchor_name v0.0.0-20151028001915-10ef21a441db h1:lrOUn8raSZS/V52c7elGaEyuogqSkEo/Qj2Auo2G1ik= github.com/shurcooL/sanitized_anchor_name v0.0.0-20151028001915-10ef21a441db/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/sirupsen/logrus v1.4.1 h1:GL2rEmy6nsikmW0r8opw9JIRScdMF5hA8cOYLH7In1k= diff --git a/pkg/minikube/cluster/cluster.go b/pkg/minikube/cluster/cluster.go index 25bd69fa83..b768922b76 100644 --- a/pkg/minikube/cluster/cluster.go +++ b/pkg/minikube/cluster/cluster.go @@ -37,6 +37,9 @@ import ( "github.com/docker/machine/libmachine/state" "github.com/golang/glog" "github.com/pkg/errors" + "github.com/shirou/gopsutil/cpu" + "github.com/shirou/gopsutil/disk" + "github.com/shirou/gopsutil/mem" "github.com/spf13/viper" cfg "k8s.io/minikube/pkg/minikube/config" "k8s.io/minikube/pkg/minikube/console" @@ -344,11 +347,21 @@ To disable this message, run [minikube config set ShowDriverDeprecationNotificat } } +func megs(bytes uint64) int { + return int(bytes / 1024 / 1024) +} + func createHost(api libmachine.API, config cfg.MachineConfig) (*host.Host, error) { preCreateHost(&config) if config.VMDriver != constants.DriverNone { console.OutStyle(console.StartingVM, "Creating %s VM (CPUs=%d, Memory=%dMB, Disk=%dMB) ...", config.VMDriver, config.CPUs, config.Memory, config.DiskSize) + } else { + i, _ := cpu.Info() + v, _ := mem.VirtualMemory() + d, _ := disk.Usage("/") + console.OutStyle(console.StartingNone, "Running on localhost (CPUs=%d, Memory=%dMB, Disk=%dMB) ...", len(i), megs(v.Total), megs(d.Total)) } + def, err := registry.Driver(config.VMDriver) if err != nil { if err == registry.ErrDriverNotFound { From 365b208b6d51d60c4eb76468d22ab67241c7de29 Mon Sep 17 00:00:00 2001 From: Ben Ebsworth Date: Fri, 12 Jul 2019 06:38:26 +1000 Subject: [PATCH 11/16] reverting unexpected change in test data --- pkg/minikube/extract/testdata/test.json | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/pkg/minikube/extract/testdata/test.json b/pkg/minikube/extract/testdata/test.json index 401e6db3eb..c7a3cf31ed 100644 --- a/pkg/minikube/extract/testdata/test.json +++ b/pkg/minikube/extract/testdata/test.json @@ -1,7 +1,4 @@ { - "Hint: This is not a URL, come on.": "", "Holy cow I'm in a loop!": "Something else", - "This is a variable with a string assigned": "", - "This was a choice: %s": "Something", - "Wow another string: %s": "" + "This was a choice: %s": "Something" } \ No newline at end of file From 7584d6aa08f859272f8307248b615fce925e0d32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20F=20Bj=C3=B6rklund?= Date: Sun, 14 Jul 2019 10:19:54 +0200 Subject: [PATCH 12/16] Move hostInfo into function, add error checking --- pkg/minikube/cluster/cluster.go | 38 +++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/pkg/minikube/cluster/cluster.go b/pkg/minikube/cluster/cluster.go index b768922b76..063a94290a 100644 --- a/pkg/minikube/cluster/cluster.go +++ b/pkg/minikube/cluster/cluster.go @@ -347,19 +347,49 @@ To disable this message, run [minikube config set ShowDriverDeprecationNotificat } } +type hostInfo struct { + Memory int + CPUs int + DiskSize int +} + func megs(bytes uint64) int { return int(bytes / 1024 / 1024) } +func getHostInfo() (*hostInfo, error) { + i, err := cpu.Info() + if err != nil { + glog.Warningf("Unable to get cpu info: %v", err) + return nil, err + } + v, err := mem.VirtualMemory() + if err != nil { + glog.Warningf("Unable to get mem info: %v", err) + return nil, err + } + d, err := disk.Usage("/") + if err != nil { + glog.Warningf("Unable to get disk info: %v", err) + return nil, err + } + + var info hostInfo + info.CPUs = len(i) + info.Memory = megs(v.Total) + info.DiskSize = megs(d.Total) + return &info, nil +} + func createHost(api libmachine.API, config cfg.MachineConfig) (*host.Host, error) { preCreateHost(&config) if config.VMDriver != constants.DriverNone { console.OutStyle(console.StartingVM, "Creating %s VM (CPUs=%d, Memory=%dMB, Disk=%dMB) ...", config.VMDriver, config.CPUs, config.Memory, config.DiskSize) } else { - i, _ := cpu.Info() - v, _ := mem.VirtualMemory() - d, _ := disk.Usage("/") - console.OutStyle(console.StartingNone, "Running on localhost (CPUs=%d, Memory=%dMB, Disk=%dMB) ...", len(i), megs(v.Total), megs(d.Total)) + info, err := getHostInfo() + if err == nil { + console.OutStyle(console.StartingNone, "Running on localhost (CPUs=%d, Memory=%dMB, Disk=%dMB) ...", info.CPUs, info.Memory, info.DiskSize) + } } def, err := registry.Driver(config.VMDriver) From de6112f7565543497aa1d536a854cffed94b9dbc Mon Sep 17 00:00:00 2001 From: cclauss Date: Mon, 15 Jul 2019 19:29:58 +0200 Subject: [PATCH 13/16] Lint Python code for syntax errors and undefined names Lint Python code for issues like #4741 and #4762. --- .travis.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 649c6a6190..ad574c2768 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,12 @@ language: go os: linux -sudo: required -go: - - 1.x +matrix: + include: + - go: 1.x + - language: python + before_install: pip install flake8 + script: flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics before_install: - sudo apt-get install -y libvirt-dev From 1d3cea757bfe71722d90da252d1f31994c6930c5 Mon Sep 17 00:00:00 2001 From: tstromberg Date: Wed, 17 Jul 2019 09:58:31 -0700 Subject: [PATCH 14/16] Update github issues URL to chooser --- pkg/minikube/exit/exit.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/minikube/exit/exit.go b/pkg/minikube/exit/exit.go index b92367f381..a814aad547 100644 --- a/pkg/minikube/exit/exit.go +++ b/pkg/minikube/exit/exit.go @@ -75,7 +75,7 @@ func WithProblem(msg string, p *problem.Problem) { p.Display() console.Err("\n") console.ErrStyle(console.Sad, "If the above advice does not help, please let us know: ") - console.ErrStyle(console.URL, "https://github.com/kubernetes/minikube/issues/new") + console.ErrStyle(console.URL, "https://github.com/kubernetes/minikube/issues/new/choose") os.Exit(Config) } @@ -102,5 +102,5 @@ func displayError(msg string, err error) { console.Fatal("%s: %v", msg, err) console.Err("\n") console.ErrStyle(console.Sad, "Sorry that minikube crashed. If this was unexpected, we would love to hear from you:") - console.ErrStyle(console.URL, "https://github.com/kubernetes/minikube/issues/new") + console.ErrStyle(console.URL, "https://github.com/kubernetes/minikube/issues/new/choose") } From 6ded92edbe8817f51184ba3e05cee7df84d29ef5 Mon Sep 17 00:00:00 2001 From: Jose Donizetti Date: Wed, 17 Jul 2019 14:19:40 -0300 Subject: [PATCH 15/16] Fix darwin constants --- pkg/minikube/constants/constants_darwin.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/minikube/constants/constants_darwin.go b/pkg/minikube/constants/constants_darwin.go index 2d4e8163ee..91aa8fbb0b 100644 --- a/pkg/minikube/constants/constants_darwin.go +++ b/pkg/minikube/constants/constants_darwin.go @@ -26,6 +26,6 @@ var SupportedVMDrivers = [...]string{ DriverParallels, DriverVmwareFusion, DriverXhyve, - DriverHyperKit, + DriverHyperkit, DriverVmware, } From df7922881ce44c31e8d291dea34c05e715ecb758 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20F=20Bj=C3=B6rklund?= Date: Wed, 17 Jul 2019 19:40:19 +0200 Subject: [PATCH 16/16] Add missing ErrMapFile docs, to make golint happy --- pkg/minikube/extract/extract.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/minikube/extract/extract.go b/pkg/minikube/extract/extract.go index 94aa801a31..b8b1b806f2 100644 --- a/pkg/minikube/extract/extract.go +++ b/pkg/minikube/extract/extract.go @@ -47,6 +47,7 @@ var blacklist = []string{ "opt %s", } +// ErrMapFile is a constant to refer to the err_map file, which contains the Advice strings. const ErrMapFile string = "pkg/minikube/problem/err_map.go" // state is a struct that represent the current state of the extraction process