Merge branch 'master' into faster-kubelet

pull/4744/head
tstromberg 2019-07-17 11:35:47 -07:00
commit 146b87158a
11 changed files with 151 additions and 8 deletions

View File

@ -1,9 +1,12 @@
language: go language: go
os: linux os: linux
sudo: required
go: matrix:
- 1.x include:
- go: 1.x
- language: python
before_install: pip install flake8
script: flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
before_install: before_install:
- sudo apt-get install -y libvirt-dev - sudo apt-get install -y libvirt-dev

View File

@ -2,7 +2,7 @@ apiVersion: extensions/v1beta1
kind: DaemonSet kind: DaemonSet
metadata: metadata:
labels: labels:
kubernetes.io/minikube-addons: registry kubernetes.io/minikube-addons: registry-proxy
addonmanager.kubernetes.io/mode: Reconcile addonmanager.kubernetes.io/mode: Reconcile
name: registry-proxy name: registry-proxy
namespace: kube-system namespace: kube-system
@ -10,6 +10,7 @@ spec:
template: template:
metadata: metadata:
labels: labels:
kubernetes.io/minikube-addons: registry-proxy
addonmanager.kubernetes.io/mode: Reconcile addonmanager.kubernetes.io/mode: Reconcile
spec: spec:
containers: containers:

1
go.mod
View File

@ -73,6 +73,7 @@ require (
github.com/r2d4/external-storage v0.0.0-20171222174501-8c0e8605dc7b github.com/r2d4/external-storage v0.0.0-20171222174501-8c0e8605dc7b
github.com/russross/blackfriday v0.0.0-20151117072312-300106c228d5 // indirect github.com/russross/blackfriday v0.0.0-20151117072312-300106c228d5 // indirect
github.com/samalba/dockerclient v0.0.0-20160414174713-91d7393ff859 // 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/shurcooL/sanitized_anchor_name v0.0.0-20151028001915-10ef21a441db // indirect
github.com/sirupsen/logrus v1.4.1 // indirect github.com/sirupsen/logrus v1.4.1 // indirect
github.com/spf13/afero v0.0.0-20160816080757-b28a7effac97 // indirect github.com/spf13/afero v0.0.0-20160816080757-b28a7effac97 // indirect

2
go.sum
View File

@ -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/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 h1:XRl74t6xHKI5EVIjDI5nPlHRq0bHED9/TjQuD8/UMkE=
github.com/samalba/dockerclient v0.0.0-20160414174713-91d7393ff859/go.mod h1:yeYR4SlaRZJct6lwNRKR+qd0CocnxxWDE7Vh5dxsn/w= 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 h1:lrOUn8raSZS/V52c7elGaEyuogqSkEo/Qj2Auo2G1ik=
github.com/shurcooL/sanitized_anchor_name v0.0.0-20151028001915-10ef21a441db/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= 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= github.com/sirupsen/logrus v1.4.1 h1:GL2rEmy6nsikmW0r8opw9JIRScdMF5hA8cOYLH7In1k=

View File

@ -37,6 +37,9 @@ import (
"github.com/docker/machine/libmachine/state" "github.com/docker/machine/libmachine/state"
"github.com/golang/glog" "github.com/golang/glog"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/shirou/gopsutil/cpu"
"github.com/shirou/gopsutil/disk"
"github.com/shirou/gopsutil/mem"
"github.com/spf13/viper" "github.com/spf13/viper"
cfg "k8s.io/minikube/pkg/minikube/config" cfg "k8s.io/minikube/pkg/minikube/config"
"k8s.io/minikube/pkg/minikube/console" "k8s.io/minikube/pkg/minikube/console"
@ -344,9 +347,51 @@ 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) { func createHost(api libmachine.API, config cfg.MachineConfig) (*host.Host, error) {
preCreateHost(&config) 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)
} else {
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) def, err := registry.Driver(config.VMDriver)
if err != nil { if err != nil {
if err == registry.ErrDriverNotFound { if err == registry.ErrDriverNotFound {

View File

@ -26,6 +26,6 @@ var SupportedVMDrivers = [...]string{
DriverParallels, DriverParallels,
DriverVmwareFusion, DriverVmwareFusion,
DriverXhyve, DriverXhyve,
DriverHyperKit, DriverHyperkit,
DriverVmware, DriverVmware,
} }

View File

@ -75,7 +75,7 @@ func WithProblem(msg string, p *problem.Problem) {
p.Display() p.Display()
console.Err("\n") console.Err("\n")
console.ErrStyle(console.Sad, "If the above advice does not help, please let us know: ") 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) os.Exit(Config)
} }
@ -102,5 +102,5 @@ func displayError(msg string, err error) {
console.Fatal("%s: %v", msg, err) console.Fatal("%s: %v", msg, err)
console.Err("\n") 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.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")
} }

View File

@ -47,6 +47,7 @@ var blacklist = []string{
"opt %s", "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" const ErrMapFile string = "pkg/minikube/problem/err_map.go"
// state is a struct that represent the current state of the extraction process // state is a struct that represent the current state of the extraction process

View File

@ -190,7 +190,74 @@ func testServicesList(t *testing.T) {
t.Fatalf(err.Error()) 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")
_, 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.Errorf("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
}
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) { func testGvisor(t *testing.T) {
mk := NewMinikubeRunner(t, "--wait=false") mk := NewMinikubeRunner(t, "--wait=false")
mk.RunCommand("addons enable gvisor", true) mk.RunCommand("addons enable gvisor", true)

View File

@ -36,6 +36,7 @@ func TestFunctional(t *testing.T) {
t.Run("DNS", testClusterDNS) t.Run("DNS", testClusterDNS)
t.Run("Logs", testClusterLogs) t.Run("Logs", testClusterLogs)
t.Run("Addons", testAddons) t.Run("Addons", testAddons)
t.Run("Registry", testRegistry)
t.Run("Dashboard", testDashboard) t.Run("Dashboard", testDashboard)
t.Run("ServicesList", testServicesList) t.Run("ServicesList", testServicesList)
t.Run("Provisioning", testProvisioning) t.Run("Provisioning", testProvisioning)

View File

@ -359,6 +359,28 @@ func WaitForIngressControllerRunning(t *testing.T) error {
return nil 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 // WaitForIngressDefaultBackendRunning waits until ingress default backend pod to be running
func WaitForIngressDefaultBackendRunning(t *testing.T) error { func WaitForIngressDefaultBackendRunning(t *testing.T) error {
client, err := commonutil.GetClient() client, err := commonutil.GetClient()