From e19e29f60e0215722948eb8e91f44fd90b8af9d3 Mon Sep 17 00:00:00 2001 From: Vasyl Purchel Date: Fri, 25 Oct 2019 17:22:45 +0100 Subject: [PATCH 01/72] Adds dm-crypt support Adds crypt target support in kernel for device mapper Adds XTS support, AES cipher algorithms and User-space interface for symmetric key cipher algorithms in kernel Signed-off-by: Vasyl Purchel vasyl.purchel@workday.com Signed-off-by: Andrea Baglioni andrea.baglioni@workday.com --- .../board/coreos/minikube/linux_defconfig | 77 +++++++++---------- 1 file changed, 36 insertions(+), 41 deletions(-) diff --git a/deploy/iso/minikube-iso/board/coreos/minikube/linux_defconfig b/deploy/iso/minikube-iso/board/coreos/minikube/linux_defconfig index 49d55a6d8c..5537582e19 100644 --- a/deploy/iso/minikube-iso/board/coreos/minikube/linux_defconfig +++ b/deploy/iso/minikube-iso/board/coreos/minikube/linux_defconfig @@ -4,6 +4,7 @@ CONFIG_POSIX_MQUEUE=y CONFIG_AUDIT=y CONFIG_NO_HZ=y CONFIG_HIGH_RES_TIMERS=y +CONFIG_PREEMPT_VOLUNTARY=y CONFIG_BSD_PROCESS_ACCT=y CONFIG_TASK_XACCT=y CONFIG_TASK_IO_ACCOUNTING=y @@ -29,29 +30,11 @@ CONFIG_BLK_DEV_INITRD=y CONFIG_BPF_SYSCALL=y # CONFIG_COMPAT_BRK is not set CONFIG_PROFILING=y -CONFIG_KPROBES=y -CONFIG_JUMP_LABEL=y -CONFIG_MODULES=y -CONFIG_MODULE_UNLOAD=y -CONFIG_MODULE_FORCE_UNLOAD=y -CONFIG_PARTITION_ADVANCED=y -CONFIG_OSF_PARTITION=y -CONFIG_AMIGA_PARTITION=y -CONFIG_MAC_PARTITION=y -CONFIG_BSD_DISKLABEL=y -CONFIG_MINIX_SUBPARTITION=y -CONFIG_SOLARIS_X86_PARTITION=y -CONFIG_UNIXWARE_DISKLABEL=y -CONFIG_SGI_PARTITION=y -CONFIG_SUN_PARTITION=y -CONFIG_KARMA_PARTITION=y CONFIG_SMP=y CONFIG_HYPERVISOR_GUEST=y CONFIG_PARAVIRT_SPINLOCKS=y CONFIG_KVM_DEBUG_FS=y CONFIG_CALGARY_IOMMU=y -CONFIG_SCHED_SMT=y -CONFIG_PREEMPT_VOLUNTARY=y CONFIG_X86_REROUTE_FOR_BROKEN_BOOT_IRQS=y CONFIG_MICROCODE_AMD=y CONFIG_X86_MSR=y @@ -71,13 +54,34 @@ CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE=y CONFIG_CPU_FREQ_GOV_PERFORMANCE=y CONFIG_CPU_FREQ_GOV_ONDEMAND=y CONFIG_X86_ACPI_CPUFREQ=y -CONFIG_PCI_MMCONFIG=y CONFIG_PCIEPORTBUS=y CONFIG_HOTPLUG_PCI=y CONFIG_PCCARD=y CONFIG_YENTA=y -CONFIG_BINFMT_MISC=y CONFIG_IA32_EMULATION=y +CONFIG_EFI_VARS=y +CONFIG_KVM=m +CONFIG_KVM_INTEL=m +CONFIG_KVM_AMD=m +CONFIG_VHOST_NET=m +CONFIG_VHOST_VSOCK=m +CONFIG_KPROBES=y +CONFIG_JUMP_LABEL=y +CONFIG_MODULES=y +CONFIG_MODULE_UNLOAD=y +CONFIG_MODULE_FORCE_UNLOAD=y +CONFIG_PARTITION_ADVANCED=y +CONFIG_OSF_PARTITION=y +CONFIG_AMIGA_PARTITION=y +CONFIG_MAC_PARTITION=y +CONFIG_BSD_DISKLABEL=y +CONFIG_MINIX_SUBPARTITION=y +CONFIG_SOLARIS_X86_PARTITION=y +CONFIG_UNIXWARE_DISKLABEL=y +CONFIG_SGI_PARTITION=y +CONFIG_SUN_PARTITION=y +CONFIG_KARMA_PARTITION=y +CONFIG_BINFMT_MISC=y CONFIG_NET=y CONFIG_PACKET=y CONFIG_UNIX=y @@ -226,8 +230,6 @@ CONFIG_IP_VS_SH=m CONFIG_IP_VS_SED=m CONFIG_IP_VS_NQ=m CONFIG_IP_VS_NFCT=y -CONFIG_NF_CONNTRACK_IPV4=m -CONFIG_NF_SOCKET_IPV4=m CONFIG_NF_LOG_ARP=m CONFIG_IP_NF_IPTABLES=y CONFIG_IP_NF_FILTER=y @@ -238,8 +240,6 @@ CONFIG_IP_NF_TARGET_NETMAP=m CONFIG_IP_NF_TARGET_REDIRECT=m CONFIG_IP_NF_MANGLE=y CONFIG_IP_NF_RAW=m -CONFIG_NF_CONNTRACK_IPV6=m -CONFIG_NF_SOCKET_IPV6=m CONFIG_IP6_NF_IPTABLES=y CONFIG_IP6_NF_MATCH_IPV6HEADER=y CONFIG_IP6_NF_FILTER=y @@ -269,13 +269,13 @@ CONFIG_BRIDGE_EBT_NFLOG=m CONFIG_BRIDGE=m CONFIG_NET_SCHED=y CONFIG_NET_SCH_INGRESS=m +CONFIG_NET_CLS_U32=m CONFIG_NET_CLS_CGROUP=y CONFIG_NET_CLS_BPF=m CONFIG_NET_EMATCH=y CONFIG_NET_CLS_ACT=y -CONFIG_NET_ACT_BPF=m CONFIG_NET_ACT_MIRRED=m -CONFIG_NET_CLS_U32=m +CONFIG_NET_ACT_BPF=m CONFIG_OPENVSWITCH=m CONFIG_VSOCKETS=m CONFIG_VIRTIO_VSOCKETS=m @@ -322,6 +322,7 @@ CONFIG_PATA_SCH=y CONFIG_MD=y CONFIG_BLK_DEV_MD=y CONFIG_BLK_DEV_DM=y +CONFIG_DM_CRYPT=y CONFIG_DM_SNAPSHOT=y CONFIG_DM_THIN_PROVISIONING=y CONFIG_DM_MIRROR=y @@ -342,7 +343,6 @@ CONFIG_IPVLAN=m CONFIG_VXLAN=y CONFIG_NETCONSOLE=y CONFIG_TUN=y -CONFIG_TAP=y CONFIG_VETH=y CONFIG_VIRTIO_NET=y CONFIG_AMD8111_ETH=m @@ -439,7 +439,6 @@ CONFIG_EEEPC_LAPTOP=y CONFIG_AMD_IOMMU=y CONFIG_INTEL_IOMMU=y # CONFIG_INTEL_IOMMU_DEFAULT_ON is not set -CONFIG_EFI_VARS=y CONFIG_EXT4_FS=y CONFIG_EXT4_FS_POSIX_ACL=y CONFIG_EXT4_FS_SECURITY=y @@ -480,8 +479,16 @@ CONFIG_NLS_CODEPAGE_437=y CONFIG_NLS_ASCII=y CONFIG_NLS_ISO8859_1=y CONFIG_NLS_UTF8=y +CONFIG_SECURITY=y +CONFIG_SECURITY_NETWORK=y +CONFIG_SECURITY_SELINUX=y +CONFIG_SECURITY_SELINUX_BOOTPARAM=y +CONFIG_SECURITY_SELINUX_DISABLE=y +CONFIG_CRYPTO_XTS=y +CONFIG_CRYPTO_AES_NI_INTEL=y +CONFIG_CRYPTO_USER_API_HASH=y +CONFIG_CRYPTO_USER_API_SKCIPHER=y CONFIG_PRINTK_TIME=y -# CONFIG_ENABLE_WARN_DEPRECATED is not set # CONFIG_UNUSED_SYMBOLS is not set CONFIG_MAGIC_SYSRQ=y CONFIG_DEBUG_KERNEL=y @@ -494,15 +501,3 @@ CONFIG_PROVIDE_OHCI1394_DMA_INIT=y CONFIG_EARLY_PRINTK_DBGP=y CONFIG_DEBUG_BOOT_PARAMS=y CONFIG_OPTIMIZE_INLINING=y -CONFIG_SECURITY=y -CONFIG_SECURITY_NETWORK=y -CONFIG_SECURITY_SELINUX=y -CONFIG_SECURITY_SELINUX_BOOTPARAM=y -CONFIG_SECURITY_SELINUX_DISABLE=y -CONFIG_CRYPTO_USER_API_HASH=y -CONFIG_KVM=m -CONFIG_KVM_INTEL=m -CONFIG_KVM_AMD=m -CONFIG_VHOST_NET=m -CONFIG_VHOST=m -CONFIG_VHOST_VSOCK=m From 169c3e74793ea0dcefed1a829aba34737c4d52e8 Mon Sep 17 00:00:00 2001 From: Priya Wadhwa Date: Tue, 29 Oct 2019 13:46:32 -0700 Subject: [PATCH 02/72] Add skeleton for performance scanning service This service runs in a VM and is responsible for: 1. Determining which PRs need to be analyzed 2. Running mkcmp against each PR 3. Commenting the results on the PR via minikube-bot This PR also moves the mkcmp code into its own directory. --- Makefile | 6 +++- cmd/performance/{ => mkcmp}/cmd/mkcmp.go | 0 cmd/performance/{ => mkcmp}/main.go | 2 +- cmd/performance/monitor/monitor.go | 40 ++++++++++++++++++++++++ 4 files changed, 46 insertions(+), 2 deletions(-) rename cmd/performance/{ => mkcmp}/cmd/mkcmp.go (100%) rename cmd/performance/{ => mkcmp}/main.go (92%) create mode 100644 cmd/performance/monitor/monitor.go diff --git a/Makefile b/Makefile index cc2907f480..8a6ba33067 100755 --- a/Makefile +++ b/Makefile @@ -572,4 +572,8 @@ site: site/themes/docsy/assets/vendor/bootstrap/package.js out/hugo/hugo .PHONY: out/mkcmp out/mkcmp: - GOOS=$(GOOS) GOARCH=$(GOARCH) go build -o $@ cmd/performance/main.go + GOOS=$(GOOS) GOARCH=$(GOARCH) go build -o $@ cmd/performance/mkcmp/main.go + +.PHONY: out/performance-monitor +out/performance-monitor: + GOOS=$(GOOS) GOARCH=$(GOARCH) go build -o $@ cmd/performance/monitor/monitor.go diff --git a/cmd/performance/cmd/mkcmp.go b/cmd/performance/mkcmp/cmd/mkcmp.go similarity index 100% rename from cmd/performance/cmd/mkcmp.go rename to cmd/performance/mkcmp/cmd/mkcmp.go diff --git a/cmd/performance/main.go b/cmd/performance/mkcmp/main.go similarity index 92% rename from cmd/performance/main.go rename to cmd/performance/mkcmp/main.go index 82c0efb0ac..a80c841f6f 100644 --- a/cmd/performance/main.go +++ b/cmd/performance/mkcmp/main.go @@ -16,7 +16,7 @@ limitations under the License. package main -import "k8s.io/minikube/cmd/performance/cmd" +import "k8s.io/minikube/cmd/performance/mkcmp/cmd" func main() { cmd.Execute() diff --git a/cmd/performance/monitor/monitor.go b/cmd/performance/monitor/monitor.go new file mode 100644 index 0000000000..174c10d9e4 --- /dev/null +++ b/cmd/performance/monitor/monitor.go @@ -0,0 +1,40 @@ +/* +Copyright 2019 The Kubernetes Authors All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package main + +import ( + "context" + "log" + "time" +) + +func main() { + for { + if err := analyzePerformance(context.Background()); err != nil { + log.Printf("error executing performance analysis: %v", err) + } + time.Sleep(10 * time.Minute) + } +} + +// analyzePerformance is responsible for: +// 1. collecting PRs to run performance analysis on +// 2. running mkcmp against those PRs +// 3. commenting results on those PRs +func analyzePerformance(ctx context.Context) error { + return nil +} From c6686317d0f0270630805f4f0f4c75005368cf80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20F=20Bj=C3=B6rklund?= Date: Sat, 2 Nov 2019 15:26:46 +0100 Subject: [PATCH 03/72] Don't use bash as the entrypoint for docker The bash shell is not very good at playing init(1), let tini handle this instead by doing `docker run --init`. This makes it forward signals properly to e.g. make, and also reaps processes for long-running containers. However, we _need_ to override the entrypoint of the karalabe/xgo image, since it'll self-destruct otherwise. It (/build.sh) expects the command to be the import path and cannot handle getting the bash command line to run. --- Makefile | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 9468331188..a7ff0eced7 100755 --- a/Makefile +++ b/Makefile @@ -114,7 +114,7 @@ HYPERKIT_LDFLAGS := -X k8s.io/minikube/pkg/drivers/hyperkit.version=$(VERSION) - # $(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)' + 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 --init $(1) /bin/bash -c '$(2)' endef ifeq ($(BUILD_IN_DOCKER),y) @@ -427,7 +427,10 @@ out/minikube-installer.exe: out/minikube-windows-amd64.exe out/docker-machine-driver-hyperkit: ifeq ($(MINIKUBE_BUILD_IN_DOCKER),y) - $(call DOCKER,$(HYPERKIT_BUILD_IMAGE),CC=o64-clang CXX=o64-clang++ /usr/bin/make $@) + 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 --init --entrypoint "" \ + $(HYPERKIT_BUILD_IMAGE) /bin/bash -c 'CC=o64-clang CXX=o64-clang++ /usr/bin/make $@' else GOOS=darwin CGO_ENABLED=1 go build \ -ldflags="$(HYPERKIT_LDFLAGS)" \ @@ -436,7 +439,7 @@ endif hyperkit_in_docker: rm -f out/docker-machine-driver-hyperkit - $(call DOCKER,$(HYPERKIT_BUILD_IMAGE),CC=o64-clang CXX=o64-clang++ /usr/bin/make out/docker-machine-driver-hyperkit) + $(MAKE) MINIKUBE_BUILD_IN_DOCKER=y out/docker-machine-driver-hyperkit .PHONY: install-hyperkit-driver install-hyperkit-driver: out/docker-machine-driver-hyperkit From 9aecbe19df0ddb255d1587d2a0cac70331365787 Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Thu, 7 Nov 2019 10:22:10 -0800 Subject: [PATCH 04/72] delete boilerplate site page --- site/content/en/docs/Concepts/_index.md | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/site/content/en/docs/Concepts/_index.md b/site/content/en/docs/Concepts/_index.md index 9cc7cd6ff4..2b874a5243 100644 --- a/site/content/en/docs/Concepts/_index.md +++ b/site/content/en/docs/Concepts/_index.md @@ -5,13 +5,3 @@ weight: 4 description: > Concepts that users and contributors should be aware of. --- - -{{% pageinfo %}} -This is a placeholder page that shows you how to use this template site. -{{% /pageinfo %}} - -For many projects, users may not need much information beyond the information in the [Overview](/docs/overview/), so this section is **optional**. However if there are areas where your users will need a more detailed understanding of a given term or feature in order to do anything useful with your project (or to not make mistakes when using it) put that information in this section. For example, you may want to add some conceptual pages if you have a large project with many components and a complex architecture. - -Remember to focus on what the user needs to know, not just what you think is interesting about your project! If they don’t need to understand your original design decisions to use or contribute to the project, don’t put them in, or include your design docs in your repo and link to them. Similarly, most users will probably need to know more about how features work when in use rather than how they are implemented. Consider a separate architecture page for more detailed implementation and system design information that potential project contributors can consult. - - From 108fd082b5a5d1e1203e00c7e1082ab2adc33776 Mon Sep 17 00:00:00 2001 From: Priya Wadhwa Date: Thu, 7 Nov 2019 10:48:55 -0800 Subject: [PATCH 05/72] change name monitor to pr-bot --- cmd/performance/{monitor/monitor.go => pr-bot/bot.go} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename cmd/performance/{monitor/monitor.go => pr-bot/bot.go} (100%) diff --git a/cmd/performance/monitor/monitor.go b/cmd/performance/pr-bot/bot.go similarity index 100% rename from cmd/performance/monitor/monitor.go rename to cmd/performance/pr-bot/bot.go From a750524774604567f387f8da0a0cff78a8c64249 Mon Sep 17 00:00:00 2001 From: Thomas Stromberg Date: Thu, 14 Nov 2019 10:56:44 -0800 Subject: [PATCH 06/72] Fix test that made assumption that minikube was valid --- cmd/minikube/cmd/config/util_test.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/cmd/minikube/cmd/config/util_test.go b/cmd/minikube/cmd/config/util_test.go index 5a47c15798..f1627f19fa 100644 --- a/cmd/minikube/cmd/config/util_test.go +++ b/cmd/minikube/cmd/config/util_test.go @@ -122,17 +122,16 @@ func TestValidateProfile(t *testing.T) { profileName: "82374328742_2974224498", }, { - profileName: "minikube", + profileName: "validate_test", }, } for _, test := range testCases { profileNam := test.profileName - expectedMsg := fmt.Sprintf("profile %q not found", test.profileName) - + expected := fmt.Sprintf("profile %q not found", test.profileName) err, ok := ValidateProfile(profileNam) - if !ok && err.Error() != expectedMsg { - t.Errorf("Didnt receive expected message") + if !ok && err.Error() != expected { + t.Errorf("got error %q, expected %q", err, expected) } } } From bb28d5c3461c074862fbf86544ffe010d0150655 Mon Sep 17 00:00:00 2001 From: Thomas Stromberg Date: Thu, 14 Nov 2019 10:57:11 -0800 Subject: [PATCH 07/72] Make lock names more specific to avoid conflicts --- pkg/minikube/bootstrapper/certs.go | 16 +++--- pkg/minikube/config/profile.go | 2 +- pkg/minikube/kubeconfig/settings.go | 7 ++- pkg/util/lock/lock.go | 75 ++++++++++++++++------------- pkg/util/lock/lock_test.go | 22 +++++---- 5 files changed, 63 insertions(+), 59 deletions(-) diff --git a/pkg/minikube/bootstrapper/certs.go b/pkg/minikube/bootstrapper/certs.go index 6702a6b122..611b5416cc 100644 --- a/pkg/minikube/bootstrapper/certs.go +++ b/pkg/minikube/bootstrapper/certs.go @@ -26,7 +26,6 @@ import ( "path" "path/filepath" "strings" - "time" "github.com/golang/glog" "github.com/pkg/errors" @@ -40,8 +39,8 @@ import ( "k8s.io/minikube/pkg/minikube/localpath" "k8s.io/minikube/pkg/minikube/vmpath" "k8s.io/minikube/pkg/util" + "k8s.io/minikube/pkg/util/lock" - "github.com/juju/clock" "github.com/juju/mutex" ) @@ -61,17 +60,17 @@ var ( // SetupCerts gets the generated credentials required to talk to the APIServer. func SetupCerts(cmd command.Runner, k8s config.KubernetesConfig) error { + + localPath := localpath.MiniPath() + glog.Infof("Setting up %s for IP: %s\n", localPath, k8s.NodeIP) + // WARNING: This function was not designed for multiple profiles, so it is VERY racey: // // It updates a shared certificate file and uploads it to the apiserver before launch. // // If another process updates the shared certificate, it's invalid. // TODO: Instead of racey manipulation of a shared certificate, use per-profile certs - spec := mutex.Spec{ - Name: "setupCerts", - Clock: clock.WallClock, - Delay: 15 * time.Second, - } + spec := lock.UserMutexSpec(filepath.Join(localPath, "certs")) glog.Infof("acquiring lock: %+v", spec) releaser, err := mutex.Acquire(spec) if err != nil { @@ -79,9 +78,6 @@ func SetupCerts(cmd command.Runner, k8s config.KubernetesConfig) error { } defer releaser.Release() - localPath := localpath.MiniPath() - glog.Infof("Setting up %s for IP: %s\n", localPath, k8s.NodeIP) - if err := generateCerts(k8s); err != nil { return errors.Wrap(err, "Error generating certs") } diff --git a/pkg/minikube/config/profile.go b/pkg/minikube/config/profile.go index 3546ec2e93..22ad511d51 100644 --- a/pkg/minikube/config/profile.go +++ b/pkg/minikube/config/profile.go @@ -105,7 +105,7 @@ func CreateProfile(name string, cfg *MachineConfig, miniHome ...string) error { } defer os.Remove(tf.Name()) - if err = lock.WriteFile(tf.Name(), data, 0600); err != nil { + if err = ioutil.WriteFile(tf.Name(), data, 0600); err != nil { return err } diff --git a/pkg/minikube/kubeconfig/settings.go b/pkg/minikube/kubeconfig/settings.go index 28601d0b6e..0cd09ec542 100644 --- a/pkg/minikube/kubeconfig/settings.go +++ b/pkg/minikube/kubeconfig/settings.go @@ -18,14 +18,14 @@ package kubeconfig import ( "io/ioutil" + "path/filepath" "sync/atomic" - "time" "github.com/golang/glog" - "github.com/juju/clock" "github.com/juju/mutex" "github.com/pkg/errors" "k8s.io/client-go/tools/clientcmd/api" + "k8s.io/minikube/pkg/util/lock" ) // Settings is the minikubes settings for kubeconfig @@ -119,8 +119,7 @@ func PopulateFromSettings(cfg *Settings, apiCfg *api.Config) error { // activeContext is true when minikube is the CurrentContext // If no CurrentContext is set, the given name will be used. func Update(kcs *Settings) error { - // Add a lock around both the read, update, and write operations - spec := mutex.Spec{Name: "kubeconfigUpdate", Clock: clock.WallClock, Delay: 10 * time.Second} + spec := lock.UserMutexSpec(filepath.Join(kcs.filePath(), "settings.Update")) glog.Infof("acquiring lock: %+v", spec) releaser, err := mutex.Acquire(spec) if err != nil { diff --git a/pkg/util/lock/lock.go b/pkg/util/lock/lock.go index 513eaaf1c5..5083fa0d8c 100644 --- a/pkg/util/lock/lock.go +++ b/pkg/util/lock/lock.go @@ -20,8 +20,8 @@ import ( "fmt" "io/ioutil" "os" - "path/filepath" - "strconv" + "os/user" + "regexp" "strings" "time" @@ -31,15 +31,17 @@ import ( "github.com/pkg/errors" ) +var ( + // nonString is characters to strip from lock names + nonString = regexp.MustCompile(`[\W_]+`) + // forceID is a user id for consistent testing + forceID = "" +) + // WriteFile decorates ioutil.WriteFile with a file lock and retry func WriteFile(filename string, data []byte, perm os.FileMode) error { - spec := mutex.Spec{ - Name: getMutexName(filename), - Clock: clock.WallClock, - Delay: 13 * time.Second, - } - glog.Infof("attempting to write to file %q with filemode %v", filename, perm) - + spec := UserMutexSpec(filename) + glog.Infof("acquiring lock for %s: %+v", filename, spec) releaser, err := mutex.Acquire(spec) if err != nil { return errors.Wrapf(err, "error acquiring lock for %s", filename) @@ -50,34 +52,39 @@ func WriteFile(filename string, data []byte, perm os.FileMode) error { if err = ioutil.WriteFile(filename, data, perm); err != nil { return errors.Wrapf(err, "error writing file %s", filename) } - return err } -func getMutexName(filename string) string { - // Make the mutex name the file name and its parent directory - dir, name := filepath.Split(filename) - - // Replace underscores and periods with dashes, the only valid punctuation for mutex name - name = strings.ReplaceAll(name, ".", "-") - name = strings.ReplaceAll(name, "_", "-") - - p := strings.ReplaceAll(filepath.Base(dir), ".", "-") - p = strings.ReplaceAll(p, "_", "-") - mutexName := fmt.Sprintf("%s-%s", p, strings.ReplaceAll(name, ".", "-")) - - // Check if name starts with an int and prepend a string instead - if _, err := strconv.Atoi(mutexName[:1]); err == nil { - mutexName = "m" + mutexName - } - // There's an arbitrary hard max on mutex name at 40. - if len(mutexName) > 40 { - mutexName = mutexName[:40] +// UserMutexSpec returns a mutex spec that will not collide with other users +func UserMutexSpec(path string) mutex.Spec { + id := forceID + if forceID == "" { + u, err := user.Current() + if err == nil { + id = u.Uid + } } - // Make sure name doesn't start or end with punctuation - mutexName = strings.TrimPrefix(mutexName, "-") - mutexName = strings.TrimSuffix(mutexName, "-") - - return mutexName + s := mutex.Spec{ + Name: getMutexNameForPath(fmt.Sprintf("%s-%s", path, id)), + Clock: clock.WallClock, + // Poll the lock twice a second + Delay: 500 * time.Millisecond, + // panic after a minute instead of locking infinitely + Timeout: 60 * time.Second, + } + return s +} + +func getMutexNameForPath(path string) string { + // juju requires that names match ^[a-zA-Z][a-zA-Z0-9-]*$", and be under 40 chars long. + n := strings.Trim(nonString.ReplaceAllString(path, "-"), "-") + // we need to always guarantee an alphanumeric prefix + prefix := "m" + + // Prefer the last 40 chars, as paths tend get more specific toward the end + if len(n) >= 40 { + return prefix + n[len(n)-39:] + } + return prefix + n } diff --git a/pkg/util/lock/lock_test.go b/pkg/util/lock/lock_test.go index 8c84321d4e..8bb97d0465 100644 --- a/pkg/util/lock/lock_test.go +++ b/pkg/util/lock/lock_test.go @@ -18,7 +18,9 @@ package lock import "testing" -func TestGetMutexName(t *testing.T) { +func TestUserMutexSpec(t *testing.T) { + forceID = "test" + var tests = []struct { description string path string @@ -27,40 +29,40 @@ func TestGetMutexName(t *testing.T) { { description: "standard", path: "/foo/bar", - expected: "foo-bar", + expected: "mfoo-bar-test", }, { description: "deep directory", path: "/foo/bar/baz/bat", - expected: "baz-bat", + expected: "mfoo-bar-baz-bat-test", }, { description: "underscores", path: "/foo_bar/baz", - expected: "foo-bar-baz", + expected: "mfoo-bar-baz-test", }, { description: "starts with number", path: "/foo/2bar/baz", - expected: "m2bar-baz", + expected: "mfoo-2bar-baz-test", }, { description: "starts with punctuation", path: "/.foo/bar", - expected: "foo-bar", + expected: "mfoo-bar-test", }, { description: "long filename", path: "/very-very-very-very-very-very-very-very-long/bar", - expected: "very-very-very-very-very-very-very-very", + expected: "m-very-very-very-very-very-long-bar-test", }, } for _, tc := range tests { t.Run(tc.description, func(t *testing.T) { - got := getMutexName(tc.path) - if got != tc.expected { - t.Errorf("Unexpected mutex name for path %s. got: %s, expected: %s", tc.path, got, tc.expected) + got := UserMutexSpec(tc.path) + if got.Name != tc.expected { + t.Errorf("%s mutex name = %q, expected %q", tc.path, got.Name, tc.expected) } }) } From f680d1b1fcca11fc57b01f8521af2a7a5a9bf452 Mon Sep 17 00:00:00 2001 From: Nanik T Date: Fri, 1 Nov 2019 16:42:21 +1100 Subject: [PATCH 08/72] Fix --kubernetes-version for upgrading cluster to correct version This PR fix the issue of checking kubernetes-version and upgrading it. The fix now will do the following * Not specifying the --kubernetes-version flag means just use the currently deployed version. * If an update is available inform the user that they may use --kubernetes-version=. * When --kubernetes-version is specifically set, upgrade the cluster. Also add integration testing to test upgrading and downgrading --- cmd/minikube/cmd/start.go | 26 ++++++++--- cmd/minikube/cmd/start_test.go | 55 ++++++++++++++++++++++++ test/integration/version_upgrade_test.go | 36 +++++++++++++++- 3 files changed, 108 insertions(+), 9 deletions(-) diff --git a/cmd/minikube/cmd/start.go b/cmd/minikube/cmd/start.go index 1be0db1f12..c97f28cb4b 100644 --- a/cmd/minikube/cmd/start.go +++ b/cmd/minikube/cmd/start.go @@ -178,7 +178,7 @@ func initMinikubeFlags() { // initKubernetesFlags inits the commandline flags for kubernetes related options func initKubernetesFlags() { - startCmd.Flags().String(kubernetesVersion, constants.DefaultKubernetesVersion, "The kubernetes version that the minikube VM will use (ex: v1.2.3)") + startCmd.Flags().String(kubernetesVersion, "", "The kubernetes version that the minikube VM will use (ex: v1.2.3)") startCmd.Flags().Var(&extraOptions, "extra-config", `A set of key=value pairs that describe configuration that may be passed to different components. The key should be '.' separated, and the first part before the dot is the component to apply the configuration to. @@ -1114,15 +1114,20 @@ func tryRegistry(r command.Runner) { // getKubernetesVersion ensures that the requested version is reasonable func getKubernetesVersion(old *cfg.MachineConfig) (string, bool) { - rawVersion := viper.GetString(kubernetesVersion) + paramVersion := viper.GetString(kubernetesVersion) isUpgrade := false - if rawVersion == "" { - rawVersion = constants.DefaultKubernetesVersion + + if paramVersion == "" { // if the user did not specify any version then ... + if old != nil { // .. use the old version from config + paramVersion = old.KubernetesConfig.KubernetesVersion + } else { // .. otherwise use the default version + paramVersion = constants.DefaultKubernetesVersion + } } - nvs, err := semver.Make(strings.TrimPrefix(rawVersion, version.VersionPrefix)) + nvs, err := semver.Make(strings.TrimPrefix(paramVersion, version.VersionPrefix)) if err != nil { - exit.WithCodeT(exit.Data, `Unable to parse "{{.kubernetes_version}}": {{.error}}`, out.V{"kubernetes_version": rawVersion, "error": err}) + exit.WithCodeT(exit.Data, `Unable to parse "{{.kubernetes_version}}": {{.error}}`, out.V{"kubernetes_version": paramVersion, "error": err}) } nv := version.VersionPrefix + nvs.String() @@ -1134,6 +1139,10 @@ func getKubernetesVersion(old *cfg.MachineConfig) (string, bool) { if err != nil { exit.WithCodeT(exit.Data, "Unable to parse oldest Kubernetes version from constants: {{.error}}", out.V{"error": err}) } + defaultVersion, err := semver.Make(strings.TrimPrefix(constants.DefaultKubernetesVersion, version.VersionPrefix)) + if err != nil { + exit.WithCodeT(exit.Data, "Unable to parse default Kubernetes version from constants: {{.error}}", out.V{"error": err}) + } if nvs.LT(oldestVersion) { out.WarningT("Specified Kubernetes version {{.specified}} is less than the oldest supported version: {{.oldest}}", out.V{"specified": nvs, "oldest": constants.OldestKubernetesVersion}) @@ -1162,8 +1171,11 @@ func getKubernetesVersion(old *cfg.MachineConfig) (string, bool) { * Reuse the existing cluster with Kubernetes v{{.old}} or newer: Run "minikube start {{.profile}} --kubernetes-version={{.old}}"`, out.V{"new": nvs, "old": ovs, "profile": profileArg}) } + if defaultVersion.GT(nvs) { + out.T(out.ThumbsUp, "Kubernetes {{.new}} is now available. If you would like to upgrade, specify: --kubernetes-version={{.new}}", out.V{"new": defaultVersion}) + } + if nvs.GT(ovs) { - out.T(out.ThumbsUp, "Upgrading from Kubernetes {{.old}} to {{.new}}", out.V{"old": ovs, "new": nvs}) isUpgrade = true } return nv, isUpgrade diff --git a/cmd/minikube/cmd/start_test.go b/cmd/minikube/cmd/start_test.go index 60c57d76fd..33de12cc13 100644 --- a/cmd/minikube/cmd/start_test.go +++ b/cmd/minikube/cmd/start_test.go @@ -22,9 +22,64 @@ import ( "github.com/spf13/cobra" "github.com/spf13/viper" + cfg "k8s.io/minikube/pkg/minikube/config" "k8s.io/minikube/pkg/minikube/constants" ) +func TestGetKuberneterVersion(t *testing.T) { + var tests = []struct { + description string + expectedVersion string + paramVersion string + upgrade bool + cfg *cfg.MachineConfig + }{ + { + description: "kubernetes-version not given, no config", + expectedVersion: constants.DefaultKubernetesVersion, + paramVersion: "", + upgrade: false, + }, + { + description: "kubernetes-version not given, config available", + expectedVersion: "v1.15.0", + paramVersion: "", + upgrade: false, + cfg: &cfg.MachineConfig{KubernetesConfig: cfg.KubernetesConfig{KubernetesVersion: "v1.15.0"}}, + }, + { + description: "kubernetes-version given, no config", + expectedVersion: "v1.15.0", + paramVersion: "v1.15.0", + upgrade: false, + }, + { + description: "kubernetes-version given, config available", + expectedVersion: "v1.16.0", + paramVersion: "v1.16.0", + upgrade: true, + cfg: &cfg.MachineConfig{KubernetesConfig: cfg.KubernetesConfig{KubernetesVersion: "v1.15.0"}}, + }, + } + + for _, test := range tests { + t.Run(test.description, func(t *testing.T) { + viper.SetDefault(kubernetesVersion, test.paramVersion) + version, upgrade := getKubernetesVersion(test.cfg) + + // check whether we are getting the expected version + if version != test.expectedVersion { + t.Fatalf("test failed because the expected version %s is not returned", test.expectedVersion) + } + + // check whether the upgrade flag is correct + if test.upgrade != upgrade { + t.Fatalf("test failed expected upgrade is %t", test.upgrade) + } + }) + } +} + func TestGenerateCfgFromFlagsHTTPProxyHandling(t *testing.T) { viper.SetDefault(memory, defaultMemorySize) viper.SetDefault(humanReadableDiskSize, defaultDiskSize) diff --git a/test/integration/version_upgrade_test.go b/test/integration/version_upgrade_test.go index 78bc9ef712..cec42dcb9d 100644 --- a/test/integration/version_upgrade_test.go +++ b/test/integration/version_upgrade_test.go @@ -18,6 +18,7 @@ package integration import ( "context" + "encoding/json" "fmt" "io/ioutil" "os" @@ -28,6 +29,7 @@ import ( "time" "github.com/docker/machine/libmachine/state" + "k8s.io/minikube/pkg/minikube/constants" "k8s.io/minikube/pkg/util/retry" @@ -66,13 +68,13 @@ func TestVersionUpgrade(t *testing.T) { args := append([]string{"start", "-p", profile, fmt.Sprintf("--kubernetes-version=%s", constants.OldestKubernetesVersion), "--alsologtostderr", "-v=1"}, StartArgs()...) rr := &RunResult{} - releaseStart := func() error { + r := func() error { rr, err = Run(t, exec.CommandContext(ctx, tf.Name(), args...)) return err } // Retry to allow flakiness for the previous release - if err := retry.Expo(releaseStart, 1*time.Second, 30*time.Minute, 3); err != nil { + if err := retry.Expo(r, 1*time.Second, 30*time.Minute, 3); err != nil { t.Fatalf("release start failed: %v", err) } @@ -96,4 +98,34 @@ func TestVersionUpgrade(t *testing.T) { if err != nil { t.Errorf("%s failed: %v", rr.Args, err) } + + s, err := Run(t, exec.CommandContext(ctx, "kubectl", "--context", profile, "version", "--output=json")) + if err != nil { + t.Fatalf("error running kubectl: %v", err) + } + cv := struct { + ServerVersion struct { + GitVersion string `json:"gitVersion"` + } `json:"serverVersion"` + }{} + err = json.Unmarshal(s.Stdout.Bytes(), &cv) + + if err != nil { + t.Fatalf("error traversing json output: %v", err) + } + + if cv.ServerVersion.GitVersion != constants.NewestKubernetesVersion { + t.Fatalf("expected server version %s is not the same with latest version %s", cv.ServerVersion.GitVersion, constants.NewestKubernetesVersion) + } + + args = append([]string{"start", "-p", profile, fmt.Sprintf("--kubernetes-version=%s", constants.OldestKubernetesVersion), "--alsologtostderr", "-v=1"}, StartArgs()...) + rr = &RunResult{} + r = func() error { + rr, err = Run(t, exec.CommandContext(ctx, tf.Name(), args...)) + return err + } + + if err := retry.Expo(r, 1*time.Second, 30*time.Minute, 3); err == nil { + t.Fatalf("downgrading kubernetes should not be allowed: %v", err) + } } From 9ad7fb70b1197e6c3e1a9b3e73c4e1ba9683a4c8 Mon Sep 17 00:00:00 2001 From: Thomas Stromberg Date: Sat, 16 Nov 2019 21:20:14 -0800 Subject: [PATCH 09/72] Pre-cache the latest kube-addon-manager --- pkg/minikube/bootstrapper/images/images.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/minikube/bootstrapper/images/images.go b/pkg/minikube/bootstrapper/images/images.go index b69d1160bd..5b294a3ef0 100644 --- a/pkg/minikube/bootstrapper/images/images.go +++ b/pkg/minikube/bootstrapper/images/images.go @@ -145,7 +145,7 @@ func CachedImages(imageRepositoryStr string, kubernetesVersionStr string) []stri images = append(images, []string{ imageRepository + "kubernetes-dashboard" + ArchTag(true) + "v1.10.1", - imageRepository + "kube-addon-manager" + ArchTag(false) + "v9.0", + imageRepository + "kube-addon-manager" + ArchTag(false) + "v9.0.2", minikubeRepository + "storage-provisioner" + ArchTag(false) + "v1.8.1", }...) From fb985f4be001ca4ee2a89479dea18a144c383b78 Mon Sep 17 00:00:00 2001 From: Priya Wadhwa Date: Mon, 18 Nov 2019 11:53:56 -0800 Subject: [PATCH 10/72] Add iostat and strace packages to minikube ISO --- deploy/iso/minikube-iso/configs/minikube_defconfig | 2 ++ 1 file changed, 2 insertions(+) diff --git a/deploy/iso/minikube-iso/configs/minikube_defconfig b/deploy/iso/minikube-iso/configs/minikube_defconfig index abcb1c8491..5ef1c1a39e 100644 --- a/deploy/iso/minikube-iso/configs/minikube_defconfig +++ b/deploy/iso/minikube-iso/configs/minikube_defconfig @@ -60,3 +60,5 @@ BR2_TARGET_ROOTFS_ISO9660_BOOT_MENU="$(BR2_EXTERNAL_MINIKUBE_PATH)/board/coreos/ BR2_TARGET_SYSLINUX=y BR2_PACKAGE_HOST_E2TOOLS=y BR2_PACKAGE_SYSTEMD_TIMESYNCD=y +BR2_PACKAGE_IOSTAT=y +BR2_PACKAGE_STRACE=y From 2074b6faffe87068b1d491632cd5aa8a24a96c41 Mon Sep 17 00:00:00 2001 From: Priya Wadhwa Date: Mon, 18 Nov 2019 13:11:43 -0800 Subject: [PATCH 11/72] Replace iostat with sysstat package which includes iostat, pidstat, and other performance tools. Ref: https://git.busybox.net/buildroot/tree/package/sysstat/Config.in?id=3bbf1c2ea6140d8b288b0af5b1a9c3a1aa92edad --- deploy/iso/minikube-iso/configs/minikube_defconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy/iso/minikube-iso/configs/minikube_defconfig b/deploy/iso/minikube-iso/configs/minikube_defconfig index 5ef1c1a39e..193f2be030 100644 --- a/deploy/iso/minikube-iso/configs/minikube_defconfig +++ b/deploy/iso/minikube-iso/configs/minikube_defconfig @@ -60,5 +60,5 @@ BR2_TARGET_ROOTFS_ISO9660_BOOT_MENU="$(BR2_EXTERNAL_MINIKUBE_PATH)/board/coreos/ BR2_TARGET_SYSLINUX=y BR2_PACKAGE_HOST_E2TOOLS=y BR2_PACKAGE_SYSTEMD_TIMESYNCD=y -BR2_PACKAGE_IOSTAT=y BR2_PACKAGE_STRACE=y +BR2_PACKAGE_SYSSTAT=y From 99350b3b7f2bc13be91a119f6964987e4e8b96d7 Mon Sep 17 00:00:00 2001 From: Olivier Lemasle Date: Wed, 20 Nov 2019 13:36:06 +0100 Subject: [PATCH 12/72] Remove depreacted annotation storageclass.beta.kubernetes.io/is-default-class (deprecated since K8s 1.6 - cf https://github.com/kubernetes/kubernetes/pull/40088) --- .../storage-provisioner-glusterfile.yaml.tmpl | 2 +- pkg/minikube/storageclass/storageclass.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/deploy/addons/storage-provisioner-gluster/storage-provisioner-glusterfile.yaml.tmpl b/deploy/addons/storage-provisioner-gluster/storage-provisioner-glusterfile.yaml.tmpl index df579da777..74c84ede77 100644 --- a/deploy/addons/storage-provisioner-gluster/storage-provisioner-glusterfile.yaml.tmpl +++ b/deploy/addons/storage-provisioner-gluster/storage-provisioner-glusterfile.yaml.tmpl @@ -8,7 +8,7 @@ metadata: kubernetes.io/minikube-addons: storage-provisioner-gluster addonmanager.kubernetes.io/mode: EnsureExists annotations: - storageclass.beta.kubernetes.io/is-default-class: "true" + storageclass.kubernetes.io/is-default-class: "true" provisioner: gluster.org/glusterfile reclaimPolicy: Delete parameters: diff --git a/pkg/minikube/storageclass/storageclass.go b/pkg/minikube/storageclass/storageclass.go index 657d99911f..fa6bb19a12 100644 --- a/pkg/minikube/storageclass/storageclass.go +++ b/pkg/minikube/storageclass/storageclass.go @@ -29,7 +29,7 @@ import ( func annotateDefaultStorageClass(storage storagev1.StorageV1Interface, class *v1.StorageClass, enable bool) error { isDefault := strconv.FormatBool(enable) - metav1.SetMetaDataAnnotation(&class.ObjectMeta, "storageclass.beta.kubernetes.io/is-default-class", isDefault) + metav1.SetMetaDataAnnotation(&class.ObjectMeta, "storageclass.kubernetes.io/is-default-class", isDefault) _, err := storage.StorageClasses().Update(class) return err From b0b6dd493e8ba1d8569552c65b7eb4be003ef2e6 Mon Sep 17 00:00:00 2001 From: Jan Ahrens Date: Fri, 22 Nov 2019 08:03:12 +0100 Subject: [PATCH 13/72] Add tutorial for audit policy This tutorial was assembled from information provided in #4488. --- .../content/en/docs/Tutorials/audit-policy.md | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 site/content/en/docs/Tutorials/audit-policy.md diff --git a/site/content/en/docs/Tutorials/audit-policy.md b/site/content/en/docs/Tutorials/audit-policy.md new file mode 100644 index 0000000000..b688a53631 --- /dev/null +++ b/site/content/en/docs/Tutorials/audit-policy.md @@ -0,0 +1,42 @@ +--- +title: "Audit Policy" +linkTitle: "Audit Policy" +weight: 1 +date: 2019-11-19 +description: > + Enabling audit policy for minikube +--- + +## Overview + +[Auditing](https://kubernetes.io/docs/tasks/debug-application-cluster/audit/) is not enabled in minikube by default. +This tutorial shows how to provide an [Audit Policy](https://kubernetes.io/docs/tasks/debug-application-cluster/audit/#audit-policy) file +to the minikube API server on startup. + +## Tutorial + +```shell +minikube stop + +mkdir -p ~/.minikube/files/etc/ssl/certs + +cat < ~/.minikube/files/etc/ssl/certs/audit-policy.yaml +# Log all requests at the Metadata level. +apiVersion: audit.k8s.io/v1 +kind: Policy +rules: +- level: Metadata +EOF + +minikube start \ + --extra-config=apiserver.audit-policy-file=/etc/ssl/certs/audit-policy.yaml \ + --extra-config=apiserver.audit-log-path=- + +kubectl logs kube-apiserver-minikube -n kube-system | grep audit.k8s.io/v1 +``` + +Putting the file into the `~/.minikube/files/` directory triggers the [file sync mechanism](https://minikube.sigs.k8s.io/docs/tasks/sync/) to copy the `audit-policy.yaml` file +from the host onto the minikube node. When the API server container starts I'll mount the `/etc/ssl/certs` directory from the minikube node and can thus read the audit policy file. + +You most likely want to tune the [Audit Policy](https://kubernetes.io/docs/tasks/debug-application-cluster/audit/#audit-policy) next as the one used in this tutorial is quite verbose. +To use a new file you need to stop and start minikube. From 9317c453c01d3e32c42d02bd081fff1b457fe9b9 Mon Sep 17 00:00:00 2001 From: Priya Wadhwa Date: Fri, 22 Nov 2019 15:39:18 -0800 Subject: [PATCH 14/72] Added more performance analysis tools --- deploy/iso/minikube-iso/configs/minikube_defconfig | 3 +++ 1 file changed, 3 insertions(+) diff --git a/deploy/iso/minikube-iso/configs/minikube_defconfig b/deploy/iso/minikube-iso/configs/minikube_defconfig index 193f2be030..1e99ba1e52 100644 --- a/deploy/iso/minikube-iso/configs/minikube_defconfig +++ b/deploy/iso/minikube-iso/configs/minikube_defconfig @@ -62,3 +62,6 @@ BR2_PACKAGE_HOST_E2TOOLS=y BR2_PACKAGE_SYSTEMD_TIMESYNCD=y BR2_PACKAGE_STRACE=y BR2_PACKAGE_SYSSTAT=y +BR2_PACKAGE_HTOP=y +BR2_PACKAGE_PYTHON=y +BR2_PACKAGE_IOTOP=y \ No newline at end of file From 8ee34b375a8e90de5469dbbc3b354d42c1f6e891 Mon Sep 17 00:00:00 2001 From: Priya Wadhwa Date: Mon, 25 Nov 2019 14:04:11 -0800 Subject: [PATCH 15/72] remove iotop and python dependencies, iotop installed by another package --- deploy/iso/minikube-iso/configs/minikube_defconfig | 2 -- 1 file changed, 2 deletions(-) diff --git a/deploy/iso/minikube-iso/configs/minikube_defconfig b/deploy/iso/minikube-iso/configs/minikube_defconfig index 1e99ba1e52..6cdec2cf80 100644 --- a/deploy/iso/minikube-iso/configs/minikube_defconfig +++ b/deploy/iso/minikube-iso/configs/minikube_defconfig @@ -63,5 +63,3 @@ BR2_PACKAGE_SYSTEMD_TIMESYNCD=y BR2_PACKAGE_STRACE=y BR2_PACKAGE_SYSSTAT=y BR2_PACKAGE_HTOP=y -BR2_PACKAGE_PYTHON=y -BR2_PACKAGE_IOTOP=y \ No newline at end of file From 690ea964b3c65b3ae080e345e31f253a5aee25c5 Mon Sep 17 00:00:00 2001 From: Sharif Elgamal Date: Tue, 26 Nov 2019 10:53:14 -0800 Subject: [PATCH 16/72] Update Makefile for 1.6.0-beta.1 release --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 85bb5d2de1..032a0726df 100755 --- a/Makefile +++ b/Makefile @@ -15,12 +15,12 @@ # Bump these on release - and please check ISO_VERSION for correctness. VERSION_MAJOR ?= 1 VERSION_MINOR ?= 6 -VERSION_BUILD ?= 0-beta.0 +VERSION_BUILD ?= 0-beta.1 RAW_VERSION=$(VERSION_MAJOR).$(VERSION_MINOR).${VERSION_BUILD} VERSION ?= v$(RAW_VERSION) # Default to .0 for higher cache hit rates, as build increments typically don't require new ISO versions -ISO_VERSION ?= v1.5.1 +ISO_VERSION ?= v1.6.0-beta.1 # Dashes are valid in semver, but not Linux packaging. Use ~ to delimit alpha/beta DEB_VERSION ?= $(subst -,~,$(RAW_VERSION)) RPM_VERSION ?= $(DEB_VERSION) From aaae707702a9063eff1433aea28ef8336ef309b5 Mon Sep 17 00:00:00 2001 From: Nanik T Date: Thu, 7 Nov 2019 12:20:52 +1100 Subject: [PATCH 17/72] Add test case to test file sync between host and VM. Executing 'minikube start' when it is currently running will allow user to sync folder under MINIKUBE_HOME/files to the VM. The test case will copy a file to the MINIKUBE_HOME/files/etc folder to be copied to the VM /etc/ folder. --- test/integration/functional_test.go | 38 +++++++++++++++++++++++++++++ test/integration/testdata/sync.test | 1 + 2 files changed, 39 insertions(+) create mode 100644 test/integration/testdata/sync.test diff --git a/test/integration/functional_test.go b/test/integration/functional_test.go index 3a1a234e24..eab7b6a50a 100644 --- a/test/integration/functional_test.go +++ b/test/integration/functional_test.go @@ -35,8 +35,13 @@ import ( "testing" "time" + "github.com/google/go-cmp/cmp" + + "k8s.io/minikube/pkg/minikube/localpath" + "github.com/elazarl/goproxy" "github.com/hashicorp/go-retryablehttp" + "github.com/otiai10/copy" "github.com/phayes/freeport" "github.com/pkg/errors" "golang.org/x/build/kubernetes/api" @@ -59,6 +64,7 @@ func TestFunctional(t *testing.T) { name string validator validateFunc }{ + {"CopySyncFile", setupFileSync}, // Set file for the file sync test case {"StartWithProxy", validateStartWithProxy}, // Set everything else up for success {"KubeContext", validateKubeContext}, // Racy: must come immediately after "minikube start" {"KubectlGetPods", validateKubectlGetPods}, // Make sure apiserver is up @@ -96,6 +102,7 @@ func TestFunctional(t *testing.T) { {"TunnelCmd", validateTunnelCmd}, {"SSHCmd", validateSSHCmd}, {"MySQL", validateMySQL}, + {"FileSync", validateFileSync}, } for _, tc := range tests { tc := tc @@ -573,6 +580,37 @@ func validateMySQL(ctx context.Context, t *testing.T, profile string) { } } +// Copy extra file into minikube home folder for file sync test +func setupFileSync(ctx context.Context, t *testing.T, profile string) { + // 1. copy random file to MINIKUBE_HOME/files/etc + f := filepath.Join(localpath.MiniPath(), "/files/etc/sync.test") + err := copy.Copy("./testdata/sync.test", f) + if err != nil { + t.Fatalf("copy: %v", err) + } +} + +// validateFileSync to check existence of the test file +func validateFileSync(ctx context.Context, t *testing.T, profile string) { + if NoneDriver() { + t.Skipf("skipping: ssh unsupported by none") + } + // check file existence + rr, err := Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "cat /etc/sync.test")) + if err != nil { + t.Errorf("%s failed: %v", rr.Args, err) + } + + expected, err := ioutil.ReadFile("./testdata/sync.test") + if err != nil { + t.Errorf("test file not found: %v", err) + } + + if diff := cmp.Diff(string(expected), rr.Stdout.String()); diff != "" { + t.Errorf("/etc/sync.test content mismatch (-want +got):\n%s", diff) + } +} + // startHTTPProxy runs a local http proxy and sets the env vars for it. func startHTTPProxy(t *testing.T) (*http.Server, error) { port, err := freeport.GetFreePort() diff --git a/test/integration/testdata/sync.test b/test/integration/testdata/sync.test new file mode 100644 index 0000000000..fd4616956f --- /dev/null +++ b/test/integration/testdata/sync.test @@ -0,0 +1 @@ +Test file for checking file sync process \ No newline at end of file From 8a4b22e222e8c1024ea4416539969957dd528812 Mon Sep 17 00:00:00 2001 From: Sharif Elgamal Date: Tue, 26 Nov 2019 13:07:30 -0800 Subject: [PATCH 18/72] Add release notes for 1.6.0-beta.1 --- CHANGELOG.md | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 80d57ff46d..3314170d60 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,30 @@ # Release Notes +## Version 1.6.0-beta.1 - 2019-11-26 + +* cri-o v1.16.0 [#5970](https://github.com/kubernetes/minikube/pull/5970) +* Update default k8s version to 1.17.0-rc.1 [#5973](https://github.com/kubernetes/minikube/pull/5973) +* Update crictl to v1.16.1 [#5972](https://github.com/kubernetes/minikube/pull/5972) +* Update docker to v19.03.5 [#5914](https://github.com/kubernetes/minikube/pull/5914) +* Fix profile list for non existenting folder [#5955](https://github.com/kubernetes/minikube/pull/5955) +* Upgrade podman to 1.6.3 [#5971](https://github.com/kubernetes/minikube/pull/5971) +* Fix validation of container-runtime config [#5964](https://github.com/kubernetes/minikube/pull/5964) +* Add option for virtualbox users to set nat-nic-type [#5960](https://github.com/kubernetes/minikube/pull/5960) +* Upgrade buildroot minor version to 2019.02.7 [#5967](https://github.com/kubernetes/minikube/pull/5967) +* dashboard: Update to latest images (2.0.0-beta6) [#5934](https://github.com/kubernetes/minikube/pull/5934) + +Huge thank you for this release towards our contributors: +- Adam Crowder +- Anders F Björklund +- David Newman +- Harsimran Singh Maan +- Kenta Iso +- Medya Ghazizadeh +- Reuven Harrison +- Sharif Elgamal +- Thomas Stromberg +- yuxiaobo + ## Version 1.6.0-beta.0 - 2019-11-15 * Update DefaultKubernetesVersion to v1.17.0-beta.1 to prepare for betas [#5925](https://github.com/kubernetes/minikube/pull/5925) @@ -30,7 +55,6 @@ Huge thank you for this release towards our contributors: - Steffen Gransow - Thomas Strömberg - ## Version 1.5.2 - 2019-10-31 (Happy Halloween!) * service: fix --url mode [#5790](https://github.com/kubernetes/minikube/pull/5790) From 63868dba4dc665c84bcb345aa82e6142ba99d9a4 Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Tue, 26 Nov 2019 16:08:07 -0800 Subject: [PATCH 19/72] add integrationn tests for cache --- go.mod | 3 --- test/integration/functional_test.go | 32 +++++++++++++++++++++++++---- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/go.mod b/go.mod index 46cf856a68..8976fb1bec 100644 --- a/go.mod +++ b/go.mod @@ -21,14 +21,11 @@ require ( github.com/docker/machine v0.7.1-0.20190718054102-a555e4f7a8f5 // version is 0.7.1 to pin to a555e4f7a8f5 github.com/elazarl/goproxy v0.0.0-20190421051319-9d40249d3c2f github.com/elazarl/goproxy/ext v0.0.0-20190421051319-9d40249d3c2f // indirect - github.com/ghodss/yaml v1.0.0 // indirect github.com/go-ole/go-ole v1.2.4 // indirect github.com/golang-collections/collections v0.0.0-20130729185459-604e922904d3 github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b - github.com/google/btree v1.0.0 // indirect github.com/google/go-cmp v0.3.0 github.com/gorilla/mux v1.7.1 // indirect - github.com/grpc-ecosystem/grpc-gateway v1.5.0 // indirect github.com/hashicorp/errwrap v0.0.0-20141028054710-7554cd9344ce // indirect github.com/hashicorp/go-getter v1.4.0 github.com/hashicorp/go-multierror v0.0.0-20160811015721-8c5f0ad93604 // indirect diff --git a/test/integration/functional_test.go b/test/integration/functional_test.go index eab7b6a50a..870e68dfcf 100644 --- a/test/integration/functional_test.go +++ b/test/integration/functional_test.go @@ -308,17 +308,41 @@ func validateDNS(ctx context.Context, t *testing.T, profile string) { } } -// validateCacheCmd asserts basic "ssh" command functionality +// validateCacheCmd tests functionality of cache command (cache add, delete, list) func validateCacheCmd(ctx context.Context, t *testing.T, profile string) { if NoneDriver() { t.Skipf("skipping: cache unsupported by none") } - for _, img := range []string{"busybox", "busybox:1.28.4-glibc", "mysql:5.6", "gcr.io/hello-minikube-zero-install/hello-node"} { - rr, err := Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "cache", "add", img)) + for _, img := range []string{"busybox", "busybox:1.28.4-glibc", "k8s.gcr.io/pause:latest"} { + _, err := Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "cache", "add", img)) if err != nil { - t.Errorf("%s failed: %v", rr.Args, err) + t.Errorf("failed to add %q to cache", img) } } + + rr, err := Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "docker", "images")) + if err != nil { + t.Errorf("failed to get docker images through ssh %v", err) + + } + if !strings.Contains(rr.Output(), "busybox:1.28.4-glibc") { + t.Errorf("expected busybox:1.28.4-glibc to be loaded by docker inside minikube node. but got %s", rr.Output()) + } + _, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "cache", "delete", "busybox:1.28.4-glibc")) + if err != nil { + t.Errorf("failed to delete image busybox:1.28.4-glibc from cache: %v", err) + } + + rr, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "cache", "list")) + if err != nil { + t.Errorf("cache list failed: %v", err) + } + if !strings.Contains(rr.Output(), "k8s.gcr.io/pause") { + t.Errorf("cache list did not include k8s.gcr.io/pause") + } + if strings.Contains(rr.Output(), "busybox:1.28.4-glibc") { + t.Errorf("cache list should not include busybox:1.28.4-glibc") + } } // validateConfigCmd asserts basic "config" command functionality From 71857f42881a38e30796c6c0ffeb701e151939e2 Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Tue, 26 Nov 2019 16:19:29 -0800 Subject: [PATCH 20/72] organize cache functional test --- test/integration/functional_test.go | 65 +++++++++++++++++------------ 1 file changed, 38 insertions(+), 27 deletions(-) diff --git a/test/integration/functional_test.go b/test/integration/functional_test.go index 870e68dfcf..f7f5207522 100644 --- a/test/integration/functional_test.go +++ b/test/integration/functional_test.go @@ -313,36 +313,47 @@ func validateCacheCmd(ctx context.Context, t *testing.T, profile string) { if NoneDriver() { t.Skipf("skipping: cache unsupported by none") } - for _, img := range []string{"busybox", "busybox:1.28.4-glibc", "k8s.gcr.io/pause:latest"} { - _, err := Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "cache", "add", img)) - if err != nil { - t.Errorf("failed to add %q to cache", img) - } - } + t.Run("cache", func(t *testing.T) { + t.Run("add", func(t *testing.T) { + for _, img := range []string{"busybox", "busybox:1.28.4-glibc", "k8s.gcr.io/pause:latest"} { + _, err := Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "cache", "add", img)) + if err != nil { + t.Errorf("Failed to cache image %q", img) + } + } + }) + t.Run("delete", func(t *testing.T) { + _, err := Run(t, exec.CommandContext(ctx, Target(), "cache", "delete", "busybox:1.28.4-glibc")) + if err != nil { + t.Errorf("failed to delete image busybox:1.28.4-glibc from cache: %v", err) + } + }) - rr, err := Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "docker", "images")) - if err != nil { - t.Errorf("failed to get docker images through ssh %v", err) + t.Run("list", func(t *testing.T) { + rr, err := Run(t, exec.CommandContext(ctx, Target(), "cache", "list")) + if err != nil { + t.Errorf("cache list failed: %v", err) + } + if !strings.Contains(rr.Output(), "k8s.gcr.io/pause") { + t.Errorf("cache list did not include k8s.gcr.io/pause") + } + if strings.Contains(rr.Output(), "busybox:1.28.4-glibc") { + t.Errorf("cache list should not include busybox:1.28.4-glibc") + } + }) - } - if !strings.Contains(rr.Output(), "busybox:1.28.4-glibc") { - t.Errorf("expected busybox:1.28.4-glibc to be loaded by docker inside minikube node. but got %s", rr.Output()) - } - _, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "cache", "delete", "busybox:1.28.4-glibc")) - if err != nil { - t.Errorf("failed to delete image busybox:1.28.4-glibc from cache: %v", err) - } + t.Run("verify cache inside node", func(t *testing.T) { + rr, err := Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "docker", "images")) + if err != nil { + t.Errorf("failed to get docker images through ssh %v", err) + } - rr, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "cache", "list")) - if err != nil { - t.Errorf("cache list failed: %v", err) - } - if !strings.Contains(rr.Output(), "k8s.gcr.io/pause") { - t.Errorf("cache list did not include k8s.gcr.io/pause") - } - if strings.Contains(rr.Output(), "busybox:1.28.4-glibc") { - t.Errorf("cache list should not include busybox:1.28.4-glibc") - } + if !strings.Contains(rr.Output(), "busybox:1.28.4-glibc") { + t.Errorf("expected busybox:1.28.4-glibc to be loaded by docker inside minikube node. but got %s", rr.Output()) + } + + }) + }) } // validateConfigCmd asserts basic "config" command functionality From 72b17439bdac8e78760550e8ff7a2ed7758a8553 Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Tue, 26 Nov 2019 16:21:12 -0800 Subject: [PATCH 21/72] clean up temp files --- pkg/minikube/machine/cache_images.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/minikube/machine/cache_images.go b/pkg/minikube/machine/cache_images.go index 587a27f816..24c2903414 100644 --- a/pkg/minikube/machine/cache_images.go +++ b/pkg/minikube/machine/cache_images.go @@ -331,6 +331,12 @@ func CacheImage(image, dst string) error { if err != nil { return err } + defer func() { // clean up temp files + err := os.Remove(f.Name()) + if err != nil { + glog.Infof("Failed to clean up the temp file %s : %v", f.Name(), err) + } + }() tag, err := name.NewTag(image, name.WeakValidation) if err != nil { return err From 6c08fedf970cd851ef7f0951f5f80e1dc9436ce4 Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Tue, 26 Nov 2019 17:48:37 -0800 Subject: [PATCH 22/72] remove cyclic depdenecy and make cluster pkg smaller --- cmd/minikube/cmd/delete.go | 4 +- cmd/minikube/cmd/delete_test.go | 4 +- pkg/minikube/machine/cache_images.go | 41 +++++++++++++------ pkg/minikube/{cluster => machine}/machine.go | 8 ++-- .../{cluster => machine}/machine_test.go | 2 +- 5 files changed, 37 insertions(+), 22 deletions(-) rename pkg/minikube/{cluster => machine}/machine.go (95%) rename pkg/minikube/{cluster => machine}/machine_test.go (99%) diff --git a/cmd/minikube/cmd/delete.go b/cmd/minikube/cmd/delete.go index 1c820af04a..898c470217 100644 --- a/cmd/minikube/cmd/delete.go +++ b/cmd/minikube/cmd/delete.go @@ -163,7 +163,7 @@ func DeleteProfiles(profiles []*pkg_config.Profile) []error { err := deleteProfile(profile) if err != nil { - mm, loadErr := cluster.LoadMachine(profile.Name) + mm, loadErr := machine.LoadMachine(profile.Name) if !profile.IsValid() || (loadErr != nil || !mm.IsValid()) { invalidProfileDeletionErrs := deleteInvalidProfile(profile) @@ -263,7 +263,7 @@ func deleteInvalidProfile(profile *pkg_config.Profile) []error { } } - pathToMachine := cluster.MachinePath(profile.Name, localpath.MiniPath()) + pathToMachine := machine.MachinePath(profile.Name, localpath.MiniPath()) if _, err := os.Stat(pathToMachine); !os.IsNotExist(err) { err := os.RemoveAll(pathToMachine) if err != nil { diff --git a/cmd/minikube/cmd/delete_test.go b/cmd/minikube/cmd/delete_test.go index 69a37be735..29915a394a 100644 --- a/cmd/minikube/cmd/delete_test.go +++ b/cmd/minikube/cmd/delete_test.go @@ -26,9 +26,9 @@ import ( "github.com/otiai10/copy" "github.com/spf13/viper" - "k8s.io/minikube/pkg/minikube/cluster" "k8s.io/minikube/pkg/minikube/config" "k8s.io/minikube/pkg/minikube/localpath" + "k8s.io/minikube/pkg/minikube/machine" ) // except returns a list of strings, minus the excluded ones @@ -117,7 +117,7 @@ func TestDeleteProfile(t *testing.T) { t.Errorf("Profile folder of profile \"%s\" was not deleted", profile.Name) } - pathToMachine := cluster.MachinePath(profile.Name, localpath.MiniPath()) + pathToMachine := machine.MachinePath(profile.Name, localpath.MiniPath()) if _, err := os.Stat(pathToMachine); !os.IsNotExist(err) { t.Errorf("Profile folder of profile \"%s\" was not deleted", profile.Name) } diff --git a/pkg/minikube/machine/cache_images.go b/pkg/minikube/machine/cache_images.go index 24c2903414..edf9ac410f 100644 --- a/pkg/minikube/machine/cache_images.go +++ b/pkg/minikube/machine/cache_images.go @@ -27,6 +27,7 @@ import ( "sync" "time" + "github.com/docker/machine/libmachine/state" "github.com/golang/glog" "github.com/google/go-containerregistry/pkg/authn" "github.com/google/go-containerregistry/pkg/name" @@ -38,6 +39,7 @@ import ( "golang.org/x/sync/errgroup" "k8s.io/minikube/pkg/minikube/assets" "k8s.io/minikube/pkg/minikube/bootstrapper" + "k8s.io/minikube/pkg/minikube/cluster" "k8s.io/minikube/pkg/minikube/command" "k8s.io/minikube/pkg/minikube/config" "k8s.io/minikube/pkg/minikube/constants" @@ -95,7 +97,6 @@ func CacheImages(images []string, cacheDir string) error { func LoadImages(cmd command.Runner, images []string, cacheDir string) error { glog.Infof("LoadImages start: %s", images) defer glog.Infof("LoadImages end") - var g errgroup.Group // Load profile cluster config from file cc, err := config.Load() @@ -121,7 +122,7 @@ func LoadImages(cmd command.Runner, images []string, cacheDir string) error { return nil } -// CacheAndLoadImages caches and loads images +// CacheAndLoadImages caches and loads images to all profiles func CacheAndLoadImages(images []string) error { if err := CacheImages(images, constants.ImageCacheDir); err != nil { return err @@ -131,20 +132,34 @@ func CacheAndLoadImages(images []string) error { return err } defer api.Close() - cc, err := config.Load() + profiles, _, err := config.ListProfiles() // need to load image to all profiles if err != nil { - return err + return errors.Wrap(err, "list profiles") } - h, err := api.Load(cc.Name) - if err != nil { - return err + for _, p := range profiles { // adding images to all the profiles + pName := p.Name // capture the loop variable + status, err := cluster.GetHostStatus(api, pName) + if err != nil { + glog.Warningf("skipping loading cache for profile %s", pName) + glog.Errorf("error getting status for %s: %v", pName, err) + continue // try next machine + } + if status == state.Running.String() { // the not running hosts will load on next start + h, err := api.Load(pName) + if err != nil { + return err + } + cr, err := CommandRunner(h) + if err != nil { + return err + } + err = LoadImages(cr, images, constants.ImageCacheDir) + if err != nil { + glog.Warningf("Failed to load cached images for profile %s. make sure the profile is running. %v", pName, err) + } + } } - - runner, err := CommandRunner(h) - if err != nil { - return err - } - return LoadImages(runner, images, constants.ImageCacheDir) + return err } // # ParseReference cannot have a : in the directory path diff --git a/pkg/minikube/cluster/machine.go b/pkg/minikube/machine/machine.go similarity index 95% rename from pkg/minikube/cluster/machine.go rename to pkg/minikube/machine/machine.go index 90f7979cba..98299905fb 100644 --- a/pkg/minikube/cluster/machine.go +++ b/pkg/minikube/machine/machine.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package cluster +package machine import ( "io/ioutil" @@ -23,8 +23,8 @@ import ( "github.com/docker/machine/libmachine/host" "github.com/golang/glog" "github.com/pkg/errors" + "k8s.io/minikube/pkg/minikube/cluster" "k8s.io/minikube/pkg/minikube/localpath" - "k8s.io/minikube/pkg/minikube/machine" ) // Machine contains information about a machine @@ -85,12 +85,12 @@ func ListMachines(miniHome ...string) (validMachines []*Machine, inValidMachines // LoadMachine loads a machine or throws an error if the machine could not be loadedG func LoadMachine(name string) (*Machine, error) { - api, err := machine.NewAPIClient() + api, err := NewAPIClient() if err != nil { return nil, err } - h, err := CheckIfHostExistsAndLoad(api, name) + h, err := cluster.CheckIfHostExistsAndLoad(api, name) if err != nil { return nil, err } diff --git a/pkg/minikube/cluster/machine_test.go b/pkg/minikube/machine/machine_test.go similarity index 99% rename from pkg/minikube/cluster/machine_test.go rename to pkg/minikube/machine/machine_test.go index a04f40aa8b..380decf7aa 100644 --- a/pkg/minikube/cluster/machine_test.go +++ b/pkg/minikube/machine/machine_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package cluster +package machine import ( "io/ioutil" From cdb68a139e6e576760b68ab06fc492db3bd502ce Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Tue, 26 Nov 2019 18:32:59 -0800 Subject: [PATCH 23/72] refactor config to allow load profile config --- cmd/minikube/cmd/start.go | 8 +++---- pkg/minikube/bootstrapper/bootstrapper.go | 2 +- pkg/minikube/bootstrapper/kubeadm/kubeadm.go | 24 ++++++++++---------- pkg/minikube/config/config.go | 5 +++- pkg/minikube/machine/cache_images.go | 16 +++++++------ 5 files changed, 30 insertions(+), 25 deletions(-) diff --git a/cmd/minikube/cmd/start.go b/cmd/minikube/cmd/start.go index f186345adb..e859691834 100644 --- a/cmd/minikube/cmd/start.go +++ b/cmd/minikube/cmd/start.go @@ -352,7 +352,7 @@ func runStart(cmd *cobra.Command, args []string) { } // setup kubeadm (must come after setupKubeconfig) - bs := setupKubeAdm(machineAPI, config.KubernetesConfig) + bs := setupKubeAdm(machineAPI, config) // pull images or restart cluster bootstrapCluster(bs, cr, mRunner, config.KubernetesConfig, preExists, isUpgrade) @@ -1176,7 +1176,7 @@ func getKubernetesVersion(old *cfg.MachineConfig) (string, bool) { } // setupKubeAdm adds any requested files into the VM before Kubernetes is started -func setupKubeAdm(mAPI libmachine.API, kc cfg.KubernetesConfig) bootstrapper.Bootstrapper { +func setupKubeAdm(mAPI libmachine.API, config cfg.MachineConfig) bootstrapper.Bootstrapper { bs, err := getClusterBootstrapper(mAPI, viper.GetString(cmdcfg.Bootstrapper)) if err != nil { exit.WithError("Failed to get bootstrapper", err) @@ -1185,10 +1185,10 @@ func setupKubeAdm(mAPI libmachine.API, kc cfg.KubernetesConfig) bootstrapper.Boo out.T(out.Option, "{{.extra_option_component_name}}.{{.key}}={{.value}}", out.V{"extra_option_component_name": eo.Component, "key": eo.Key, "value": eo.Value}) } // Loads cached images, generates config files, download binaries - if err := bs.UpdateCluster(kc); err != nil { + if err := bs.UpdateCluster(config); err != nil { exit.WithError("Failed to update cluster", err) } - if err := bs.SetupCerts(kc); err != nil { + if err := bs.SetupCerts(config.KubernetesConfig); err != nil { exit.WithError("Failed to setup certs", err) } return bs diff --git a/pkg/minikube/bootstrapper/bootstrapper.go b/pkg/minikube/bootstrapper/bootstrapper.go index 119466da0a..24b650232a 100644 --- a/pkg/minikube/bootstrapper/bootstrapper.go +++ b/pkg/minikube/bootstrapper/bootstrapper.go @@ -38,7 +38,7 @@ type Bootstrapper interface { // PullImages pulls images necessary for a cluster. Success should not be required. PullImages(config.KubernetesConfig) error StartCluster(config.KubernetesConfig) error - UpdateCluster(config.KubernetesConfig) error + UpdateCluster(config.MachineConfig) error DeleteCluster(config.KubernetesConfig) error WaitForCluster(config.KubernetesConfig, time.Duration) error // LogCommands returns a map of log type to a command which will display that log. diff --git a/pkg/minikube/bootstrapper/kubeadm/kubeadm.go b/pkg/minikube/bootstrapper/kubeadm/kubeadm.go index 2643ec9d3c..554efa1606 100644 --- a/pkg/minikube/bootstrapper/kubeadm/kubeadm.go +++ b/pkg/minikube/bootstrapper/kubeadm/kubeadm.go @@ -629,33 +629,33 @@ func NewKubeletConfig(k8s config.KubernetesConfig, r cruntime.Manager) ([]byte, } // UpdateCluster updates the cluster -func (k *Bootstrapper) UpdateCluster(cfg config.KubernetesConfig) error { - images := images.CachedImages(cfg.ImageRepository, cfg.KubernetesVersion) - if cfg.ShouldLoadCachedImages { - if err := machine.LoadImages(k.c, images, constants.ImageCacheDir); err != nil { +func (k *Bootstrapper) UpdateCluster(cfg config.MachineConfig) error { + images := images.CachedImages(cfg.KubernetesConfig.KubernetesVersion, cfg.KubernetesConfig.KubernetesVersion) + if cfg.KubernetesConfig.ShouldLoadCachedImages { + if err := machine.LoadImages(&cfg, k.c, images, constants.ImageCacheDir); err != nil { out.FailureT("Unable to load cached images: {{.error}}", out.V{"error": err}) } } - r, err := cruntime.New(cruntime.Config{Type: cfg.ContainerRuntime, Socket: cfg.CRISocket}) + r, err := cruntime.New(cruntime.Config{Type: cfg.ContainerRuntime, Socket: cfg.KubernetesConfig.CRISocket}) if err != nil { return errors.Wrap(err, "runtime") } - kubeadmCfg, err := generateConfig(cfg, r) + kubeadmCfg, err := generateConfig(cfg.KubernetesConfig, r) if err != nil { return errors.Wrap(err, "generating kubeadm cfg") } - kubeletCfg, err := NewKubeletConfig(cfg, r) + kubeletCfg, err := NewKubeletConfig(cfg.KubernetesConfig, r) if err != nil { return errors.Wrap(err, "generating kubelet config") } - kubeletService, err := NewKubeletService(cfg) + kubeletService, err := NewKubeletService(cfg.KubernetesConfig) if err != nil { return errors.Wrap(err, "generating kubelet service") } - glog.Infof("kubelet %s config:\n%s", cfg.KubernetesVersion, kubeletCfg) + glog.Infof("kubelet %s config:\n%s", cfg.KubernetesConfig, kubeletCfg) stopCmd := exec.Command("/bin/bash", "-c", "pgrep kubelet && sudo systemctl stop kubelet") // stop kubelet to avoid "Text File Busy" error @@ -663,11 +663,11 @@ func (k *Bootstrapper) UpdateCluster(cfg config.KubernetesConfig) error { glog.Warningf("unable to stop kubelet: %s command: %q output: %q", err, rr.Command(), rr.Output()) } - if err := transferBinaries(cfg, k.c); err != nil { + if err := transferBinaries(cfg.KubernetesConfig, k.c); err != nil { return errors.Wrap(err, "downloading binaries") } - files := configFiles(cfg, kubeadmCfg, kubeletCfg, kubeletService) - if err := addAddons(&files, assets.GenerateTemplateData(cfg)); err != nil { + files := configFiles(cfg.KubernetesConfig, kubeadmCfg, kubeletCfg, kubeletService) + if err := addAddons(&files, assets.GenerateTemplateData(cfg.KubernetesConfig)); err != nil { return errors.Wrap(err, "adding addons") } for _, f := range files { diff --git a/pkg/minikube/config/config.go b/pkg/minikube/config/config.go index 7b7501ad15..7e53d82554 100644 --- a/pkg/minikube/config/config.go +++ b/pkg/minikube/config/config.go @@ -124,8 +124,11 @@ func encode(w io.Writer, m MinikubeConfig) error { } // Load loads the kubernetes and machine config for the current machine -func Load() (*MachineConfig, error) { +func Load(profile ...string) (*MachineConfig, error) { machine := viper.GetString(MachineProfile) + if len(profile) > 0 { + machine = profile[0] + } return DefaultLoader.LoadConfigFromFile(machine) } diff --git a/pkg/minikube/machine/cache_images.go b/pkg/minikube/machine/cache_images.go index edf9ac410f..73c43d9524 100644 --- a/pkg/minikube/machine/cache_images.go +++ b/pkg/minikube/machine/cache_images.go @@ -17,6 +17,7 @@ limitations under the License. package machine import ( + "fmt" "io/ioutil" "os" "os/exec" @@ -94,15 +95,10 @@ func CacheImages(images []string, cacheDir string) error { } // LoadImages loads previously cached images into the container runtime -func LoadImages(cmd command.Runner, images []string, cacheDir string) error { +func LoadImages(cc *config.MachineConfig, cmd command.Runner, images []string, cacheDir string) error { glog.Infof("LoadImages start: %s", images) defer glog.Infof("LoadImages end") var g errgroup.Group - // Load profile cluster config from file - cc, err := config.Load() - if err != nil && !os.IsNotExist(err) { - glog.Errorln("Error loading profile config: ", err) - } for _, image := range images { image := image g.Go(func() error { @@ -145,6 +141,7 @@ func CacheAndLoadImages(images []string) error { continue // try next machine } if status == state.Running.String() { // the not running hosts will load on next start + fmt.Println("got a running", pName) h, err := api.Load(pName) if err != nil { return err @@ -153,7 +150,12 @@ func CacheAndLoadImages(images []string) error { if err != nil { return err } - err = LoadImages(cr, images, constants.ImageCacheDir) + c, err := config.Load(pName) + if err != nil { + return err + } + fmt.Printf("inside CacheAndLoadImages, \n images %+v \n ", images) + err = LoadImages(c, cr, images, constants.ImageCacheDir) if err != nil { glog.Warningf("Failed to load cached images for profile %s. make sure the profile is running. %v", pName, err) } From d8d7849d21fcbeb9e4f4829a3b6bc9ce8a0e3119 Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Tue, 26 Nov 2019 19:20:38 -0800 Subject: [PATCH 24/72] fix typo and remove debugging logs --- pkg/minikube/bootstrapper/kubeadm/kubeadm.go | 2 +- pkg/minikube/machine/cache_images.go | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/pkg/minikube/bootstrapper/kubeadm/kubeadm.go b/pkg/minikube/bootstrapper/kubeadm/kubeadm.go index 554efa1606..727c5870c2 100644 --- a/pkg/minikube/bootstrapper/kubeadm/kubeadm.go +++ b/pkg/minikube/bootstrapper/kubeadm/kubeadm.go @@ -630,7 +630,7 @@ func NewKubeletConfig(k8s config.KubernetesConfig, r cruntime.Manager) ([]byte, // UpdateCluster updates the cluster func (k *Bootstrapper) UpdateCluster(cfg config.MachineConfig) error { - images := images.CachedImages(cfg.KubernetesConfig.KubernetesVersion, cfg.KubernetesConfig.KubernetesVersion) + images := images.CachedImages(cfg.KubernetesConfig.ImageRepository, cfg.KubernetesConfig.KubernetesVersion) if cfg.KubernetesConfig.ShouldLoadCachedImages { if err := machine.LoadImages(&cfg, k.c, images, constants.ImageCacheDir); err != nil { out.FailureT("Unable to load cached images: {{.error}}", out.V{"error": err}) diff --git a/pkg/minikube/machine/cache_images.go b/pkg/minikube/machine/cache_images.go index 73c43d9524..126ab12940 100644 --- a/pkg/minikube/machine/cache_images.go +++ b/pkg/minikube/machine/cache_images.go @@ -17,7 +17,6 @@ limitations under the License. package machine import ( - "fmt" "io/ioutil" "os" "os/exec" @@ -141,7 +140,6 @@ func CacheAndLoadImages(images []string) error { continue // try next machine } if status == state.Running.String() { // the not running hosts will load on next start - fmt.Println("got a running", pName) h, err := api.Load(pName) if err != nil { return err @@ -154,7 +152,6 @@ func CacheAndLoadImages(images []string) error { if err != nil { return err } - fmt.Printf("inside CacheAndLoadImages, \n images %+v \n ", images) err = LoadImages(c, cr, images, constants.ImageCacheDir) if err != nil { glog.Warningf("Failed to load cached images for profile %s. make sure the profile is running. %v", pName, err) From 95717c4793d413f3e1bc94d4871d2fc9b5ac4b7a Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Tue, 26 Nov 2019 19:53:27 -0800 Subject: [PATCH 25/72] add status to profile list --- cmd/minikube/cmd/config/profile_list.go | 30 +++++++++++++++++++++++-- go.mod | 3 --- pkg/minikube/config/types.go | 1 + 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/cmd/minikube/cmd/config/profile_list.go b/cmd/minikube/cmd/config/profile_list.go index 7842314846..02f8b9ba1d 100644 --- a/cmd/minikube/cmd/config/profile_list.go +++ b/cmd/minikube/cmd/config/profile_list.go @@ -23,10 +23,13 @@ import ( "strconv" "strings" + "k8s.io/minikube/pkg/minikube/cluster" "k8s.io/minikube/pkg/minikube/config" "k8s.io/minikube/pkg/minikube/exit" + "k8s.io/minikube/pkg/minikube/machine" "k8s.io/minikube/pkg/minikube/out" + "github.com/golang/glog" "github.com/olekukonko/tablewriter" "github.com/spf13/cobra" ) @@ -58,7 +61,7 @@ var printProfilesTable = func() { var validData [][]string table := tablewriter.NewWriter(os.Stdout) - table.SetHeader([]string{"Profile", "VM Driver", "NodeIP", "Node Port", "Kubernetes Version"}) + table.SetHeader([]string{"Profile", "VM Driver", "NodeIP", "Node Port", "Kubernetes Version", "Status"}) table.SetAutoFormatHeaders(false) table.SetBorders(tablewriter.Border{Left: true, Top: true, Right: true, Bottom: true}) table.SetCenterSeparator("|") @@ -67,8 +70,18 @@ var printProfilesTable = func() { if len(validProfiles) == 0 || err != nil { exit.UsageT("No minikube profile was found. You can create one using `minikube start`.") } + api, err := machine.NewAPIClient() + if err != nil { + glog.Infof("failed to get machine api client %v", err) + } + defer api.Close() + for _, p := range validProfiles { - validData = append(validData, []string{p.Name, p.Config[0].VMDriver, p.Config[0].KubernetesConfig.NodeIP, strconv.Itoa(p.Config[0].KubernetesConfig.NodePort), p.Config[0].KubernetesConfig.KubernetesVersion}) + p.Status, err = cluster.GetHostStatus(api, p.Name) + if err != nil { + glog.Infof("error getting host status for %v", err) + } + validData = append(validData, []string{p.Name, p.Config[0].VMDriver, p.Config[0].KubernetesConfig.NodeIP, strconv.Itoa(p.Config[0].KubernetesConfig.NodePort), p.Config[0].KubernetesConfig.KubernetesVersion, p.Status}) } table.AppendBulk(validData) @@ -93,7 +106,20 @@ var printProfilesTable = func() { } var printProfilesJSON = func() { + api, err := machine.NewAPIClient() + if err != nil { + glog.Infof("failed to get machine api client %v", err) + } + defer api.Close() + validProfiles, invalidProfiles, err := config.ListProfiles() + for _, v := range validProfiles { + status, err := cluster.GetHostStatus(api, v.Name) + if err != nil { + glog.Infof("error getting host status for %v", err) + } + v.Status = status + } var valid []*config.Profile var invalid []*config.Profile diff --git a/go.mod b/go.mod index 46cf856a68..8976fb1bec 100644 --- a/go.mod +++ b/go.mod @@ -21,14 +21,11 @@ require ( github.com/docker/machine v0.7.1-0.20190718054102-a555e4f7a8f5 // version is 0.7.1 to pin to a555e4f7a8f5 github.com/elazarl/goproxy v0.0.0-20190421051319-9d40249d3c2f github.com/elazarl/goproxy/ext v0.0.0-20190421051319-9d40249d3c2f // indirect - github.com/ghodss/yaml v1.0.0 // indirect github.com/go-ole/go-ole v1.2.4 // indirect github.com/golang-collections/collections v0.0.0-20130729185459-604e922904d3 github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b - github.com/google/btree v1.0.0 // indirect github.com/google/go-cmp v0.3.0 github.com/gorilla/mux v1.7.1 // indirect - github.com/grpc-ecosystem/grpc-gateway v1.5.0 // indirect github.com/hashicorp/errwrap v0.0.0-20141028054710-7554cd9344ce // indirect github.com/hashicorp/go-getter v1.4.0 github.com/hashicorp/go-multierror v0.0.0-20160811015721-8c5f0ad93604 // indirect diff --git a/pkg/minikube/config/types.go b/pkg/minikube/config/types.go index cc8990aa0e..698f1542b4 100644 --- a/pkg/minikube/config/types.go +++ b/pkg/minikube/config/types.go @@ -26,6 +26,7 @@ import ( // Profile represents a minikube profile type Profile struct { Name string + Status string // running, stopped Config []*MachineConfig } From d7b6e6603863871bdc9236019ec319a262e979f2 Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Tue, 26 Nov 2019 20:07:56 -0800 Subject: [PATCH 26/72] fix unit tests and improve naming --- cmd/minikube/cmd/delete.go | 4 ++-- cmd/minikube/cmd/delete_test.go | 2 +- pkg/minikube/bootstrapper/kubeadm/kubeadm.go | 2 +- pkg/minikube/machine/machine.go | 14 +++++++------- pkg/minikube/machine/machine_test.go | 2 +- .../.minikube/machines/p1/config.json | 0 .../.minikube/machines/p2/config.json | 0 .../.minikube/machines/p3_empty_config/config.json | 0 .../machines/p4_invalid_machine_config/config.json | 0 .../machines/p5_partial_config/config.json | 0 10 files changed, 12 insertions(+), 12 deletions(-) rename pkg/minikube/{cluster => machine}/testdata/list-machines/.minikube/machines/p1/config.json (100%) rename pkg/minikube/{cluster => machine}/testdata/list-machines/.minikube/machines/p2/config.json (100%) rename pkg/minikube/{cluster => machine}/testdata/list-machines/.minikube/machines/p3_empty_config/config.json (100%) rename pkg/minikube/{cluster => machine}/testdata/list-machines/.minikube/machines/p4_invalid_machine_config/config.json (100%) rename pkg/minikube/{cluster => machine}/testdata/list-machines/.minikube/machines/p5_partial_config/config.json (100%) diff --git a/cmd/minikube/cmd/delete.go b/cmd/minikube/cmd/delete.go index 898c470217..54f13720b5 100644 --- a/cmd/minikube/cmd/delete.go +++ b/cmd/minikube/cmd/delete.go @@ -163,7 +163,7 @@ func DeleteProfiles(profiles []*pkg_config.Profile) []error { err := deleteProfile(profile) if err != nil { - mm, loadErr := machine.LoadMachine(profile.Name) + mm, loadErr := machine.Load(profile.Name) if !profile.IsValid() || (loadErr != nil || !mm.IsValid()) { invalidProfileDeletionErrs := deleteInvalidProfile(profile) @@ -263,7 +263,7 @@ func deleteInvalidProfile(profile *pkg_config.Profile) []error { } } - pathToMachine := machine.MachinePath(profile.Name, localpath.MiniPath()) + pathToMachine := machine.Path(profile.Name, localpath.MiniPath()) if _, err := os.Stat(pathToMachine); !os.IsNotExist(err) { err := os.RemoveAll(pathToMachine) if err != nil { diff --git a/cmd/minikube/cmd/delete_test.go b/cmd/minikube/cmd/delete_test.go index 29915a394a..89b6555dc0 100644 --- a/cmd/minikube/cmd/delete_test.go +++ b/cmd/minikube/cmd/delete_test.go @@ -117,7 +117,7 @@ func TestDeleteProfile(t *testing.T) { t.Errorf("Profile folder of profile \"%s\" was not deleted", profile.Name) } - pathToMachine := machine.MachinePath(profile.Name, localpath.MiniPath()) + pathToMachine := machine.Path(profile.Name, localpath.MiniPath()) if _, err := os.Stat(pathToMachine); !os.IsNotExist(err) { t.Errorf("Profile folder of profile \"%s\" was not deleted", profile.Name) } diff --git a/pkg/minikube/bootstrapper/kubeadm/kubeadm.go b/pkg/minikube/bootstrapper/kubeadm/kubeadm.go index 727c5870c2..cd06bab9ad 100644 --- a/pkg/minikube/bootstrapper/kubeadm/kubeadm.go +++ b/pkg/minikube/bootstrapper/kubeadm/kubeadm.go @@ -655,7 +655,7 @@ func (k *Bootstrapper) UpdateCluster(cfg config.MachineConfig) error { return errors.Wrap(err, "generating kubelet service") } - glog.Infof("kubelet %s config:\n%s", cfg.KubernetesConfig, kubeletCfg) + glog.Infof("kubelet %s config:\n%+v", kubeletCfg, cfg.KubernetesConfig) stopCmd := exec.Command("/bin/bash", "-c", "pgrep kubelet && sudo systemctl stop kubelet") // stop kubelet to avoid "Text File Busy" error diff --git a/pkg/minikube/machine/machine.go b/pkg/minikube/machine/machine.go index 98299905fb..552d529fa1 100644 --- a/pkg/minikube/machine/machine.go +++ b/pkg/minikube/machine/machine.go @@ -60,15 +60,15 @@ func (h *Machine) IsValid() bool { return true } -// ListMachines return all valid and invalid machines +// List return all valid and invalid machines // If a machine is valid or invalid is determined by the cluster.IsValid function -func ListMachines(miniHome ...string) (validMachines []*Machine, inValidMachines []*Machine, err error) { +func List(miniHome ...string) (validMachines []*Machine, inValidMachines []*Machine, err error) { pDirs, err := machineDirs(miniHome...) if err != nil { return nil, nil, err } for _, n := range pDirs { - p, err := LoadMachine(n) + p, err := Load(n) if err != nil { glog.Infof("%s not valid: %v", n, err) inValidMachines = append(inValidMachines, p) @@ -83,8 +83,8 @@ func ListMachines(miniHome ...string) (validMachines []*Machine, inValidMachines return validMachines, inValidMachines, nil } -// LoadMachine loads a machine or throws an error if the machine could not be loadedG -func LoadMachine(name string) (*Machine, error) { +// Load loads a machine or throws an error if the machine could not be loadedG +func Load(name string) (*Machine, error) { api, err := NewAPIClient() if err != nil { return nil, err @@ -120,8 +120,8 @@ func machineDirs(miniHome ...string) (dirs []string, err error) { return dirs, err } -// MachinePath returns the Minikube machine path of a machine -func MachinePath(machine string, miniHome ...string) string { +// Path returns the Minikube machine path of a machine +func Path(machine string, miniHome ...string) string { miniPath := localpath.MiniPath() if len(miniHome) > 0 { miniPath = miniHome[0] diff --git a/pkg/minikube/machine/machine_test.go b/pkg/minikube/machine/machine_test.go index 380decf7aa..7fc9e4c557 100644 --- a/pkg/minikube/machine/machine_test.go +++ b/pkg/minikube/machine/machine_test.go @@ -51,7 +51,7 @@ func TestListMachines(t *testing.T) { files, _ := ioutil.ReadDir(filepath.Join(localpath.MiniPath(), "machines")) numberOfMachineDirs := len(files) - validMachines, inValidMachines, err := ListMachines() + validMachines, inValidMachines, err := List() if err != nil { t.Error(err) diff --git a/pkg/minikube/cluster/testdata/list-machines/.minikube/machines/p1/config.json b/pkg/minikube/machine/testdata/list-machines/.minikube/machines/p1/config.json similarity index 100% rename from pkg/minikube/cluster/testdata/list-machines/.minikube/machines/p1/config.json rename to pkg/minikube/machine/testdata/list-machines/.minikube/machines/p1/config.json diff --git a/pkg/minikube/cluster/testdata/list-machines/.minikube/machines/p2/config.json b/pkg/minikube/machine/testdata/list-machines/.minikube/machines/p2/config.json similarity index 100% rename from pkg/minikube/cluster/testdata/list-machines/.minikube/machines/p2/config.json rename to pkg/minikube/machine/testdata/list-machines/.minikube/machines/p2/config.json diff --git a/pkg/minikube/cluster/testdata/list-machines/.minikube/machines/p3_empty_config/config.json b/pkg/minikube/machine/testdata/list-machines/.minikube/machines/p3_empty_config/config.json similarity index 100% rename from pkg/minikube/cluster/testdata/list-machines/.minikube/machines/p3_empty_config/config.json rename to pkg/minikube/machine/testdata/list-machines/.minikube/machines/p3_empty_config/config.json diff --git a/pkg/minikube/cluster/testdata/list-machines/.minikube/machines/p4_invalid_machine_config/config.json b/pkg/minikube/machine/testdata/list-machines/.minikube/machines/p4_invalid_machine_config/config.json similarity index 100% rename from pkg/minikube/cluster/testdata/list-machines/.minikube/machines/p4_invalid_machine_config/config.json rename to pkg/minikube/machine/testdata/list-machines/.minikube/machines/p4_invalid_machine_config/config.json diff --git a/pkg/minikube/cluster/testdata/list-machines/.minikube/machines/p5_partial_config/config.json b/pkg/minikube/machine/testdata/list-machines/.minikube/machines/p5_partial_config/config.json similarity index 100% rename from pkg/minikube/cluster/testdata/list-machines/.minikube/machines/p5_partial_config/config.json rename to pkg/minikube/machine/testdata/list-machines/.minikube/machines/p5_partial_config/config.json From d63408ecc08806f5b2ef84effbcfa26ef0e66748 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20F=20Bj=C3=B6rklund?= Date: Wed, 27 Nov 2019 19:05:14 +0100 Subject: [PATCH 27/72] Fix link to libvirt documentation for openSUSE --- site/content/en/docs/Reference/Drivers/includes/kvm2_usage.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site/content/en/docs/Reference/Drivers/includes/kvm2_usage.inc b/site/content/en/docs/Reference/Drivers/includes/kvm2_usage.inc index 9ae9778a6b..e933991fc0 100644 --- a/site/content/en/docs/Reference/Drivers/includes/kvm2_usage.inc +++ b/site/content/en/docs/Reference/Drivers/includes/kvm2_usage.inc @@ -11,7 +11,7 @@ Proper installation of KVM and libvirt is highly specific to each Linux distribu * [Debian](https://wiki.debian.org/KVM#Installation) * [Fedora](https://docs.fedoraproject.org/en-US/quick-docs/getting-started-with-virtualization/) * [Gentoo](https://wiki.gentoo.org/wiki/QEMU) -* [OpenSUSE](https://doc.opensuse.org/documentation/leap/virtualization/html/book.virt/cha.vt.installation.html) +* [OpenSUSE](https://doc.opensuse.org/documentation/leap/virtualization/html/book.virt/cha-vt-installation.html) * [RedHat](https://access.redhat.com/articles/1344173#Q_how-install-virtualization-packages) * [Ubuntu](https://help.ubuntu.com/community/KVM/Installation) From 2cc277af7391dc35814618807e08fd3f5d4518b3 Mon Sep 17 00:00:00 2001 From: Wietse Muizelaar Date: Fri, 29 Nov 2019 20:36:54 +0100 Subject: [PATCH 28/72] Use newer gvisor version The current gvisor version used is quite old, this PR bumps the version to a more recent one. --- pkg/gvisor/enable.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/gvisor/enable.go b/pkg/gvisor/enable.go index b2905574b8..83b391156b 100644 --- a/pkg/gvisor/enable.go +++ b/pkg/gvisor/enable.go @@ -39,7 +39,7 @@ const ( containerdConfigTomlPath = "/etc/containerd/config.toml" storedContainerdConfigTomlPath = "/tmp/config.toml" gvisorContainerdShimURL = "https://github.com/google/gvisor-containerd-shim/releases/download/v0.0.3/containerd-shim-runsc-v1.linux-amd64" - gvisorURL = "https://storage.googleapis.com/gvisor/releases/nightly/2019-01-14/runsc" + gvisorURL = "https://storage.googleapis.com/gvisor/releases/nightly/2019-11-27/runsc" ) // Enable follows these steps for enabling gvisor in minikube: From 4c47ace4dd0e266be065a0b6992b8d598e7cc036 Mon Sep 17 00:00:00 2001 From: Jan Ahrens Date: Sat, 30 Nov 2019 19:49:13 +0100 Subject: [PATCH 29/72] Update audit-policy.md Highlight why the audit-policy.yaml has to be stored in the ssl certs directory. --- site/content/en/docs/Tutorials/audit-policy.md | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/site/content/en/docs/Tutorials/audit-policy.md b/site/content/en/docs/Tutorials/audit-policy.md index b688a53631..56cf6428d2 100644 --- a/site/content/en/docs/Tutorials/audit-policy.md +++ b/site/content/en/docs/Tutorials/audit-policy.md @@ -10,8 +10,7 @@ description: > ## Overview [Auditing](https://kubernetes.io/docs/tasks/debug-application-cluster/audit/) is not enabled in minikube by default. -This tutorial shows how to provide an [Audit Policy](https://kubernetes.io/docs/tasks/debug-application-cluster/audit/#audit-policy) file -to the minikube API server on startup. +This tutorial shows how to provide an [Audit Policy](https://kubernetes.io/docs/tasks/debug-application-cluster/audit/#audit-policy) file to the minikube API server on startup. ## Tutorial @@ -35,8 +34,6 @@ minikube start \ kubectl logs kube-apiserver-minikube -n kube-system | grep audit.k8s.io/v1 ``` -Putting the file into the `~/.minikube/files/` directory triggers the [file sync mechanism](https://minikube.sigs.k8s.io/docs/tasks/sync/) to copy the `audit-policy.yaml` file -from the host onto the minikube node. When the API server container starts I'll mount the `/etc/ssl/certs` directory from the minikube node and can thus read the audit policy file. +The [Audit Policy](https://kubernetes.io/docs/tasks/debug-application-cluster/audit/#audit-policy) used in this tutorial is very minimal and quite verbose. As a next step you might want to finetune the `audit-policy.yaml` file. To get the changes applied you need to stop and start minikube. Restarting minikube triggers the [file sync mechanism](https://minikube.sigs.k8s.io/docs/tasks/sync/) that copies the yaml file onto the minikube node and causes the API server to read the changed policy file. -You most likely want to tune the [Audit Policy](https://kubernetes.io/docs/tasks/debug-application-cluster/audit/#audit-policy) next as the one used in this tutorial is quite verbose. -To use a new file you need to stop and start minikube. +Note: Currently there is no dedicated directory to store the `audit-policy.yaml` file in `~/.minikube/`. Using the `~/.minikube/files/etc/ssl/certs` directory is a workaround! This workaround works like this: By putting the file into a sub-directory of `~/.minikube/files/`, the [file sync mechanism](https://minikube.sigs.k8s.io/docs/tasks/sync/) gets triggered and copies the `audit-policy.yaml` file from the host onto the minikube node. When the API server container gets started by `kubeadm` I'll mount the `/etc/ssl/certs` directory from the minikube node into the container. This is the reason why the `audit-policy.yaml` file has to be stored in the ssl certs directory: It's one of the directories that get mounted from the minikube node into the container. From 29691a67b748dd0b122ff7909624b51e96b19f7e Mon Sep 17 00:00:00 2001 From: Sharif Elgamal Date: Mon, 2 Dec 2019 14:46:31 -0800 Subject: [PATCH 30/72] fix up release notes script --- hack/release_notes.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/hack/release_notes.sh b/hack/release_notes.sh index ca0acc9fc4..a39575ee8c 100755 --- a/hack/release_notes.sh +++ b/hack/release_notes.sh @@ -34,7 +34,10 @@ if ! [[ -x "${DIR}/release-notes" ]]; then install_release_notes_helper fi -"${DIR}/release-notes" kubernetes minikube +git pull git@github.com:kubernetes/minikube master --tags +recent=$(git describe --abbrev=0) + +"${DIR}/release-notes" kubernetes minikube --since $recent echo "Huge thank you for this release towards our contributors: " -git log "$(git describe --abbrev=0)".. --format="%aN" --reverse | sort | uniq | awk '{printf "- %s\n", $0 }' +git log "$recent".. --format="%aN" --reverse | sort | uniq | awk '{printf "- %s\n", $0 }' From 672b9de015b3e4b6a225cd1d834157045dc3f691 Mon Sep 17 00:00:00 2001 From: Guilherme Pellizzetti Date: Tue, 3 Dec 2019 20:42:18 -0300 Subject: [PATCH 31/72] typo: Fix typo in err_map key Change "MACHINE_DOES_NOT_EXST" to "MACHINE_DOES_NOT_EXIST". Please disregard if not valid. --- pkg/minikube/problem/err_map.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/minikube/problem/err_map.go b/pkg/minikube/problem/err_map.go index bad986cdcf..8147788498 100644 --- a/pkg/minikube/problem/err_map.go +++ b/pkg/minikube/problem/err_map.go @@ -400,7 +400,7 @@ var osProblems = map[string]match{ // stateProblems are issues relating to local state var stateProblems = map[string]match{ - "MACHINE_DOES_NOT_EXST": { + "MACHINE_DOES_NOT_EXIST": { Regexp: re(`Error getting state for host: machine does not exist`), Advice: "Run 'minikube delete' to delete the stale VM", Issues: []int{3864}, From 157df4a2f29d0b2643926aeb53ef41356d79f885 Mon Sep 17 00:00:00 2001 From: Anukul Sangwan Date: Mon, 9 Dec 2019 12:26:46 +0530 Subject: [PATCH 32/72] Fix ingress-dns example manifest URL HTML -> Raw YAML --- deploy/addons/ingress-dns/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy/addons/ingress-dns/README.md b/deploy/addons/ingress-dns/README.md index f1a6f919aa..9e49f071d9 100644 --- a/deploy/addons/ingress-dns/README.md +++ b/deploy/addons/ingress-dns/README.md @@ -95,7 +95,7 @@ TODO ### Add the test ingress ```bash -kubectl apply -f https://github.com/kubernetes/minikube/blob/master/deploy/addons/ingress-dns/example/example.yaml +kubectl apply -f https://raw.githubusercontent.com/kubernetes/minikube/master/deploy/addons/ingress-dns/example/example.yaml ``` Note: Minimum Kubernetes version for example ingress is 1.14.7 From 419311a111e1721e8bb778d926b8e71bf765236f Mon Sep 17 00:00:00 2001 From: Laura-Marie Henning Date: Mon, 9 Dec 2019 22:47:34 +0100 Subject: [PATCH 33/72] Add sch_netem kernel module for network emulation Signed-off-by: Laura-Marie Henning --- deploy/iso/minikube-iso/board/coreos/minikube/linux_defconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/deploy/iso/minikube-iso/board/coreos/minikube/linux_defconfig b/deploy/iso/minikube-iso/board/coreos/minikube/linux_defconfig index 5537582e19..ace0239843 100644 --- a/deploy/iso/minikube-iso/board/coreos/minikube/linux_defconfig +++ b/deploy/iso/minikube-iso/board/coreos/minikube/linux_defconfig @@ -268,6 +268,7 @@ CONFIG_BRIDGE_EBT_LOG=m CONFIG_BRIDGE_EBT_NFLOG=m CONFIG_BRIDGE=m CONFIG_NET_SCHED=y +CONFIG_NET_SCH_NETEM=y CONFIG_NET_SCH_INGRESS=m CONFIG_NET_CLS_U32=m CONFIG_NET_CLS_CGROUP=y From df3ee004813e54f7c0b9372f4a4293cb302e0fba Mon Sep 17 00:00:00 2001 From: Thomas Stromberg Date: Mon, 9 Dec 2019 14:13:50 -0800 Subject: [PATCH 34/72] Update dashboard image and pre-cache it again --- deploy/addons/dashboard/dashboard-dp.yaml | 3 ++- pkg/minikube/bootstrapper/images/images.go | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/deploy/addons/dashboard/dashboard-dp.yaml b/deploy/addons/dashboard/dashboard-dp.yaml index 0a8cf44e35..98ac68e359 100644 --- a/deploy/addons/dashboard/dashboard-dp.yaml +++ b/deploy/addons/dashboard/dashboard-dp.yaml @@ -89,7 +89,8 @@ spec: spec: containers: - name: kubernetes-dashboard - image: kubernetesui/dashboard:v2.0.0-beta6 + # WARNING: This must match pkg/minikube/bootstrapper/images/images.go + image: kubernetesui/dashboard:v2.0.0-beta8 ports: - containerPort: 9090 protocol: TCP diff --git a/pkg/minikube/bootstrapper/images/images.go b/pkg/minikube/bootstrapper/images/images.go index 67db6d04fd..a5f0dcaf35 100644 --- a/pkg/minikube/bootstrapper/images/images.go +++ b/pkg/minikube/bootstrapper/images/images.go @@ -144,6 +144,8 @@ func CachedImages(imageRepositoryStr string, kubernetesVersionStr string) []stri } images = append(images, []string{ + // This must match deploy/addons/dashboard/dashboard-dp.yaml + "kubernetesui/dashboard:v2.0.0-beta8", imageRepository + "kube-addon-manager" + ArchTag(false) + "v9.0", minikubeRepository + "storage-provisioner" + ArchTag(false) + "v1.8.1", }...) From 28959711829b81632d77d7c009531a835945e32f Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Mon, 9 Dec 2019 14:30:55 -0800 Subject: [PATCH 35/72] Skip loading image if already cached based on sha --- pkg/minikube/cruntime/containerd.go | 9 ++++++ pkg/minikube/cruntime/crio.go | 14 +++++++++ pkg/minikube/cruntime/cruntime.go | 3 ++ pkg/minikube/cruntime/docker.go | 14 +++++++++ pkg/minikube/machine/cache_images.go | 43 +++++++++++++++++++++------- 5 files changed, 72 insertions(+), 11 deletions(-) diff --git a/pkg/minikube/cruntime/containerd.go b/pkg/minikube/cruntime/containerd.go index 934f65c416..a4dc06c619 100644 --- a/pkg/minikube/cruntime/containerd.go +++ b/pkg/minikube/cruntime/containerd.go @@ -221,6 +221,15 @@ func (r *Containerd) Disable() error { return nil } +// ImageExists checks if an image exists, expected input format +func (r *Containerd) ImageExists(name string, sha string) bool { + c := exec.Command("/bin/bash", "-c", fmt.Sprintf("sudo ctr -n=k8s.io images check | grep %s | grep %s", name, sha)) + if _, err := r.Runner.RunCmd(c); err != nil { + return false + } + return true +} + // LoadImage loads an image into this runtime func (r *Containerd) LoadImage(path string) error { glog.Infof("Loading image: %s", path) diff --git a/pkg/minikube/cruntime/crio.go b/pkg/minikube/cruntime/crio.go index 763e52ac73..b5a98a3fad 100644 --- a/pkg/minikube/cruntime/crio.go +++ b/pkg/minikube/cruntime/crio.go @@ -119,6 +119,20 @@ func (r *CRIO) Disable() error { return nil } +// ImageExists checks if an image exists +func (r *CRIO) ImageExists(name string, sha string) bool { + // expected output looks like [NAME@sha256:SHA] + c := exec.Command("sudo", "podman", "inspect", "--format='{{.Id}}'", name) + rr, err := r.Runner.RunCmd(c) + if err != nil { + return false + } + if !strings.Contains(rr.Output(), sha) { + return false + } + return true +} + // LoadImage loads an image into this runtime func (r *CRIO) LoadImage(path string) error { glog.Infof("Loading image: %s", path) diff --git a/pkg/minikube/cruntime/cruntime.go b/pkg/minikube/cruntime/cruntime.go index 6566a8d8cc..d59499d40e 100644 --- a/pkg/minikube/cruntime/cruntime.go +++ b/pkg/minikube/cruntime/cruntime.go @@ -59,6 +59,9 @@ type Manager interface { // Load an image idempotently into the runtime on a host LoadImage(string) error + // ImageExists takes image name and image sha checks if an it exists + ImageExists(string, string) bool + // ListContainers returns a list of managed by this container runtime ListContainers(string) ([]string, error) // KillContainers removes containers based on ID diff --git a/pkg/minikube/cruntime/docker.go b/pkg/minikube/cruntime/docker.go index 3d80fca459..5ef472d73a 100644 --- a/pkg/minikube/cruntime/docker.go +++ b/pkg/minikube/cruntime/docker.go @@ -102,6 +102,20 @@ func (r *Docker) Disable() error { return nil } +// ImageExists checks if an image exists +func (r *Docker) ImageExists(name string, sha string) bool { + // expected output looks like [SHA_ALGO:SHA] + c := exec.Command("docker", "inspect", "--format='{{.Id}}'", name) + rr, err := r.Runner.RunCmd(c) + if err != nil { + return false + } + if !strings.Contains(rr.Output(), sha) { + return false + } + return true +} + // LoadImage loads an image into this runtime func (r *Docker) LoadImage(path string) error { glog.Infof("Loading image: %s", path) diff --git a/pkg/minikube/machine/cache_images.go b/pkg/minikube/machine/cache_images.go index 126ab12940..e89e9f99b7 100644 --- a/pkg/minikube/machine/cache_images.go +++ b/pkg/minikube/machine/cache_images.go @@ -94,18 +94,16 @@ func CacheImages(images []string, cacheDir string) error { } // LoadImages loads previously cached images into the container runtime -func LoadImages(cc *config.MachineConfig, cmd command.Runner, images []string, cacheDir string) error { +func LoadImages(cc *config.MachineConfig, runner command.Runner, images []string, cacheDir string) error { glog.Infof("LoadImages start: %s", images) defer glog.Infof("LoadImages end") var g errgroup.Group for _, image := range images { image := image g.Go(func() error { - src := filepath.Join(cacheDir, image) - src = sanitizeCacheDir(src) - if err := transferAndLoadImage(cmd, cc.KubernetesConfig, src); err != nil { - glog.Warningf("Failed to load %s: %v", src, err) - return errors.Wrapf(err, "loading image %s", src) + if err := transferAndLoadImage(runner, cc.KubernetesConfig, image, cacheDir); err != nil { + glog.Warningf("Failed to load %s: %v", image, err) + return errors.Wrapf(err, "loading image %s", image) } return nil }) @@ -225,7 +223,34 @@ func getWindowsVolumeNameCmd(d string) (string, error) { } // transferAndLoadImage transfers and loads a single image from the cache -func transferAndLoadImage(cr command.Runner, k8s config.KubernetesConfig, src string) error { +func transferAndLoadImage(cr command.Runner, k8s config.KubernetesConfig, imgName string, cacheDir string) error { + r, err := cruntime.New(cruntime.Config{Type: k8s.ContainerRuntime, Runner: cr}) + if err != nil { + return errors.Wrap(err, "runtime") + } + + ref, err := name.ParseReference(imgName, name.WeakValidation) + if err != nil { + return errors.Wrap(err, "image name reference") + } + + img, err := retrieveImage(ref) + if err != nil { + return errors.Wrap(err, "fetching image") + } + + m, err := img.Manifest() //image hash + if err != nil { + glog.Infof("error retrieving image manifest for %s to check if it already exists: %v", imgName, err) + } else { + hash := m.Config.Digest.Hex + if r.ImageExists(imgName, hash) { + glog.Infof("skipping re-loading image %q because sha %q already exists ", imgName, hash) + return nil + } + } + src := filepath.Join(cacheDir, imgName) + src = sanitizeCacheDir(src) glog.Infof("Loading image from cache: %s", src) filename := filepath.Base(src) if _, err := os.Stat(src); err != nil { @@ -240,10 +265,6 @@ func transferAndLoadImage(cr command.Runner, k8s config.KubernetesConfig, src st return errors.Wrap(err, "transferring cached image") } - r, err := cruntime.New(cruntime.Config{Type: k8s.ContainerRuntime, Runner: cr}) - if err != nil { - return errors.Wrap(err, "runtime") - } loadImageLock.Lock() defer loadImageLock.Unlock() From 35ad8e29154254b58e63dba10b2d01c6dc4a10f5 Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Mon, 9 Dec 2019 14:46:44 -0800 Subject: [PATCH 36/72] make profile name mandatory for config.Load --- cmd/minikube/cmd/config/profile.go | 2 +- cmd/minikube/cmd/config/util.go | 3 ++- cmd/minikube/cmd/config/validations.go | 3 ++- cmd/minikube/cmd/dashboard.go | 4 +++- cmd/minikube/cmd/delete.go | 3 +-- cmd/minikube/cmd/env.go | 2 +- cmd/minikube/cmd/ip.go | 3 ++- cmd/minikube/cmd/kubectl.go | 4 +++- cmd/minikube/cmd/logs.go | 2 +- cmd/minikube/cmd/mount.go | 3 ++- cmd/minikube/cmd/ssh-key.go | 3 ++- cmd/minikube/cmd/ssh.go | 2 +- cmd/minikube/cmd/start.go | 5 +++-- cmd/minikube/cmd/tunnel.go | 5 +++-- pkg/minikube/config/config.go | 9 ++------- pkg/provision/buildroot.go | 2 +- 16 files changed, 30 insertions(+), 25 deletions(-) diff --git a/cmd/minikube/cmd/config/profile.go b/cmd/minikube/cmd/config/profile.go index 3a8051146a..03eb016426 100644 --- a/cmd/minikube/cmd/config/profile.go +++ b/cmd/minikube/cmd/config/profile.go @@ -76,7 +76,7 @@ var ProfileCmd = &cobra.Command{ if err != nil { exit.WithError("Setting profile failed", err) } - cc, err := pkgConfig.Load() + cc, err := pkgConfig.Load(profile) // might err when loading older version of cfg file that doesn't have KeepContext field if err != nil && !os.IsNotExist(err) { out.ErrT(out.Sad, `Error loading profile config: {{.error}}`, out.V{"error": err}) diff --git a/cmd/minikube/cmd/config/util.go b/cmd/minikube/cmd/config/util.go index c48226e40f..56afdcbb4d 100644 --- a/cmd/minikube/cmd/config/util.go +++ b/cmd/minikube/cmd/config/util.go @@ -23,6 +23,7 @@ import ( "strings" "github.com/pkg/errors" + "github.com/spf13/viper" "k8s.io/minikube/pkg/minikube/assets" "k8s.io/minikube/pkg/minikube/cluster" "k8s.io/minikube/pkg/minikube/command" @@ -137,7 +138,7 @@ func EnableOrDisableAddon(name string, val string) error { return nil } - cfg, err := config.Load() + cfg, err := config.Load(viper.GetString(config.MachineProfile)) if err != nil && !os.IsNotExist(err) { exit.WithCodeT(exit.Data, "Unable to load config: {{.error}}", out.V{"error": err}) } diff --git a/cmd/minikube/cmd/config/validations.go b/cmd/minikube/cmd/config/validations.go index 7fb73e759e..4220afb123 100644 --- a/cmd/minikube/cmd/config/validations.go +++ b/cmd/minikube/cmd/config/validations.go @@ -26,6 +26,7 @@ import ( units "github.com/docker/go-units" "github.com/pkg/errors" + "github.com/spf13/viper" "k8s.io/minikube/pkg/minikube/assets" "k8s.io/minikube/pkg/minikube/config" "k8s.io/minikube/pkg/minikube/cruntime" @@ -158,7 +159,7 @@ func IsValidRuntime(name string, runtime string) error { // IsContainerdRuntime is a validator which returns an error if the current runtime is not containerd func IsContainerdRuntime(_, _ string) error { - config, err := config.Load() + config, err := config.Load(viper.GetString(config.MachineProfile)) if err != nil { return fmt.Errorf("config.Load: %v", err) } diff --git a/cmd/minikube/cmd/dashboard.go b/cmd/minikube/cmd/dashboard.go index 17377b879e..f1eaefda34 100644 --- a/cmd/minikube/cmd/dashboard.go +++ b/cmd/minikube/cmd/dashboard.go @@ -32,9 +32,11 @@ import ( "github.com/pkg/browser" "github.com/pkg/errors" "github.com/spf13/cobra" + "github.com/spf13/viper" configcmd "k8s.io/minikube/cmd/minikube/cmd/config" "k8s.io/minikube/pkg/minikube/assets" "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/exit" "k8s.io/minikube/pkg/minikube/machine" @@ -57,7 +59,7 @@ var dashboardCmd = &cobra.Command{ Short: "Access the kubernetes dashboard running within the minikube cluster", Long: `Access the kubernetes dashboard running within the minikube cluster`, Run: func(cmd *cobra.Command, args []string) { - cc, err := pkg_config.Load() + cc, err := pkg_config.Load(viper.GetString(config.MachineProfile)) if err != nil && !os.IsNotExist(err) { exit.WithError("Error loading profile config", err) } diff --git a/cmd/minikube/cmd/delete.go b/cmd/minikube/cmd/delete.go index 54f13720b5..dcb2aefff7 100644 --- a/cmd/minikube/cmd/delete.go +++ b/cmd/minikube/cmd/delete.go @@ -187,8 +187,7 @@ func deleteProfile(profile *pkg_config.Profile) error { return DeletionError{Err: delErr, Errtype: Fatal} } defer api.Close() - - cc, err := pkg_config.Load() + cc, err := pkg_config.Load(profile.Name) if err != nil && !os.IsNotExist(err) { delErr := profileDeletionErr(profile.Name, fmt.Sprintf("error loading profile config: %v", err)) return DeletionError{Err: delErr, Errtype: MissingProfile} diff --git a/cmd/minikube/cmd/env.go b/cmd/minikube/cmd/env.go index df273c4032..01ca87260a 100644 --- a/cmd/minikube/cmd/env.go +++ b/cmd/minikube/cmd/env.go @@ -340,7 +340,7 @@ var dockerEnvCmd = &cobra.Command{ exit.WithError("Error getting client", err) } defer api.Close() - cc, err := config.Load() + cc, err := config.Load(viper.GetString(config.MachineProfile)) if err != nil { exit.WithError("Error getting config", err) } diff --git a/cmd/minikube/cmd/ip.go b/cmd/minikube/cmd/ip.go index 068f3c10d9..5d00182dde 100644 --- a/cmd/minikube/cmd/ip.go +++ b/cmd/minikube/cmd/ip.go @@ -20,6 +20,7 @@ import ( "github.com/docker/machine/libmachine/mcnerror" "github.com/pkg/errors" "github.com/spf13/cobra" + "github.com/spf13/viper" "k8s.io/minikube/pkg/minikube/config" "k8s.io/minikube/pkg/minikube/exit" "k8s.io/minikube/pkg/minikube/machine" @@ -38,7 +39,7 @@ var ipCmd = &cobra.Command{ } defer api.Close() - cc, err := config.Load() + cc, err := config.Load(viper.GetString(config.MachineProfile)) if err != nil { exit.WithError("Error getting config", err) } diff --git a/cmd/minikube/cmd/kubectl.go b/cmd/minikube/cmd/kubectl.go index a1b1cc808f..715e414cfe 100644 --- a/cmd/minikube/cmd/kubectl.go +++ b/cmd/minikube/cmd/kubectl.go @@ -25,6 +25,8 @@ import ( "github.com/golang/glog" "github.com/spf13/cobra" + "github.com/spf13/viper" + "k8s.io/minikube/pkg/minikube/config" pkg_config "k8s.io/minikube/pkg/minikube/config" "k8s.io/minikube/pkg/minikube/constants" "k8s.io/minikube/pkg/minikube/exit" @@ -48,7 +50,7 @@ kubectl get pods --namespace kube-system`, } defer api.Close() - cc, err := pkg_config.Load() + cc, err := pkg_config.Load(viper.GetString(config.MachineProfile)) if err != nil && !os.IsNotExist(err) { out.ErrLn("Error loading profile config: %v", err) } diff --git a/cmd/minikube/cmd/logs.go b/cmd/minikube/cmd/logs.go index 58955ae4f9..60d49cfe92 100644 --- a/cmd/minikube/cmd/logs.go +++ b/cmd/minikube/cmd/logs.go @@ -47,7 +47,7 @@ var logsCmd = &cobra.Command{ Short: "Gets the logs of the running instance, used for debugging minikube, not user code.", Long: `Gets the logs of the running instance, used for debugging minikube, not user code.`, Run: func(cmd *cobra.Command, args []string) { - cfg, err := config.Load() + cfg, err := config.Load(viper.GetString(config.MachineProfile)) if err != nil { exit.WithError("Error getting config", err) } diff --git a/cmd/minikube/cmd/mount.go b/cmd/minikube/cmd/mount.go index d5cdaf418a..4884da27a0 100644 --- a/cmd/minikube/cmd/mount.go +++ b/cmd/minikube/cmd/mount.go @@ -29,6 +29,7 @@ import ( "github.com/golang/glog" "github.com/pkg/errors" "github.com/spf13/cobra" + "github.com/spf13/viper" "k8s.io/minikube/pkg/minikube/cluster" "k8s.io/minikube/pkg/minikube/config" "k8s.io/minikube/pkg/minikube/driver" @@ -102,7 +103,7 @@ var mountCmd = &cobra.Command{ exit.WithError("Error getting client", err) } defer api.Close() - cc, err := config.Load() + cc, err := config.Load(viper.GetString(config.MachineProfile)) if err != nil { exit.WithError("Error getting config", err) } diff --git a/cmd/minikube/cmd/ssh-key.go b/cmd/minikube/cmd/ssh-key.go index 1d5538572a..223703f82d 100644 --- a/cmd/minikube/cmd/ssh-key.go +++ b/cmd/minikube/cmd/ssh-key.go @@ -20,6 +20,7 @@ import ( "path/filepath" "github.com/spf13/cobra" + "github.com/spf13/viper" "k8s.io/minikube/pkg/minikube/config" "k8s.io/minikube/pkg/minikube/exit" "k8s.io/minikube/pkg/minikube/localpath" @@ -32,7 +33,7 @@ var sshKeyCmd = &cobra.Command{ Short: "Retrieve the ssh identity key path of the specified cluster", Long: "Retrieve the ssh identity key path of the specified cluster.", Run: func(cmd *cobra.Command, args []string) { - cc, err := config.Load() + cc, err := config.Load(viper.GetString(config.MachineProfile)) if err != nil { exit.WithError("Getting machine config failed", err) } diff --git a/cmd/minikube/cmd/ssh.go b/cmd/minikube/cmd/ssh.go index 5634363510..340cbd6010 100644 --- a/cmd/minikube/cmd/ssh.go +++ b/cmd/minikube/cmd/ssh.go @@ -42,7 +42,7 @@ var sshCmd = &cobra.Command{ exit.WithError("Error getting client", err) } defer api.Close() - cc, err := config.Load() + cc, err := config.Load(viper.GetString(config.MachineProfile)) if err != nil { exit.WithError("Error getting config", err) } diff --git a/cmd/minikube/cmd/start.go b/cmd/minikube/cmd/start.go index e859691834..7767dc5fda 100644 --- a/cmd/minikube/cmd/start.go +++ b/cmd/minikube/cmd/start.go @@ -51,6 +51,7 @@ import ( "k8s.io/minikube/pkg/minikube/bootstrapper/kubeadm" "k8s.io/minikube/pkg/minikube/cluster" "k8s.io/minikube/pkg/minikube/command" + "k8s.io/minikube/pkg/minikube/config" cfg "k8s.io/minikube/pkg/minikube/config" "k8s.io/minikube/pkg/minikube/constants" "k8s.io/minikube/pkg/minikube/cruntime" @@ -287,7 +288,7 @@ func runStart(cmd *cobra.Command, args []string) { registryMirror = viper.GetStringSlice("registry_mirror") } - existing, err := cfg.Load() + existing, err := cfg.Load(viper.GetString(config.MachineProfile)) if err != nil && !os.IsNotExist(err) { exit.WithCodeT(exit.Data, "Unable to load config: {{.error}}", out.V{"error": err}) } @@ -729,7 +730,7 @@ func validateUser(drvName string) { if !useForce { os.Exit(exit.Permissions) } - _, err = cfg.Load() + _, err = cfg.Load(viper.GetString(config.MachineProfile)) if err == nil || !os.IsNotExist(err) { out.T(out.Tip, "Tip: To remove this root owned cluster, run: sudo {{.cmd}} delete", out.V{"cmd": minikubeCmd()}) } diff --git a/cmd/minikube/cmd/tunnel.go b/cmd/minikube/cmd/tunnel.go index f892047bb4..daa421dce9 100644 --- a/cmd/minikube/cmd/tunnel.go +++ b/cmd/minikube/cmd/tunnel.go @@ -24,6 +24,7 @@ import ( "github.com/golang/glog" "github.com/spf13/cobra" + "github.com/spf13/viper" "k8s.io/minikube/pkg/minikube/config" "k8s.io/minikube/pkg/minikube/exit" "k8s.io/minikube/pkg/minikube/machine" @@ -76,11 +77,11 @@ var tunnelCmd = &cobra.Command{ cancel() }() - cc, err := config.Load() + cfg, err := config.Load(viper.GetString(config.MachineProfile)) if err != nil { exit.WithError("Error getting config", err) } - done, err := manager.StartTunnel(ctx, cc.Name, api, config.DefaultLoader, clientset.CoreV1()) + done, err := manager.StartTunnel(ctx, cfg.Name, api, config.DefaultLoader, clientset.CoreV1()) if err != nil { exit.WithError("error starting tunnel", err) } diff --git a/pkg/minikube/config/config.go b/pkg/minikube/config/config.go index 7e53d82554..db4efc1f2c 100644 --- a/pkg/minikube/config/config.go +++ b/pkg/minikube/config/config.go @@ -24,7 +24,6 @@ import ( "io/ioutil" "os" - "github.com/spf13/viper" "k8s.io/minikube/pkg/minikube/localpath" ) @@ -124,12 +123,8 @@ func encode(w io.Writer, m MinikubeConfig) error { } // Load loads the kubernetes and machine config for the current machine -func Load(profile ...string) (*MachineConfig, error) { - machine := viper.GetString(MachineProfile) - if len(profile) > 0 { - machine = profile[0] - } - return DefaultLoader.LoadConfigFromFile(machine) +func Load(profile string) (*MachineConfig, error) { + return DefaultLoader.LoadConfigFromFile(profile) } // Loader loads the kubernetes and machine config based on the machine profile name diff --git a/pkg/provision/buildroot.go b/pkg/provision/buildroot.go index acd10f703e..ef2f5a2358 100644 --- a/pkg/provision/buildroot.go +++ b/pkg/provision/buildroot.go @@ -314,7 +314,7 @@ func configureAuth(p *BuildrootProvisioner) error { return err } - config, err := config.Load() + config, err := config.Load(p.Driver.GetMachineName()) if err != nil { return errors.Wrap(err, "getting cluster config") } From 60346821d684ecada2d77b599754333c15c79335 Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Mon, 9 Dec 2019 14:51:10 -0800 Subject: [PATCH 37/72] move machine path to localpath package --- cmd/minikube/cmd/delete.go | 2 +- cmd/minikube/cmd/delete_test.go | 3 +-- pkg/minikube/localpath/localpath.go | 11 ++++++++++- pkg/minikube/machine/machine.go | 9 --------- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/cmd/minikube/cmd/delete.go b/cmd/minikube/cmd/delete.go index dcb2aefff7..5efe7e2ee3 100644 --- a/cmd/minikube/cmd/delete.go +++ b/cmd/minikube/cmd/delete.go @@ -262,7 +262,7 @@ func deleteInvalidProfile(profile *pkg_config.Profile) []error { } } - pathToMachine := machine.Path(profile.Name, localpath.MiniPath()) + pathToMachine := localpath.MachinePath(profile.Name, localpath.MiniPath()) if _, err := os.Stat(pathToMachine); !os.IsNotExist(err) { err := os.RemoveAll(pathToMachine) if err != nil { diff --git a/cmd/minikube/cmd/delete_test.go b/cmd/minikube/cmd/delete_test.go index 89b6555dc0..fddfc201da 100644 --- a/cmd/minikube/cmd/delete_test.go +++ b/cmd/minikube/cmd/delete_test.go @@ -28,7 +28,6 @@ import ( "k8s.io/minikube/pkg/minikube/config" "k8s.io/minikube/pkg/minikube/localpath" - "k8s.io/minikube/pkg/minikube/machine" ) // except returns a list of strings, minus the excluded ones @@ -117,7 +116,7 @@ func TestDeleteProfile(t *testing.T) { t.Errorf("Profile folder of profile \"%s\" was not deleted", profile.Name) } - pathToMachine := machine.Path(profile.Name, localpath.MiniPath()) + pathToMachine := localpath.MachinePath(profile.Name, localpath.MiniPath()) if _, err := os.Stat(pathToMachine); !os.IsNotExist(err) { t.Errorf("Profile folder of profile \"%s\" was not deleted", profile.Name) } diff --git a/pkg/minikube/localpath/localpath.go b/pkg/minikube/localpath/localpath.go index 8b6ae0a16e..820d21f1d3 100644 --- a/pkg/minikube/localpath/localpath.go +++ b/pkg/minikube/localpath/localpath.go @@ -23,7 +23,7 @@ import ( "k8s.io/client-go/util/homedir" ) -// MinikubeHome is the name of the minikube home directory variable. +// MinikubeHome is the name of the minikube home directory environment variable. const MinikubeHome = "MINIKUBE_HOME" // ConfigFile is the path of the config file @@ -46,3 +46,12 @@ func MakeMiniPath(fileName ...string) string { args = append(args, fileName...) return filepath.Join(args...) } + +// MachinePath returns the Minikube machine path of a machine +func MachinePath(machine string, miniHome ...string) string { + miniPath := MiniPath() + if len(miniHome) > 0 { + miniPath = miniHome[0] + } + return filepath.Join(miniPath, "machines", machine) +} diff --git a/pkg/minikube/machine/machine.go b/pkg/minikube/machine/machine.go index 552d529fa1..cd29bb715f 100644 --- a/pkg/minikube/machine/machine.go +++ b/pkg/minikube/machine/machine.go @@ -119,12 +119,3 @@ func machineDirs(miniHome ...string) (dirs []string, err error) { } return dirs, err } - -// Path returns the Minikube machine path of a machine -func Path(machine string, miniHome ...string) string { - miniPath := localpath.MiniPath() - if len(miniHome) > 0 { - miniPath = miniHome[0] - } - return filepath.Join(miniPath, "machines", machine) -} From fc09dd4814aca401127f8d5c60481509cd97e598 Mon Sep 17 00:00:00 2001 From: Karuppiah Natarajan Date: Tue, 10 Dec 2019 19:56:25 +0530 Subject: [PATCH 38/72] Update default Kubernetes version to v1.17.0 Signed-off-by: Karuppiah Natarajan --- pkg/minikube/bootstrapper/kubeadm/kubeadm_test.go | 8 ++++---- pkg/minikube/constants/constants.go | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/minikube/bootstrapper/kubeadm/kubeadm_test.go b/pkg/minikube/bootstrapper/kubeadm/kubeadm_test.go index 0afbb9ffb7..a387d71931 100644 --- a/pkg/minikube/bootstrapper/kubeadm/kubeadm_test.go +++ b/pkg/minikube/bootstrapper/kubeadm/kubeadm_test.go @@ -66,7 +66,7 @@ Wants=crio.service [Service] ExecStart= -ExecStart=/var/lib/minikube/binaries/v1.17.0-rc.1/kubelet --authorization-mode=Webhook --bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --cgroup-driver=cgroupfs --client-ca-file=/var/lib/minikube/certs/ca.crt --cluster-dns=10.96.0.10 --cluster-domain=cluster.local --config=/var/lib/kubelet/config.yaml --container-runtime=remote --container-runtime-endpoint=/var/run/crio/crio.sock --fail-swap-on=false --hostname-override=minikube --image-service-endpoint=/var/run/crio/crio.sock --kubeconfig=/etc/kubernetes/kubelet.conf --node-ip=192.168.1.100 --pod-manifest-path=/etc/kubernetes/manifests --runtime-request-timeout=15m +ExecStart=/var/lib/minikube/binaries/v1.17.0/kubelet --authorization-mode=Webhook --bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --cgroup-driver=cgroupfs --client-ca-file=/var/lib/minikube/certs/ca.crt --cluster-dns=10.96.0.10 --cluster-domain=cluster.local --config=/var/lib/kubelet/config.yaml --container-runtime=remote --container-runtime-endpoint=/var/run/crio/crio.sock --fail-swap-on=false --hostname-override=minikube --image-service-endpoint=/var/run/crio/crio.sock --kubeconfig=/etc/kubernetes/kubelet.conf --node-ip=192.168.1.100 --pod-manifest-path=/etc/kubernetes/manifests --runtime-request-timeout=15m [Install] `, @@ -84,7 +84,7 @@ Wants=containerd.service [Service] ExecStart= -ExecStart=/var/lib/minikube/binaries/v1.17.0-rc.1/kubelet --authorization-mode=Webhook --bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --cgroup-driver=cgroupfs --client-ca-file=/var/lib/minikube/certs/ca.crt --cluster-dns=10.96.0.10 --cluster-domain=cluster.local --config=/var/lib/kubelet/config.yaml --container-runtime=remote --container-runtime-endpoint=unix:///run/containerd/containerd.sock --fail-swap-on=false --hostname-override=minikube --image-service-endpoint=unix:///run/containerd/containerd.sock --kubeconfig=/etc/kubernetes/kubelet.conf --node-ip=192.168.1.100 --pod-manifest-path=/etc/kubernetes/manifests --runtime-request-timeout=15m +ExecStart=/var/lib/minikube/binaries/v1.17.0/kubelet --authorization-mode=Webhook --bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --cgroup-driver=cgroupfs --client-ca-file=/var/lib/minikube/certs/ca.crt --cluster-dns=10.96.0.10 --cluster-domain=cluster.local --config=/var/lib/kubelet/config.yaml --container-runtime=remote --container-runtime-endpoint=unix:///run/containerd/containerd.sock --fail-swap-on=false --hostname-override=minikube --image-service-endpoint=unix:///run/containerd/containerd.sock --kubeconfig=/etc/kubernetes/kubelet.conf --node-ip=192.168.1.100 --pod-manifest-path=/etc/kubernetes/manifests --runtime-request-timeout=15m [Install] `, @@ -109,7 +109,7 @@ Wants=containerd.service [Service] ExecStart= -ExecStart=/var/lib/minikube/binaries/v1.17.0-rc.1/kubelet --authorization-mode=Webhook --bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --cgroup-driver=cgroupfs --client-ca-file=/var/lib/minikube/certs/ca.crt --cluster-dns=10.96.0.10 --cluster-domain=cluster.local --config=/var/lib/kubelet/config.yaml --container-runtime=remote --container-runtime-endpoint=unix:///run/containerd/containerd.sock --fail-swap-on=false --hostname-override=minikube --image-service-endpoint=unix:///run/containerd/containerd.sock --kubeconfig=/etc/kubernetes/kubelet.conf --node-ip=192.168.1.200 --pod-manifest-path=/etc/kubernetes/manifests --runtime-request-timeout=15m +ExecStart=/var/lib/minikube/binaries/v1.17.0/kubelet --authorization-mode=Webhook --bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --cgroup-driver=cgroupfs --client-ca-file=/var/lib/minikube/certs/ca.crt --cluster-dns=10.96.0.10 --cluster-domain=cluster.local --config=/var/lib/kubelet/config.yaml --container-runtime=remote --container-runtime-endpoint=unix:///run/containerd/containerd.sock --fail-swap-on=false --hostname-override=minikube --image-service-endpoint=unix:///run/containerd/containerd.sock --kubeconfig=/etc/kubernetes/kubelet.conf --node-ip=192.168.1.200 --pod-manifest-path=/etc/kubernetes/manifests --runtime-request-timeout=15m [Install] `, @@ -128,7 +128,7 @@ Wants=docker.socket [Service] ExecStart= -ExecStart=/var/lib/minikube/binaries/v1.17.0-rc.1/kubelet --authorization-mode=Webhook --bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --cgroup-driver=cgroupfs --client-ca-file=/var/lib/minikube/certs/ca.crt --cluster-dns=10.96.0.10 --cluster-domain=cluster.local --config=/var/lib/kubelet/config.yaml --container-runtime=docker --fail-swap-on=false --hostname-override=minikube --kubeconfig=/etc/kubernetes/kubelet.conf --node-ip=192.168.1.100 --pod-infra-container-image=docker-proxy-image.io/google_containers/pause:3.1 --pod-manifest-path=/etc/kubernetes/manifests +ExecStart=/var/lib/minikube/binaries/v1.17.0/kubelet --authorization-mode=Webhook --bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --cgroup-driver=cgroupfs --client-ca-file=/var/lib/minikube/certs/ca.crt --cluster-dns=10.96.0.10 --cluster-domain=cluster.local --config=/var/lib/kubelet/config.yaml --container-runtime=docker --fail-swap-on=false --hostname-override=minikube --kubeconfig=/etc/kubernetes/kubelet.conf --node-ip=192.168.1.100 --pod-infra-container-image=docker-proxy-image.io/google_containers/pause:3.1 --pod-manifest-path=/etc/kubernetes/manifests [Install] `, diff --git a/pkg/minikube/constants/constants.go b/pkg/minikube/constants/constants.go index 1c8e915f16..9d328de7f3 100644 --- a/pkg/minikube/constants/constants.go +++ b/pkg/minikube/constants/constants.go @@ -65,10 +65,10 @@ var DefaultISOURL = fmt.Sprintf("https://storage.googleapis.com/%s/minikube-%s.i var DefaultISOSHAURL = DefaultISOURL + SHASuffix // DefaultKubernetesVersion is the default kubernetes version -var DefaultKubernetesVersion = "v1.17.0-rc.1" +var DefaultKubernetesVersion = "v1.17.0" // NewestKubernetesVersion is the newest Kubernetes version to test against -var NewestKubernetesVersion = "v1.17.0-rc.1" +var NewestKubernetesVersion = "v1.17.0" // OldestKubernetesVersion is the oldest Kubernetes version to test against var OldestKubernetesVersion = "v1.11.10" From 8b7aaba627b4f386a4cfc10e7e21e7a6ea0b8d52 Mon Sep 17 00:00:00 2001 From: Thomas Stromberg Date: Tue, 10 Dec 2019 07:58:19 -0800 Subject: [PATCH 39/72] Sync correct Kubernetes versions from kubeadm constants --- cmd/minikube/cmd/start.go | 4 +- pkg/minikube/bootstrapper/bootstrapper.go | 7 +- pkg/minikube/bootstrapper/images/images.go | 223 ++++--------------- pkg/minikube/bootstrapper/images/repo.go | 36 +++ pkg/minikube/bootstrapper/kubeadm/kubeadm.go | 7 +- pkg/minikube/cruntime/containerd.go | 2 +- pkg/minikube/cruntime/cri.go | 2 +- pkg/minikube/machine/cache_images.go | 5 +- test/integration/a_serial_test.go | 6 +- 9 files changed, 106 insertions(+), 186 deletions(-) create mode 100644 pkg/minikube/bootstrapper/images/repo.go diff --git a/cmd/minikube/cmd/start.go b/cmd/minikube/cmd/start.go index bba5f0fd5f..949e29d1f0 100644 --- a/cmd/minikube/cmd/start.go +++ b/cmd/minikube/cmd/start.go @@ -673,7 +673,7 @@ func selectImageRepository(mirrorCountry string, k8sVersion string) (bool, strin } checkRepository := func(repo string) error { - pauseImage := images.PauseImage(repo, k8sVersion) + pauseImage := images.Pause(repo) ref, err := name.ParseReference(pauseImage, name.WeakValidation) if err != nil { return err @@ -1108,7 +1108,7 @@ func tryRegistry(r command.Runner) { repo := viper.GetString(imageRepository) if repo == "" { - repo = images.DefaultImageRepo + repo = images.DefaultKubernetesRepo } opts = append(opts, fmt.Sprintf("https://%s/", repo)) diff --git a/pkg/minikube/bootstrapper/bootstrapper.go b/pkg/minikube/bootstrapper/bootstrapper.go index 119466da0a..81018a09ea 100644 --- a/pkg/minikube/bootstrapper/bootstrapper.go +++ b/pkg/minikube/bootstrapper/bootstrapper.go @@ -64,12 +64,11 @@ func GetCachedBinaryList(bootstrapper string) []string { } // GetCachedImageList returns the list of images for a version -func GetCachedImageList(imageRepository string, version string, bootstrapper string) []string { +func GetCachedImageList(imageRepository string, version string, bootstrapper string) ([]string, error) { switch bootstrapper { case BootstrapperTypeKubeadm: - images := images.CachedImages(imageRepository, version) - return images + return images.Kubeadm(imageRepository, version) default: - return []string{} + return []string{}, nil } } diff --git a/pkg/minikube/bootstrapper/images/images.go b/pkg/minikube/bootstrapper/images/images.go index a5f0dcaf35..247d41fb52 100644 --- a/pkg/minikube/bootstrapper/images/images.go +++ b/pkg/minikube/bootstrapper/images/images.go @@ -1,5 +1,5 @@ /* -Copyright 2016 The Kubernetes Authors All rights reserved. +Copyright 2019 The Kubernetes Authors All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,188 +14,63 @@ See the License for the specific language governing permissions and limitations under the License. */ +// Package images implements helpers for getting image names package images import ( + "path" "runtime" - "strings" - - "github.com/blang/semver" - "github.com/golang/glog" - minikubeVersion "k8s.io/minikube/pkg/version" ) -const ( - // DefaultImageRepo is the default repository for images - DefaultImageRepo = "k8s.gcr.io" - // DefaultMinikubeRepo is the default repository for minikube - DefaultMinikubeRepo = "gcr.io/k8s-minikube" -) - -// getImageRepositories returns either the k8s image registry on GCR or a mirror if specified -func getImageRepository(imageRepository string) string { - if imageRepository == "" { - imageRepository = DefaultImageRepo - } - if !strings.HasSuffix(imageRepository, "/") { - imageRepository += "/" - } - - return imageRepository -} - -// getMinikubeRepository returns either the minikube image registry on GCR or a mirror if specified -func getMinikubeRepository(imageRepository string) string { - minikubeRepository := imageRepository - if minikubeRepository == "" { - minikubeRepository = DefaultMinikubeRepo - } - if !strings.HasSuffix(minikubeRepository, "/") { - minikubeRepository += "/" - } - - return minikubeRepository -} - -// CachedImages gets the images to cache for kubeadm for a version -func CachedImages(imageRepositoryStr string, kubernetesVersionStr string) []string { - imageRepository := getImageRepository(imageRepositoryStr) - minikubeRepository := getMinikubeRepository(imageRepositoryStr) - - v1_16plus := semver.MustParseRange(">=1.16.0") - v1_14plus := semver.MustParseRange(">=1.14.0 <1.16.0") - v1_13 := semver.MustParseRange(">=1.13.0 <1.14.0") - v1_12 := semver.MustParseRange(">=1.12.0 <1.13.0") - v1_11 := semver.MustParseRange(">=1.11.0 <1.12.0") - v1_12plus := semver.MustParseRange(">=1.12.0") - - kubernetesVersion, err := semver.Make(strings.TrimPrefix(kubernetesVersionStr, minikubeVersion.VersionPrefix)) - if err != nil { - glog.Errorln("Error parsing version semver: ", err) - } - - var images []string - if v1_12plus(kubernetesVersion) { - images = append(images, []string{ - imageRepository + "kube-proxy" + ArchTag(false) + kubernetesVersionStr, - imageRepository + "kube-scheduler" + ArchTag(false) + kubernetesVersionStr, - imageRepository + "kube-controller-manager" + ArchTag(false) + kubernetesVersionStr, - imageRepository + "kube-apiserver" + ArchTag(false) + kubernetesVersionStr, - }...) - } else { - images = append(images, []string{ - imageRepository + "kube-proxy" + ArchTag(true) + kubernetesVersionStr, - imageRepository + "kube-scheduler" + ArchTag(true) + kubernetesVersionStr, - imageRepository + "kube-controller-manager" + ArchTag(true) + kubernetesVersionStr, - imageRepository + "kube-apiserver" + ArchTag(true) + kubernetesVersionStr, - }...) - } - - podInfraContainerImage := PauseImage(imageRepository, kubernetesVersionStr) - if v1_16plus(kubernetesVersion) { - images = append(images, []string{ - podInfraContainerImage, - imageRepository + "k8s-dns-kube-dns" + ArchTag(true) + "1.14.13", - imageRepository + "k8s-dns-dnsmasq-nanny" + ArchTag(true) + "1.14.13", - imageRepository + "k8s-dns-sidecar" + ArchTag(true) + "1.14.13", - imageRepository + "etcd" + ArchTag(false) + "3.3.15-0", - imageRepository + "coredns" + ArchTag(false) + "1.6.2", - }...) - - } else if v1_14plus(kubernetesVersion) { - images = append(images, []string{ - podInfraContainerImage, - imageRepository + "k8s-dns-kube-dns" + ArchTag(true) + "1.14.13", - imageRepository + "k8s-dns-dnsmasq-nanny" + ArchTag(true) + "1.14.13", - imageRepository + "k8s-dns-sidecar" + ArchTag(true) + "1.14.13", - imageRepository + "etcd" + ArchTag(false) + "3.3.10", - imageRepository + "coredns" + ArchTag(false) + "1.3.1", - }...) - - } else if v1_13(kubernetesVersion) { - images = append(images, []string{ - podInfraContainerImage, - imageRepository + "k8s-dns-kube-dns" + ArchTag(true) + "1.14.8", - imageRepository + "k8s-dns-dnsmasq-nanny" + ArchTag(true) + "1.14.8", - imageRepository + "k8s-dns-sidecar" + ArchTag(true) + "1.14.8", - imageRepository + "etcd" + ArchTag(false) + "3.2.24", - imageRepository + "coredns:1.2.6", - }...) - - } else if v1_12(kubernetesVersion) { - images = append(images, []string{ - podInfraContainerImage, - imageRepository + "k8s-dns-kube-dns" + ArchTag(true) + "1.14.8", - imageRepository + "k8s-dns-dnsmasq-nanny" + ArchTag(true) + "1.14.8", - imageRepository + "k8s-dns-sidecar" + ArchTag(true) + "1.14.8", - imageRepository + "etcd" + ArchTag(false) + "3.2.24", - imageRepository + "coredns:1.2.2", - }...) - - } else if v1_11(kubernetesVersion) { - images = append(images, []string{ - podInfraContainerImage, - imageRepository + "k8s-dns-kube-dns" + ArchTag(true) + "1.14.8", - imageRepository + "k8s-dns-dnsmasq-nanny" + ArchTag(true) + "1.14.8", - imageRepository + "k8s-dns-sidecar" + ArchTag(true) + "1.14.8", - imageRepository + "etcd" + ArchTag(true) + "3.2.18", - imageRepository + "coredns:1.1.3", - }...) - } - - images = append(images, []string{ - // This must match deploy/addons/dashboard/dashboard-dp.yaml - "kubernetesui/dashboard:v2.0.0-beta8", - imageRepository + "kube-addon-manager" + ArchTag(false) + "v9.0", - minikubeRepository + "storage-provisioner" + ArchTag(false) + "v1.8.1", - }...) - - return images -} - -// PauseImage returns the image name for pause image (for pod infra) -func PauseImage(imageRepositoryStr string, kubernetesVersionStr string) string { - imageRepository := getImageRepository(imageRepositoryStr) - - v1_16plus := semver.MustParseRange(">=1.16.0") - v1_14plus := semver.MustParseRange(">=1.14.0 <1.16.0") - v1_13 := semver.MustParseRange(">=1.13.0 <1.14.0") - v1_12 := semver.MustParseRange(">=1.12.0 <1.13.0") - v1_11 := semver.MustParseRange(">=1.11.0 <1.12.0") - - kubernetesVersion, err := semver.Make(strings.TrimPrefix(kubernetesVersionStr, minikubeVersion.VersionPrefix)) - if err != nil { - glog.Errorln("Error parsing version semver: ", err) - } - - var podInfraContainerImage string - switch { - case v1_16plus(kubernetesVersion): - podInfraContainerImage = imageRepository + "pause:3.1" - - case v1_14plus(kubernetesVersion): - podInfraContainerImage = imageRepository + "pause:3.1" - - case v1_13(kubernetesVersion): - podInfraContainerImage = imageRepository + "pause" + ArchTag(false) + "3.1" - - case v1_12(kubernetesVersion): - podInfraContainerImage = imageRepository + "pause:3.1" - - case v1_11(kubernetesVersion): - podInfraContainerImage = imageRepository + "pause" + ArchTag(false) + "3.1" - - default: - podInfraContainerImage = imageRepository + "pause" + ArchTag(false) + "3.0" - } - - return podInfraContainerImage -} - -// ArchTag returns the archtag for images +// ArchTag returns a CPU architecture suffix for images func ArchTag(hasTag bool) string { if runtime.GOARCH == "amd64" && !hasTag { return ":" } return "-" + runtime.GOARCH + ":" } + +// Auxiliary returns images that are helpful for running minikube +func Auxiliary(mirror string) []string { + return []string{ + addonManager(mirror), + storageProvisioner(mirror), + dashboardFrontend(mirror), + dashboardMetrics(mirror), + } +} + +// Pause returns the image name for the pause image +func Pause(mirror string) string { + // Should match `PauseVersion` in: + // https://github.com/kubernetes/kubernetes/blob/master/cmd/kubeadm/app/constants/constants.go + return path.Join(KubernetesRepo(mirror), "pause"+ArchTag(false)+"3.1") +} + +// storageProvisioner returns the minikube storage provisioner image +func storageProvisioner(mirror string) string { + return path.Join(minikubeRepo(mirror), "storage-provisioner"+ArchTag(false)+"v1.8.1") +} + +// addonManager returns the Kubernetes addon manager image +func addonManager(mirror string) string { + return path.Join(KubernetesRepo(mirror), "kube-addon-manager"+ArchTag(false)+"v9.0.2") +} + +// dashboardFrontend returns the image used for the dashboard frontend +func dashboardFrontend(repo string) string { + if repo == "" { + repo = "kubernetesui" + } + // See 'kubernetes-dashboard' in deploy/addons/dashboard/dashboard-dp.yaml + return path.Join(repo, "dashboard:v2.0.0-beta8") +} + +// dashboardMetrics returns the image used for the dashboard metrics scraper +func dashboardMetrics(repo string) string { + if repo == "" { + repo = "kubernetesui" + } + // See 'dashboard-metrics-scraper' in deploy/addons/dashboard/dashboard-dp.yaml + return path.Join(repo, "metrics-scraper:v1.0.2") +} diff --git a/pkg/minikube/bootstrapper/images/repo.go b/pkg/minikube/bootstrapper/images/repo.go new file mode 100644 index 0000000000..02cf44345b --- /dev/null +++ b/pkg/minikube/bootstrapper/images/repo.go @@ -0,0 +1,36 @@ +/* +Copyright 2019 The Kubernetes Authors All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package images + +// DefaultKubernetesRepo is the default Kubernetes repository +const DefaultKubernetesRepo = "k8s.gcr.io" + +// KubernetesRepo returns the official Kubernetes repository, or an alternate +func KubernetesRepo(mirror string) string { + if mirror != "" { + return mirror + } + return DefaultKubernetesRepo +} + +// minikubeRepo returns the official minikube repository, or an alternate +func minikubeRepo(mirror string) string { + if mirror != "" { + return mirror + } + return "gcr.io/k8s-minikube" +} diff --git a/pkg/minikube/bootstrapper/kubeadm/kubeadm.go b/pkg/minikube/bootstrapper/kubeadm/kubeadm.go index 2643ec9d3c..52122891b7 100644 --- a/pkg/minikube/bootstrapper/kubeadm/kubeadm.go +++ b/pkg/minikube/bootstrapper/kubeadm/kubeadm.go @@ -596,7 +596,7 @@ func NewKubeletConfig(k8s config.KubernetesConfig, r cruntime.Manager) ([]byte, extraOpts["node-ip"] = k8s.NodeIP } - pauseImage := images.PauseImage(k8s.ImageRepository, k8s.KubernetesVersion) + pauseImage := images.Pause(k8s.ImageRepository) if _, ok := extraOpts["pod-infra-container-image"]; !ok && k8s.ImageRepository != "" && pauseImage != "" && k8s.ContainerRuntime != remoteContainerRuntime { extraOpts["pod-infra-container-image"] = pauseImage } @@ -630,7 +630,10 @@ func NewKubeletConfig(k8s config.KubernetesConfig, r cruntime.Manager) ([]byte, // UpdateCluster updates the cluster func (k *Bootstrapper) UpdateCluster(cfg config.KubernetesConfig) error { - images := images.CachedImages(cfg.ImageRepository, cfg.KubernetesVersion) + images, err := images.Kubeadm(cfg.ImageRepository, cfg.KubernetesVersion) + if err != nil { + return errors.Wrap(err, "kubeadm images") + } if cfg.ShouldLoadCachedImages { if err := machine.LoadImages(k.c, images, constants.ImageCacheDir); err != nil { out.FailureT("Unable to load cached images: {{.error}}", out.V{"error": err}) diff --git a/pkg/minikube/cruntime/containerd.go b/pkg/minikube/cruntime/containerd.go index 934f65c416..99a2daa797 100644 --- a/pkg/minikube/cruntime/containerd.go +++ b/pkg/minikube/cruntime/containerd.go @@ -175,7 +175,7 @@ func generateContainerdConfig(cr CommandRunner, imageRepository string, k8sVersi if err != nil { return err } - pauseImage := images.PauseImage(imageRepository, k8sVersion) + pauseImage := images.Pause(imageRepository) opts := struct{ PodInfraContainerImage string }{PodInfraContainerImage: pauseImage} var b bytes.Buffer if err := t.Execute(&b, opts); err != nil { diff --git a/pkg/minikube/cruntime/cri.go b/pkg/minikube/cruntime/cri.go index 173e652301..92c9a6af1f 100644 --- a/pkg/minikube/cruntime/cri.go +++ b/pkg/minikube/cruntime/cri.go @@ -413,7 +413,7 @@ func generateCRIOConfig(cr CommandRunner, imageRepository string, k8sVersion str if err != nil { return err } - pauseImage := images.PauseImage(imageRepository, k8sVersion) + pauseImage := images.Pause(imageRepository) opts := struct{ PodInfraContainerImage string }{PodInfraContainerImage: pauseImage} var b bytes.Buffer if err := t.Execute(&b, opts); err != nil { diff --git a/pkg/minikube/machine/cache_images.go b/pkg/minikube/machine/cache_images.go index 587a27f816..b0c4c6aeb7 100644 --- a/pkg/minikube/machine/cache_images.go +++ b/pkg/minikube/machine/cache_images.go @@ -55,7 +55,10 @@ var loadImageLock sync.Mutex // CacheImagesForBootstrapper will cache images for a bootstrapper func CacheImagesForBootstrapper(imageRepository string, version string, clusterBootstrapper string) error { - images := bootstrapper.GetCachedImageList(imageRepository, version, clusterBootstrapper) + images, err := bootstrapper.GetCachedImageList(imageRepository, version, clusterBootstrapper) + if err != nil { + return errors.Wrap(err, "cached images list") + } if err := CacheImages(images, constants.ImageCacheDir); err != nil { return errors.Wrapf(err, "Caching images for %s", clusterBootstrapper) diff --git a/test/integration/a_serial_test.go b/test/integration/a_serial_test.go index b71b3e877c..0efa3e7e57 100644 --- a/test/integration/a_serial_test.go +++ b/test/integration/a_serial_test.go @@ -67,7 +67,11 @@ func TestDownloadOnly(t *testing.T) { t.Errorf("%s failed: %v", args, err) } - imgs := images.CachedImages("", v) + imgs, err := images.Kubeadm("", v) + if err != nil { + t.Errorf("kubeadm images: %v", v) + } + for _, img := range imgs { img = strings.Replace(img, ":", "_", 1) // for example kube-scheduler:v1.15.2 --> kube-scheduler_v1.15.2 fp := filepath.Join(localpath.MiniPath(), "cache", "images", img) From 14b805d494358797a6db1ecdd061e17ec0b74e64 Mon Sep 17 00:00:00 2001 From: Thomas Stromberg Date: Tue, 10 Dec 2019 08:17:08 -0800 Subject: [PATCH 40/72] Remove unused vars --- cmd/minikube/cmd/start.go | 4 ++-- pkg/minikube/cruntime/containerd.go | 4 ++-- pkg/minikube/cruntime/cri.go | 2 +- pkg/minikube/cruntime/crio.go | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cmd/minikube/cmd/start.go b/cmd/minikube/cmd/start.go index 949e29d1f0..d29d81e9aa 100644 --- a/cmd/minikube/cmd/start.go +++ b/cmd/minikube/cmd/start.go @@ -645,7 +645,7 @@ func validateDriver(name string, existing *cfg.MachineConfig) { exit.WithCodeT(exit.Config, "Exiting.") } -func selectImageRepository(mirrorCountry string, k8sVersion string) (bool, string, error) { +func selectImageRepository(mirrorCountry string) (bool, string, error) { var tryCountries []string var fallback string glog.Infof("selecting image repository for country %s ...", mirrorCountry) @@ -866,7 +866,7 @@ func generateCfgFromFlags(cmd *cobra.Command, k8sVersion string, drvName string) repository := viper.GetString(imageRepository) mirrorCountry := strings.ToLower(viper.GetString(imageMirrorCountry)) if strings.ToLower(repository) == "auto" || mirrorCountry != "" { - found, autoSelectedRepository, err := selectImageRepository(mirrorCountry, k8sVersion) + found, autoSelectedRepository, err := selectImageRepository(mirrorCountry) if err != nil { exit.WithError("Failed to check main repository and mirrors for images for images", err) } diff --git a/pkg/minikube/cruntime/containerd.go b/pkg/minikube/cruntime/containerd.go index 99a2daa797..e1c7fdda73 100644 --- a/pkg/minikube/cruntime/containerd.go +++ b/pkg/minikube/cruntime/containerd.go @@ -169,7 +169,7 @@ func (r *Containerd) Available() error { } // generateContainerdConfig sets up /etc/containerd/config.toml -func generateContainerdConfig(cr CommandRunner, imageRepository string, k8sVersion string) error { +func generateContainerdConfig(cr CommandRunner, imageRepository string) error { cPath := containerdConfigFile t, err := template.New("containerd.config.toml").Parse(containerdConfigTemplate) if err != nil { @@ -198,7 +198,7 @@ func (r *Containerd) Enable(disOthers bool) error { if err := populateCRIConfig(r.Runner, r.SocketPath()); err != nil { return err } - if err := generateContainerdConfig(r.Runner, r.ImageRepository, r.KubernetesVersion); err != nil { + if err := generateContainerdConfig(r.Runner, r.ImageRepository); err != nil { return err } if err := enableIPForwarding(r.Runner); err != nil { diff --git a/pkg/minikube/cruntime/cri.go b/pkg/minikube/cruntime/cri.go index 92c9a6af1f..f053c74404 100644 --- a/pkg/minikube/cruntime/cri.go +++ b/pkg/minikube/cruntime/cri.go @@ -407,7 +407,7 @@ image-endpoint: unix://{{.Socket}} } // generateCRIOConfig sets up /etc/crio/crio.conf -func generateCRIOConfig(cr CommandRunner, imageRepository string, k8sVersion string) error { +func generateCRIOConfig(cr CommandRunner, imageRepository string) error { cPath := crioConfigFile t, err := template.New("crio.conf").Parse(crioConfigTemplate) if err != nil { diff --git a/pkg/minikube/cruntime/crio.go b/pkg/minikube/cruntime/crio.go index 763e52ac73..585ad33684 100644 --- a/pkg/minikube/cruntime/crio.go +++ b/pkg/minikube/cruntime/crio.go @@ -98,7 +98,7 @@ func (r *CRIO) Enable(disOthers bool) error { if err := populateCRIConfig(r.Runner, r.SocketPath()); err != nil { return err } - if err := generateCRIOConfig(r.Runner, r.ImageRepository, r.KubernetesVersion); err != nil { + if err := generateCRIOConfig(r.Runner, r.ImageRepository); err != nil { return err } if err := enableIPForwarding(r.Runner); err != nil { From 650c26309c3cd4a02cded640694c178a013779c1 Mon Sep 17 00:00:00 2001 From: Thomas Stromberg Date: Tue, 10 Dec 2019 09:29:45 -0800 Subject: [PATCH 41/72] Add missing files --- .../bootstrapper/images/images_test.go | 49 +++++++ pkg/minikube/bootstrapper/images/kubeadm.go | 95 ++++++++++++ .../bootstrapper/images/kubeadm_test.go | 135 ++++++++++++++++++ 3 files changed, 279 insertions(+) create mode 100644 pkg/minikube/bootstrapper/images/images_test.go create mode 100644 pkg/minikube/bootstrapper/images/kubeadm.go create mode 100644 pkg/minikube/bootstrapper/images/kubeadm_test.go diff --git a/pkg/minikube/bootstrapper/images/images_test.go b/pkg/minikube/bootstrapper/images/images_test.go new file mode 100644 index 0000000000..31a487e4c4 --- /dev/null +++ b/pkg/minikube/bootstrapper/images/images_test.go @@ -0,0 +1,49 @@ +/* +Copyright 2019 The Kubernetes Authors All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package images + +import ( + "testing" + + "github.com/google/go-cmp/cmp" +) + +func TestAuxiliary(t *testing.T) { + want := []string{ + "k8s.gcr.io/kube-addon-manager:v9.0.2", + "gcr.io/k8s-minikube/storage-provisioner:v1.8.1", + "kubernetesui/dashboard:v2.0.0-beta8", + "kubernetesui/metrics-scraper:v1.0.2", + } + got := Auxiliary("") + if diff := cmp.Diff(want, got); diff != "" { + t.Errorf("images mismatch (-want +got):\n%s", diff) + } +} + +func TestAuxiliaryMirror(t *testing.T) { + want := []string{ + "test.mirror/kube-addon-manager:v9.0.2", + "test.mirror/storage-provisioner:v1.8.1", + "test.mirror/dashboard:v2.0.0-beta8", + "test.mirror/metrics-scraper:v1.0.2", + } + got := Auxiliary("test.mirror") + if diff := cmp.Diff(want, got); diff != "" { + t.Errorf("images mismatch (-want +got):\n%s", diff) + } +} diff --git a/pkg/minikube/bootstrapper/images/kubeadm.go b/pkg/minikube/bootstrapper/images/kubeadm.go new file mode 100644 index 0000000000..5072f4a5c1 --- /dev/null +++ b/pkg/minikube/bootstrapper/images/kubeadm.go @@ -0,0 +1,95 @@ +/* +Copyright 2019 The Kubernetes Authors All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package images + +import ( + "fmt" + "path" + "strings" + + "github.com/blang/semver" + "github.com/pkg/errors" +) + +// Kubeadm returns a list of images necessary to bootstrap kubeadm +func Kubeadm(mirror string, version string) ([]string, error) { + v, err := semver.Make(strings.TrimPrefix(version, "v")) + if err != nil { + return nil, errors.Wrap(err, "semver") + } + + imgs := []string{ + componentImage("kube-proxy", v, mirror), + componentImage("kube-scheduler", v, mirror), + componentImage("kube-controller-manager", v, mirror), + componentImage("kube-apiserver", v, mirror), + coreDNS(v, mirror), + etcd(v, mirror), + Pause(mirror), + } + imgs = append(imgs, Auxiliary(mirror)...) + return imgs, nil +} + +// componentImage returns a Kubernetes component image to pull +func componentImage(name string, v semver.Version, mirror string) string { + hasTag := false + ancient := semver.MustParseRange("<1.12.0") + if ancient(v) { + hasTag = true + } + + return fmt.Sprintf("%sv%s", path.Join(KubernetesRepo(mirror), name+ArchTag(hasTag)), v) +} + +// coreDNS returns the images used for CoreDNS +func coreDNS(v semver.Version, mirror string) string { + // Should match `CoreDNSVersion` in + // https://github.com/kubernetes/kubernetes/blob/master/cmd/kubeadm/app/constants/constants.go + cv := "1.6.5" + switch v.Minor { + case 16: + cv = "1.6.2" + case 15, 14: + cv = "1.3.1" + case 13: + cv = "1.2.6" + case 12: + cv = "1.2.2" + case 11: + cv = "1.1.3" + } + return path.Join(KubernetesRepo(mirror), "coredns"+ArchTag(false)+cv) +} + +// etcd returns the image used for etcd +func etcd(v semver.Version, mirror string) string { + // Should match `DefaultEtcdVersion` in: + // https://github.com/kubernetes/kubernetes/blob/master/cmd/kubeadm/app/constants/constants.go + ev := "3.4.3-0" + switch v.Minor { + case 16: + ev = "3.3.15-0" + case 14, 15: + ev = "3.3.10" + case 12, 13: + ev = "3.2.24" + case 11: + ev = "3.2.18" + } + return path.Join(KubernetesRepo(mirror), "etcd"+ArchTag(false)+ev) +} diff --git a/pkg/minikube/bootstrapper/images/kubeadm_test.go b/pkg/minikube/bootstrapper/images/kubeadm_test.go new file mode 100644 index 0000000000..a5bfe2bd7b --- /dev/null +++ b/pkg/minikube/bootstrapper/images/kubeadm_test.go @@ -0,0 +1,135 @@ +/* +Copyright 2019 The Kubernetes Authors All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package images + +import ( + "sort" + "testing" + + "github.com/google/go-cmp/cmp" +) + +func TestKubeadmImages(t *testing.T) { + tests := []struct { + version string + mirror string + want []string + }{ + {"v1.17.0", "", []string{ + "k8s.gcr.io/kube-proxy:v1.17.0", + "k8s.gcr.io/kube-scheduler:v1.17.0", + "k8s.gcr.io/kube-controller-manager:v1.17.0", + "k8s.gcr.io/kube-apiserver:v1.17.0", + "k8s.gcr.io/coredns:1.6.5", + "k8s.gcr.io/etcd:3.4.3-0", + "k8s.gcr.io/pause:3.1", + "k8s.gcr.io/kube-addon-manager:v9.0.2", + "gcr.io/k8s-minikube/storage-provisioner:v1.8.1", + "kubernetesui/dashboard:v2.0.0-beta8", + "kubernetesui/metrics-scraper:v1.0.2", + }}, + {"v1.16.1", "mirror.k8s.io", []string{ + "mirror.k8s.io/kube-proxy:v1.16.1", + "mirror.k8s.io/kube-scheduler:v1.16.1", + "mirror.k8s.io/kube-controller-manager:v1.16.1", + "mirror.k8s.io/kube-apiserver:v1.16.1", + "mirror.k8s.io/coredns:1.6.2", + "mirror.k8s.io/etcd:3.3.15-0", + "mirror.k8s.io/pause:3.1", + "mirror.k8s.io/kube-addon-manager:v9.0.2", + "mirror.k8s.io/storage-provisioner:v1.8.1", + "mirror.k8s.io/dashboard:v2.0.0-beta8", + "mirror.k8s.io/metrics-scraper:v1.0.2", + }}, + {"v1.15.0", "", []string{ + "k8s.gcr.io/kube-proxy:v1.15.0", + "k8s.gcr.io/kube-scheduler:v1.15.0", + "k8s.gcr.io/kube-controller-manager:v1.15.0", + "k8s.gcr.io/kube-apiserver:v1.15.0", + "k8s.gcr.io/coredns:1.3.1", + "k8s.gcr.io/etcd:3.3.10", + "k8s.gcr.io/pause:3.1", + "k8s.gcr.io/kube-addon-manager:v9.0.2", + "gcr.io/k8s-minikube/storage-provisioner:v1.8.1", + "kubernetesui/dashboard:v2.0.0-beta8", + "kubernetesui/metrics-scraper:v1.0.2", + }}, + {"v1.14.0", "", []string{ + "k8s.gcr.io/kube-proxy:v1.14.0", + "k8s.gcr.io/kube-scheduler:v1.14.0", + "k8s.gcr.io/kube-controller-manager:v1.14.0", + "k8s.gcr.io/kube-apiserver:v1.14.0", + "k8s.gcr.io/coredns:1.3.1", + "k8s.gcr.io/etcd:3.3.10", + "k8s.gcr.io/pause:3.1", + "k8s.gcr.io/kube-addon-manager:v9.0.2", + "gcr.io/k8s-minikube/storage-provisioner:v1.8.1", + "kubernetesui/dashboard:v2.0.0-beta8", + "kubernetesui/metrics-scraper:v1.0.2", + }}, + {"v1.13.0", "", []string{ + "k8s.gcr.io/kube-proxy:v1.13.0", + "k8s.gcr.io/kube-scheduler:v1.13.0", + "k8s.gcr.io/kube-controller-manager:v1.13.0", + "k8s.gcr.io/kube-apiserver:v1.13.0", + "k8s.gcr.io/coredns:1.2.6", + "k8s.gcr.io/etcd:3.2.24", + "k8s.gcr.io/pause:3.1", + "k8s.gcr.io/kube-addon-manager:v9.0.2", + "gcr.io/k8s-minikube/storage-provisioner:v1.8.1", + "kubernetesui/dashboard:v2.0.0-beta8", + "kubernetesui/metrics-scraper:v1.0.2", + }}, + {"v1.12.0", "", []string{ + "k8s.gcr.io/kube-proxy:v1.12.0", + "k8s.gcr.io/kube-scheduler:v1.12.0", + "k8s.gcr.io/kube-controller-manager:v1.12.0", + "k8s.gcr.io/kube-apiserver:v1.12.0", + "k8s.gcr.io/coredns:1.2.2", + "k8s.gcr.io/etcd:3.2.24", + "k8s.gcr.io/pause:3.1", + "k8s.gcr.io/kube-addon-manager:v9.0.2", + "gcr.io/k8s-minikube/storage-provisioner:v1.8.1", + "kubernetesui/dashboard:v2.0.0-beta8", + "kubernetesui/metrics-scraper:v1.0.2", + }}, + {"v1.11.0", "", []string{ + "k8s.gcr.io/kube-proxy-amd64:v1.11.0", + "k8s.gcr.io/kube-scheduler-amd64:v1.11.0", + "k8s.gcr.io/kube-controller-manager-amd64:v1.11.0", + "k8s.gcr.io/kube-apiserver-amd64:v1.11.0", + "k8s.gcr.io/coredns:1.1.3", + "k8s.gcr.io/etcd:3.2.18", + "k8s.gcr.io/pause:3.1", + "k8s.gcr.io/kube-addon-manager:v9.0.2", + "gcr.io/k8s-minikube/storage-provisioner:v1.8.1", + "kubernetesui/dashboard:v2.0.0-beta8", + "kubernetesui/metrics-scraper:v1.0.2", + }}, + } + for _, tc := range tests { + got, err := Kubeadm(tc.mirror, tc.version) + if err != nil { + t.Fatalf("unexpected err: %v", err) + } + sort.Strings(got) + sort.Strings(tc.want) + if diff := cmp.Diff(tc.want, got); diff != "" { + t.Errorf("%s images mismatch (-want +got):\n%s", tc.version, diff) + } + } +} From b7176b91fd3a997e7952bde99df8fa5bab838023 Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Tue, 10 Dec 2019 10:29:59 -0800 Subject: [PATCH 42/72] Use a faster way to get image sha --- pkg/minikube/machine/cache_images.go | 45 +++++++++++++++------------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/pkg/minikube/machine/cache_images.go b/pkg/minikube/machine/cache_images.go index e89e9f99b7..d6f9bd54a2 100644 --- a/pkg/minikube/machine/cache_images.go +++ b/pkg/minikube/machine/cache_images.go @@ -98,9 +98,33 @@ func LoadImages(cc *config.MachineConfig, runner command.Runner, images []string glog.Infof("LoadImages start: %s", images) defer glog.Infof("LoadImages end") var g errgroup.Group + cr, err := cruntime.New(cruntime.Config{Type: cc.ContainerRuntime, Runner: runner}) + if err != nil { + return errors.Wrap(err, "runtime") + } + for _, image := range images { image := image g.Go(func() error { + ref, err := name.ParseReference(image, name.WeakValidation) + if err != nil { + return errors.Wrap(err, "image name reference") + } + + img, err := retrieveImage(ref) + if err != nil { + return errors.Wrap(err, "fetching image") + } + cf, _ := img.ConfigName() + hash := cf.Hex + if err != nil { + glog.Infof("error retrieving image manifest for %s to check if it already exists: %v", image, err) + } else { + if cr.ImageExists(image, hash) { + glog.Infof("skipping re-loading image %q because sha %q already exists ", image, hash) + return nil + } + } if err := transferAndLoadImage(runner, cc.KubernetesConfig, image, cacheDir); err != nil { glog.Warningf("Failed to load %s: %v", image, err) return errors.Wrapf(err, "loading image %s", image) @@ -228,27 +252,6 @@ func transferAndLoadImage(cr command.Runner, k8s config.KubernetesConfig, imgNam if err != nil { return errors.Wrap(err, "runtime") } - - ref, err := name.ParseReference(imgName, name.WeakValidation) - if err != nil { - return errors.Wrap(err, "image name reference") - } - - img, err := retrieveImage(ref) - if err != nil { - return errors.Wrap(err, "fetching image") - } - - m, err := img.Manifest() //image hash - if err != nil { - glog.Infof("error retrieving image manifest for %s to check if it already exists: %v", imgName, err) - } else { - hash := m.Config.Digest.Hex - if r.ImageExists(imgName, hash) { - glog.Infof("skipping re-loading image %q because sha %q already exists ", imgName, hash) - return nil - } - } src := filepath.Join(cacheDir, imgName) src = sanitizeCacheDir(src) glog.Infof("Loading image from cache: %s", src) From 7b8cfe167c247be026930734bdfd016f7625a91f Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Tue, 10 Dec 2019 11:23:02 -0800 Subject: [PATCH 43/72] lint --- pkg/minikube/machine/cache_images.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/pkg/minikube/machine/cache_images.go b/pkg/minikube/machine/cache_images.go index d6f9bd54a2..ba7cb1fb79 100644 --- a/pkg/minikube/machine/cache_images.go +++ b/pkg/minikube/machine/cache_images.go @@ -115,15 +115,13 @@ func LoadImages(cc *config.MachineConfig, runner command.Runner, images []string if err != nil { return errors.Wrap(err, "fetching image") } - cf, _ := img.ConfigName() + cf, err := img.ConfigName() hash := cf.Hex if err != nil { glog.Infof("error retrieving image manifest for %s to check if it already exists: %v", image, err) - } else { - if cr.ImageExists(image, hash) { - glog.Infof("skipping re-loading image %q because sha %q already exists ", image, hash) - return nil - } + } else if cr.ImageExists(image, hash) { + glog.Infof("skipping re-loading image %q because sha %q already exists ", image, hash) + return nil } if err := transferAndLoadImage(runner, cc.KubernetesConfig, image, cacheDir); err != nil { glog.Warningf("Failed to load %s: %v", image, err) From b49425d76826d8c1000411c4596a12cc68ba80bb Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Tue, 10 Dec 2019 12:15:20 -0800 Subject: [PATCH 44/72] fix integration test logic for cache --- test/integration/functional_test.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/test/integration/functional_test.go b/test/integration/functional_test.go index f7f5207522..cdda2dd55d 100644 --- a/test/integration/functional_test.go +++ b/test/integration/functional_test.go @@ -343,13 +343,12 @@ func validateCacheCmd(ctx context.Context, t *testing.T, profile string) { }) t.Run("verify cache inside node", func(t *testing.T) { - rr, err := Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "docker", "images")) + rr, err := Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "sudo", "crictl", "images")) if err != nil { t.Errorf("failed to get docker images through ssh %v", err) } - - if !strings.Contains(rr.Output(), "busybox:1.28.4-glibc") { - t.Errorf("expected busybox:1.28.4-glibc to be loaded by docker inside minikube node. but got %s", rr.Output()) + if !strings.Contains(rr.Output(), "1.28.4-glibc") { + t.Errorf("expected '1.28.4-glibc' to be in the output: %s", rr.Output()) } }) From 32e0732e152f307e536f909d055052896a3c02e7 Mon Sep 17 00:00:00 2001 From: Thomas Stromberg Date: Tue, 10 Dec 2019 14:02:12 -0800 Subject: [PATCH 45/72] Add integration test --- pkg/minikube/bootstrapper/images/images.go | 2 +- pkg/minikube/bootstrapper/images/kubeadm.go | 14 +++-- .../bootstrapper/images/kubeadm_test.go | 36 ++++++------- test/integration/docker_test.go | 2 +- test/integration/start_stop_delete_test.go | 51 +++++++++++++++---- 5 files changed, 71 insertions(+), 34 deletions(-) diff --git a/pkg/minikube/bootstrapper/images/images.go b/pkg/minikube/bootstrapper/images/images.go index 247d41fb52..1d84dda09f 100644 --- a/pkg/minikube/bootstrapper/images/images.go +++ b/pkg/minikube/bootstrapper/images/images.go @@ -40,7 +40,7 @@ func Auxiliary(mirror string) []string { } } -// Pause returns the image name for the pause image +// Pause returns the image name for thoß… pause image func Pause(mirror string) string { // Should match `PauseVersion` in: // https://github.com/kubernetes/kubernetes/blob/master/cmd/kubeadm/app/constants/constants.go diff --git a/pkg/minikube/bootstrapper/images/kubeadm.go b/pkg/minikube/bootstrapper/images/kubeadm.go index 5072f4a5c1..7f1071a3f3 100644 --- a/pkg/minikube/bootstrapper/images/kubeadm.go +++ b/pkg/minikube/bootstrapper/images/kubeadm.go @@ -47,13 +47,13 @@ func Kubeadm(mirror string, version string) ([]string, error) { // componentImage returns a Kubernetes component image to pull func componentImage(name string, v semver.Version, mirror string) string { - hasTag := false + needsArchSuffix := false ancient := semver.MustParseRange("<1.12.0") if ancient(v) { - hasTag = true + needsArchSuffix = true } - return fmt.Sprintf("%sv%s", path.Join(KubernetesRepo(mirror), name+ArchTag(hasTag)), v) + return fmt.Sprintf("%sv%s", path.Join(KubernetesRepo(mirror), name+ArchTag(needsArchSuffix)), v) } // coreDNS returns the images used for CoreDNS @@ -78,6 +78,12 @@ func coreDNS(v semver.Version, mirror string) string { // etcd returns the image used for etcd func etcd(v semver.Version, mirror string) string { + needsArchSuffix := false + ancient := semver.MustParseRange("<1.12.0") + if ancient(v) { + needsArchSuffix = true + } + // Should match `DefaultEtcdVersion` in: // https://github.com/kubernetes/kubernetes/blob/master/cmd/kubeadm/app/constants/constants.go ev := "3.4.3-0" @@ -91,5 +97,5 @@ func etcd(v semver.Version, mirror string) string { case 11: ev = "3.2.18" } - return path.Join(KubernetesRepo(mirror), "etcd"+ArchTag(false)+ev) + return path.Join(KubernetesRepo(mirror), "etcd"+ArchTag(needsArchSuffix)+ev) } diff --git a/pkg/minikube/bootstrapper/images/kubeadm_test.go b/pkg/minikube/bootstrapper/images/kubeadm_test.go index a5bfe2bd7b..ccbb0b1e83 100644 --- a/pkg/minikube/bootstrapper/images/kubeadm_test.go +++ b/pkg/minikube/bootstrapper/images/kubeadm_test.go @@ -39,8 +39,8 @@ func TestKubeadmImages(t *testing.T) { "k8s.gcr.io/pause:3.1", "k8s.gcr.io/kube-addon-manager:v9.0.2", "gcr.io/k8s-minikube/storage-provisioner:v1.8.1", - "kubernetesui/dashboard:v2.0.0-beta8", - "kubernetesui/metrics-scraper:v1.0.2", + "docker.io/kubernetesui/dashboard:v2.0.0-beta8", + "docker.io/kubernetesui/metrics-scraper:v1.0.2", }}, {"v1.16.1", "mirror.k8s.io", []string{ "mirror.k8s.io/kube-proxy:v1.16.1", @@ -65,8 +65,8 @@ func TestKubeadmImages(t *testing.T) { "k8s.gcr.io/pause:3.1", "k8s.gcr.io/kube-addon-manager:v9.0.2", "gcr.io/k8s-minikube/storage-provisioner:v1.8.1", - "kubernetesui/dashboard:v2.0.0-beta8", - "kubernetesui/metrics-scraper:v1.0.2", + "docker.io/kubernetesui/dashboard:v2.0.0-beta8", + "docker.io/kubernetesui/metrics-scraper:v1.0.2", }}, {"v1.14.0", "", []string{ "k8s.gcr.io/kube-proxy:v1.14.0", @@ -78,8 +78,8 @@ func TestKubeadmImages(t *testing.T) { "k8s.gcr.io/pause:3.1", "k8s.gcr.io/kube-addon-manager:v9.0.2", "gcr.io/k8s-minikube/storage-provisioner:v1.8.1", - "kubernetesui/dashboard:v2.0.0-beta8", - "kubernetesui/metrics-scraper:v1.0.2", + "docker.io/kubernetesui/dashboard:v2.0.0-beta8", + "docker.io/kubernetesui/metrics-scraper:v1.0.2", }}, {"v1.13.0", "", []string{ "k8s.gcr.io/kube-proxy:v1.13.0", @@ -91,8 +91,8 @@ func TestKubeadmImages(t *testing.T) { "k8s.gcr.io/pause:3.1", "k8s.gcr.io/kube-addon-manager:v9.0.2", "gcr.io/k8s-minikube/storage-provisioner:v1.8.1", - "kubernetesui/dashboard:v2.0.0-beta8", - "kubernetesui/metrics-scraper:v1.0.2", + "docker.io/kubernetesui/dashboard:v2.0.0-beta8", + "docker.io/kubernetesui/metrics-scraper:v1.0.2", }}, {"v1.12.0", "", []string{ "k8s.gcr.io/kube-proxy:v1.12.0", @@ -104,21 +104,21 @@ func TestKubeadmImages(t *testing.T) { "k8s.gcr.io/pause:3.1", "k8s.gcr.io/kube-addon-manager:v9.0.2", "gcr.io/k8s-minikube/storage-provisioner:v1.8.1", - "kubernetesui/dashboard:v2.0.0-beta8", - "kubernetesui/metrics-scraper:v1.0.2", + "docker.io/kubernetesui/dashboard:v2.0.0-beta8", + "docker.io/kubernetesui/metrics-scraper:v1.0.2", }}, - {"v1.11.0", "", []string{ - "k8s.gcr.io/kube-proxy-amd64:v1.11.0", - "k8s.gcr.io/kube-scheduler-amd64:v1.11.0", - "k8s.gcr.io/kube-controller-manager-amd64:v1.11.0", - "k8s.gcr.io/kube-apiserver-amd64:v1.11.0", + {"v1.11.10", "", []string{ + "k8s.gcr.io/kube-proxy-amd64:v1.11.10", + "k8s.gcr.io/kube-scheduler-amd64:v1.11.10", + "k8s.gcr.io/kube-controller-manager-amd64:v1.11.10", + "k8s.gcr.io/kube-apiserver-amd64:v1.11.10", "k8s.gcr.io/coredns:1.1.3", - "k8s.gcr.io/etcd:3.2.18", + "k8s.gcr.io/etcd-amd64:3.2.18", "k8s.gcr.io/pause:3.1", "k8s.gcr.io/kube-addon-manager:v9.0.2", "gcr.io/k8s-minikube/storage-provisioner:v1.8.1", - "kubernetesui/dashboard:v2.0.0-beta8", - "kubernetesui/metrics-scraper:v1.0.2", + "docker.io/kubernetesui/dashboard:v2.0.0-beta8", + "docker.io/kubernetesui/metrics-scraper:v1.0.2", }}, } for _, tc := range tests { diff --git a/test/integration/docker_test.go b/test/integration/docker_test.go index 7acb0f9dcc..6ed9f76202 100644 --- a/test/integration/docker_test.go +++ b/test/integration/docker_test.go @@ -38,7 +38,7 @@ func TestDockerFlags(t *testing.T) { defer CleanupWithLogs(t, profile, cancel) // Use the most verbose logging for the simplest test. If it fails, something is very wrong. - args := append([]string{"start", "-p", profile, "--wait=false", "--docker-env=FOO=BAR", "--docker-env=BAZ=BAT", "--docker-opt=debug", "--docker-opt=icc=true", "--alsologtostderr", "-v=5"}, StartArgs()...) + args := append([]string{"start", "-p", profile, "--cache-images=false", "--wait=false", "--docker-env=FOO=BAR", "--docker-env=BAZ=BAT", "--docker-opt=debug", "--docker-opt=icc=true", "--alsologtostderr", "-v=5"}, StartArgs()...) rr, err := Run(t, exec.CommandContext(ctx, Target(), args...)) if err != nil { t.Errorf("%s failed: %v", rr.Args, err) diff --git a/test/integration/start_stop_delete_test.go b/test/integration/start_stop_delete_test.go index 52ac7a4202..49d1b9ee9d 100644 --- a/test/integration/start_stop_delete_test.go +++ b/test/integration/start_stop_delete_test.go @@ -20,15 +20,19 @@ package integration import ( "context" + "encoding/json" "fmt" "os/exec" "path/filepath" + "sort" "strconv" "strings" "testing" "time" "github.com/docker/machine/libmachine/state" + "github.com/google/go-cmp/cmp" + "k8s.io/minikube/pkg/minikube/bootstrapper/images" "k8s.io/minikube/pkg/minikube/constants" ) @@ -37,12 +41,11 @@ func TestStartStop(t *testing.T) { t.Run("group", func(t *testing.T) { tests := []struct { - name string - args []string + name string + version string + args []string }{ - {"docker", []string{ - "--cache-images=false", - fmt.Sprintf("--kubernetes-version=%s", constants.OldestKubernetesVersion), + {"old-docker", constants.OldestKubernetesVersion, []string{ // 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", @@ -51,21 +54,20 @@ func TestStartStop(t *testing.T) { "--keep-context=false", "--container-runtime=docker", }}, - {"cni", []string{ + {"newest-cni", constants.NewestKubernetesVersion, []string{ "--feature-gates", "ServerSideApply=true", "--network-plugin=cni", "--extra-config=kubelet.network-plugin=cni", "--extra-config=kubeadm.pod-network-cidr=192.168.111.111/16", - fmt.Sprintf("--kubernetes-version=%s", constants.NewestKubernetesVersion), }}, - {"containerd", []string{ + {"containerd", constants.DefaultKubernetesVersion, []string{ "--container-runtime=containerd", "--docker-opt", "containerd=/var/run/containerd/containerd.sock", "--apiserver-port=8444", }}, - {"crio", []string{ + {"crio", "v1.15.0", []string{ "--container-runtime=crio", "--disable-driver-mounts", "--extra-config=kubeadm.ignore-preflight-errors=SystemVerification", @@ -88,6 +90,7 @@ func TestStartStop(t *testing.T) { startArgs := append([]string{"start", "-p", profile, "--alsologtostderr", "-v=3", "--wait=true"}, tc.args...) startArgs = append(startArgs, StartArgs()...) + startArgs = append(startArgs, fmt.Sprintf("--kubernetes-version=%s", tc.version)) rr, err := Run(t, exec.CommandContext(ctx, Target(), startArgs...)) if err != nil { // Fatal so that we may collect logs before stop/delete steps @@ -144,6 +147,34 @@ func TestStartStop(t *testing.T) { t.Fatalf("%s failed: %v", rr.Args, err) } + // Make sure that kubeadm did not need to pull in additional images + rr, err = Run(t, exec.CommandContext(ctx, Target(), "ssh", "-p", profile, "sudo crictl images -o json")) + if err != nil { + t.Errorf("%s failed: %v", rr.Args, err) + } + jv := map[string][]struct { + Tags []string `json:"repoTags"` + }{} + err = json.Unmarshal(rr.Stdout.Bytes(), &jv) + gotImages := []string{} + for _, img := range jv["images"] { + for _, i := range img.Tags { + // Ignore non-Kubernetes images + if !strings.Contains(i, "ingress") && !strings.Contains(i, "busybox") { + gotImages = append(gotImages, i) + } + } + } + want, err := images.Kubeadm("", tc.version) + if err != nil { + t.Errorf("kubeadm images: %v", tc.version) + } + sort.Strings(want) + sort.Strings(gotImages) + if diff := cmp.Diff(want, gotImages); diff != "" { + t.Errorf("%s images mismatch (-want +got):\n%s", tc.version, diff) + } + if strings.Contains(tc.name, "cni") { t.Logf("WARNING: cni mode requires additional setup before pods can schedule :(") } else if _, err := PodWait(ctx, t, profile, "default", "integration-test=busybox", 2*time.Minute); err != nil { @@ -155,7 +186,7 @@ func TestStartStop(t *testing.T) { t.Errorf("status = %q; want = %q", got, state.Running) } - if !*cleanup { + if *cleanup { // Normally handled by cleanuprofile, but not fatal there rr, err = Run(t, exec.CommandContext(ctx, Target(), "delete", "-p", profile)) if err != nil { From a1ddd283fe874793e69c046b03db02e3a99ff484 Mon Sep 17 00:00:00 2001 From: Thomas Stromberg Date: Tue, 10 Dec 2019 14:28:40 -0800 Subject: [PATCH 46/72] Check errors, remove docker.io prefix used by crio --- .../bootstrapper/images/kubeadm_test.go | 24 +++++++++---------- test/integration/start_stop_delete_test.go | 6 ++++- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/pkg/minikube/bootstrapper/images/kubeadm_test.go b/pkg/minikube/bootstrapper/images/kubeadm_test.go index ccbb0b1e83..d20a05bc55 100644 --- a/pkg/minikube/bootstrapper/images/kubeadm_test.go +++ b/pkg/minikube/bootstrapper/images/kubeadm_test.go @@ -39,8 +39,8 @@ func TestKubeadmImages(t *testing.T) { "k8s.gcr.io/pause:3.1", "k8s.gcr.io/kube-addon-manager:v9.0.2", "gcr.io/k8s-minikube/storage-provisioner:v1.8.1", - "docker.io/kubernetesui/dashboard:v2.0.0-beta8", - "docker.io/kubernetesui/metrics-scraper:v1.0.2", + "kubernetesui/dashboard:v2.0.0-beta8", + "kubernetesui/metrics-scraper:v1.0.2", }}, {"v1.16.1", "mirror.k8s.io", []string{ "mirror.k8s.io/kube-proxy:v1.16.1", @@ -65,8 +65,8 @@ func TestKubeadmImages(t *testing.T) { "k8s.gcr.io/pause:3.1", "k8s.gcr.io/kube-addon-manager:v9.0.2", "gcr.io/k8s-minikube/storage-provisioner:v1.8.1", - "docker.io/kubernetesui/dashboard:v2.0.0-beta8", - "docker.io/kubernetesui/metrics-scraper:v1.0.2", + "kubernetesui/dashboard:v2.0.0-beta8", + "kubernetesui/metrics-scraper:v1.0.2", }}, {"v1.14.0", "", []string{ "k8s.gcr.io/kube-proxy:v1.14.0", @@ -78,8 +78,8 @@ func TestKubeadmImages(t *testing.T) { "k8s.gcr.io/pause:3.1", "k8s.gcr.io/kube-addon-manager:v9.0.2", "gcr.io/k8s-minikube/storage-provisioner:v1.8.1", - "docker.io/kubernetesui/dashboard:v2.0.0-beta8", - "docker.io/kubernetesui/metrics-scraper:v1.0.2", + "kubernetesui/dashboard:v2.0.0-beta8", + "kubernetesui/metrics-scraper:v1.0.2", }}, {"v1.13.0", "", []string{ "k8s.gcr.io/kube-proxy:v1.13.0", @@ -91,8 +91,8 @@ func TestKubeadmImages(t *testing.T) { "k8s.gcr.io/pause:3.1", "k8s.gcr.io/kube-addon-manager:v9.0.2", "gcr.io/k8s-minikube/storage-provisioner:v1.8.1", - "docker.io/kubernetesui/dashboard:v2.0.0-beta8", - "docker.io/kubernetesui/metrics-scraper:v1.0.2", + "kubernetesui/dashboard:v2.0.0-beta8", + "kubernetesui/metrics-scraper:v1.0.2", }}, {"v1.12.0", "", []string{ "k8s.gcr.io/kube-proxy:v1.12.0", @@ -104,8 +104,8 @@ func TestKubeadmImages(t *testing.T) { "k8s.gcr.io/pause:3.1", "k8s.gcr.io/kube-addon-manager:v9.0.2", "gcr.io/k8s-minikube/storage-provisioner:v1.8.1", - "docker.io/kubernetesui/dashboard:v2.0.0-beta8", - "docker.io/kubernetesui/metrics-scraper:v1.0.2", + "kubernetesui/dashboard:v2.0.0-beta8", + "kubernetesui/metrics-scraper:v1.0.2", }}, {"v1.11.10", "", []string{ "k8s.gcr.io/kube-proxy-amd64:v1.11.10", @@ -117,8 +117,8 @@ func TestKubeadmImages(t *testing.T) { "k8s.gcr.io/pause:3.1", "k8s.gcr.io/kube-addon-manager:v9.0.2", "gcr.io/k8s-minikube/storage-provisioner:v1.8.1", - "docker.io/kubernetesui/dashboard:v2.0.0-beta8", - "docker.io/kubernetesui/metrics-scraper:v1.0.2", + "kubernetesui/dashboard:v2.0.0-beta8", + "kubernetesui/metrics-scraper:v1.0.2", }}, } for _, tc := range tests { diff --git a/test/integration/start_stop_delete_test.go b/test/integration/start_stop_delete_test.go index 49d1b9ee9d..8dfd44f667 100644 --- a/test/integration/start_stop_delete_test.go +++ b/test/integration/start_stop_delete_test.go @@ -156,12 +156,16 @@ func TestStartStop(t *testing.T) { Tags []string `json:"repoTags"` }{} err = json.Unmarshal(rr.Stdout.Bytes(), &jv) + if err != nil { + t.Errorf("images unmarshal: %v", err) + } gotImages := []string{} for _, img := range jv["images"] { for _, i := range img.Tags { // Ignore non-Kubernetes images if !strings.Contains(i, "ingress") && !strings.Contains(i, "busybox") { - gotImages = append(gotImages, i) + // Remove docker.io for naming consistency between container runtimes + gotImages = append(gotImages, strings.TrimPrefix(i, "docker.io/")) } } } From 8c806cc6639ed9a5815a5a44725a0a6b2cce92f4 Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Tue, 10 Dec 2019 14:43:58 -0800 Subject: [PATCH 47/72] CI: adding integration test duration to commit status --- hack/jenkins/common.sh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/hack/jenkins/common.sh b/hack/jenkins/common.sh index 4d32792d4b..d32ad0935d 100755 --- a/hack/jenkins/common.sh +++ b/hack/jenkins/common.sh @@ -258,6 +258,7 @@ if [[ "${LOAD}" -gt 2 ]]; then uptime fi +e2e_start_time="$(date -u +%s)" echo "" echo ">> Starting ${E2E_BIN} at $(date)" set -x @@ -270,6 +271,11 @@ ${SUDO_PREFIX}${E2E_BIN} \ set +x echo ">> ${E2E_BIN} exited with ${result} at $(date)" echo "" +e2e_end_time="$(date -u +%s)" +elapsed=$(($end_time-$start_time)) +elapsed=$(bc <<< "scale=2;$elapsed/60") +description="Finished in ${elapsed} minute(s)." +echo $description if [[ $result -eq 0 ]]; then status="success" @@ -300,6 +306,7 @@ function retry_github_status() { local state=$3 local token=$4 local target=$5 + local desc=$6 # Retry in case we hit our GitHub API quota or fail other ways. local attempt=0 @@ -312,7 +319,7 @@ function retry_github_status() { "https://api.github.com/repos/kubernetes/minikube/statuses/${commit}?access_token=${token}" \ -H "Content-Type: application/json" \ -X POST \ - -d "{\"state\": \"${state}\", \"description\": \"Jenkins\", \"target_url\": \"${target}\", \"context\": \"${context}\"}" || echo 999) + -d "{\"state\": \"${state}\", \"description\": \"Jenkins: ${desc}\", \"target_url\": \"${target}\", \"context\": \"${context}\"}" || echo 999) # 2xx HTTP codes if [[ "${code}" =~ ^2 ]]; then @@ -327,5 +334,7 @@ function retry_github_status() { done } -retry_github_status "${COMMIT}" "${JOB_NAME}" "${status}" "${access_token}" "https://storage.googleapis.com/minikube-builds/logs/${MINIKUBE_LOCATION}/${JOB_NAME}.txt" + + +retry_github_status "${COMMIT}" "${JOB_NAME}" "${status}" "${access_token}" "https://storage.googleapis.com/minikube-builds/logs/${MINIKUBE_LOCATION}/${JOB_NAME}.txt" "${description}" exit $result From e428b29ed2ef5845330f65d44b4af34440f1b91d Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Tue, 10 Dec 2019 14:48:23 -0800 Subject: [PATCH 48/72] fix typo --- hack/jenkins/common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hack/jenkins/common.sh b/hack/jenkins/common.sh index d32ad0935d..eb93296584 100755 --- a/hack/jenkins/common.sh +++ b/hack/jenkins/common.sh @@ -272,7 +272,7 @@ set +x echo ">> ${E2E_BIN} exited with ${result} at $(date)" echo "" e2e_end_time="$(date -u +%s)" -elapsed=$(($end_time-$start_time)) +elapsed=$(($e2e_end_time-$e2e_start_time)) elapsed=$(bc <<< "scale=2;$elapsed/60") description="Finished in ${elapsed} minute(s)." echo $description From dabf8c1cde93899f2833394e4be650541187ef1e Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Tue, 10 Dec 2019 14:51:19 -0800 Subject: [PATCH 49/72] better wording --- hack/jenkins/common.sh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/hack/jenkins/common.sh b/hack/jenkins/common.sh index eb93296584..ceb9c32dc9 100755 --- a/hack/jenkins/common.sh +++ b/hack/jenkins/common.sh @@ -271,11 +271,6 @@ ${SUDO_PREFIX}${E2E_BIN} \ set +x echo ">> ${E2E_BIN} exited with ${result} at $(date)" echo "" -e2e_end_time="$(date -u +%s)" -elapsed=$(($e2e_end_time-$e2e_start_time)) -elapsed=$(bc <<< "scale=2;$elapsed/60") -description="Finished in ${elapsed} minute(s)." -echo $description if [[ $result -eq 0 ]]; then status="success" @@ -285,6 +280,13 @@ else echo "minikube: FAIL" fi +e2e_end_time="$(date -u +%s)" +elapsed=$(($e2e_end_time-$e2e_start_time)) +elapsed=$(bc <<< "scale=2;$elapsed/60") +description="completed with ${status} in ${elapsed} minute(s)." +echo $description + + echo ">> Cleaning up after ourselves ..." ${SUDO_PREFIX}${MINIKUBE_BIN} tunnel --cleanup || true ${SUDO_PREFIX}${MINIKUBE_BIN} delete >/dev/null 2>/dev/null || true From bef508d461286e710fd1a92bc4492a369b8a11ba Mon Sep 17 00:00:00 2001 From: Thomas Stromberg Date: Tue, 10 Dec 2019 15:23:47 -0800 Subject: [PATCH 50/72] Remove high-ASCII characters from comment --- pkg/minikube/bootstrapper/images/images.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/minikube/bootstrapper/images/images.go b/pkg/minikube/bootstrapper/images/images.go index 1d84dda09f..b80e17f372 100644 --- a/pkg/minikube/bootstrapper/images/images.go +++ b/pkg/minikube/bootstrapper/images/images.go @@ -40,7 +40,7 @@ func Auxiliary(mirror string) []string { } } -// Pause returns the image name for thoß… pause image +// Pause returns the image name to pull for the pause image func Pause(mirror string) string { // Should match `PauseVersion` in: // https://github.com/kubernetes/kubernetes/blob/master/cmd/kubeadm/app/constants/constants.go From 28e3dc6d14ccc9a4682dd8f6c79cb6fd794d2bc5 Mon Sep 17 00:00:00 2001 From: tstromberg Date: Tue, 10 Dec 2019 15:43:03 -0800 Subject: [PATCH 51/72] Version bump to v1.6.0 --- CHANGELOG.md | 35 +++++++++++++++++++++++++++++++++++ Makefile | 4 ++-- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3314170d60..009e9a696e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,40 @@ # Release Notes +## Version 1.6.0 - 2019-12-10 + +* Sync cached image list for Kubernetes v1.17 [#6043](https://github.com/kubernetes/minikube/pull/6043) +* cache add: load images to all profiles & skip previously cached images [#5987](https://github.com/kubernetes/minikube/pull/5987) +* Pre-cache the latest kube-addon-manager [#5935](https://github.com/kubernetes/minikube/pull/5935) +* Update default k8s version to v1.17.0 [#6042](https://github.com/kubernetes/minikube/pull/6042) +* Add sch_netem kernel module for network emulation [#6038](https://github.com/kubernetes/minikube/pull/6038) +* Update dashboard to 2.0.0b8 and pre-cache it again [#6039](https://github.com/kubernetes/minikube/pull/6039) +* Make Kubernetes version sticky for a cluster instead of auto-upgrading [#5798](https://github.com/kubernetes/minikube/pull/5798) +* Don't use bash as the entrypoint for docker [#5818](https://github.com/kubernetes/minikube/pull/5818) +* Make lock names uid and path specific to avoid conflicts [#5912](https://github.com/kubernetes/minikube/pull/5912) +* typo: Fix typo in err_map key [#6010](https://github.com/kubernetes/minikube/pull/6010) +* Remove depreacted annotation storageclass.beta.kubernetes.io [#5954](https://github.com/kubernetes/minikube/pull/5954) +* show status in profile list [#5988](https://github.com/kubernetes/minikube/pull/5988) +* Use newer gvisor version [#6000](https://github.com/kubernetes/minikube/pull/6000) +* Adds dm-crypt support [#5739](https://github.com/kubernetes/minikube/pull/5739) +* Add performance analysis packages to minikube ISO [#5942](https://github.com/kubernetes/minikube/pull/5942) + +Thanks goes out to the merry band of Kubernetes contributors that made this release possible: + +- Anders F Björklund +- Anukul Sangwan +- Guilherme Pellizzetti +- Jan Ahrens +- Karuppiah Natarajan +- Laura-Marie Henning +- Medya Ghazizadeh +- Nanik T +- Olivier Lemasle +- Priya Wadhwa +- Sharif Elgamal +- Thomas Strömberg +- Vasyl Purchel +- Wietse Muizelaar + ## Version 1.6.0-beta.1 - 2019-11-26 * cri-o v1.16.0 [#5970](https://github.com/kubernetes/minikube/pull/5970) diff --git a/Makefile b/Makefile index 5d63f97516..f12e972f96 100755 --- a/Makefile +++ b/Makefile @@ -15,12 +15,12 @@ # Bump these on release - and please check ISO_VERSION for correctness. VERSION_MAJOR ?= 1 VERSION_MINOR ?= 6 -VERSION_BUILD ?= 0-beta.1 +VERSION_BUILD ?= 0 RAW_VERSION=$(VERSION_MAJOR).$(VERSION_MINOR).${VERSION_BUILD} VERSION ?= v$(RAW_VERSION) # Default to .0 for higher cache hit rates, as build increments typically don't require new ISO versions -ISO_VERSION ?= v1.6.0-beta.1 +ISO_VERSION ?= v$(VERSION_MAJOR).$(VERSION_MINOR).0 # Dashes are valid in semver, but not Linux packaging. Use ~ to delimit alpha/beta DEB_VERSION ?= $(subst -,~,$(RAW_VERSION)) RPM_VERSION ?= $(DEB_VERSION) From b0ba1ff0c60e80296ba4a9b6e1912689420eb3e4 Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Tue, 10 Dec 2019 15:43:43 -0800 Subject: [PATCH 52/72] use tail instead of bc for div --- hack/jenkins/common.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hack/jenkins/common.sh b/hack/jenkins/common.sh index ceb9c32dc9..60002060c2 100755 --- a/hack/jenkins/common.sh +++ b/hack/jenkins/common.sh @@ -280,9 +280,12 @@ else echo "minikube: FAIL" fi +## caclucate the time took to finish running e2e binary test. e2e_end_time="$(date -u +%s)" elapsed=$(($e2e_end_time-$e2e_start_time)) -elapsed=$(bc <<< "scale=2;$elapsed/60") +min=$(($elapsed/60)) +sec=$(tail -c 3 <<< $((${elapsed}00/60))) +elapsed=$min.$sec description="completed with ${status} in ${elapsed} minute(s)." echo $description From 080db29423bc9c51b035b52e1eb6f96a1201b6b9 Mon Sep 17 00:00:00 2001 From: tstromberg Date: Tue, 10 Dec 2019 15:44:49 -0800 Subject: [PATCH 53/72] Sort changes by impact --- CHANGELOG.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 009e9a696e..53aa6d91de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,21 +2,20 @@ ## Version 1.6.0 - 2019-12-10 -* Sync cached image list for Kubernetes v1.17 [#6043](https://github.com/kubernetes/minikube/pull/6043) +* Update default k8s version to v1.17.0 [#6042](https://github.com/kubernetes/minikube/pull/6042) * cache add: load images to all profiles & skip previously cached images [#5987](https://github.com/kubernetes/minikube/pull/5987) * Pre-cache the latest kube-addon-manager [#5935](https://github.com/kubernetes/minikube/pull/5935) -* Update default k8s version to v1.17.0 [#6042](https://github.com/kubernetes/minikube/pull/6042) * Add sch_netem kernel module for network emulation [#6038](https://github.com/kubernetes/minikube/pull/6038) * Update dashboard to 2.0.0b8 and pre-cache it again [#6039](https://github.com/kubernetes/minikube/pull/6039) * Make Kubernetes version sticky for a cluster instead of auto-upgrading [#5798](https://github.com/kubernetes/minikube/pull/5798) * Don't use bash as the entrypoint for docker [#5818](https://github.com/kubernetes/minikube/pull/5818) * Make lock names uid and path specific to avoid conflicts [#5912](https://github.com/kubernetes/minikube/pull/5912) -* typo: Fix typo in err_map key [#6010](https://github.com/kubernetes/minikube/pull/6010) * Remove depreacted annotation storageclass.beta.kubernetes.io [#5954](https://github.com/kubernetes/minikube/pull/5954) * show status in profile list [#5988](https://github.com/kubernetes/minikube/pull/5988) * Use newer gvisor version [#6000](https://github.com/kubernetes/minikube/pull/6000) * Adds dm-crypt support [#5739](https://github.com/kubernetes/minikube/pull/5739) * Add performance analysis packages to minikube ISO [#5942](https://github.com/kubernetes/minikube/pull/5942) +* typo: Fix typo in err_map key [#6010](https://github.com/kubernetes/minikube/pull/6010) Thanks goes out to the merry band of Kubernetes contributors that made this release possible: From 688f6389b4a24cd761eaec477101d40e2be433c4 Mon Sep 17 00:00:00 2001 From: tstromberg Date: Tue, 10 Dec 2019 15:46:17 -0800 Subject: [PATCH 54/72] More massaging of changes --- CHANGELOG.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 53aa6d91de..cae5ae360e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,12 +10,11 @@ * Make Kubernetes version sticky for a cluster instead of auto-upgrading [#5798](https://github.com/kubernetes/minikube/pull/5798) * Don't use bash as the entrypoint for docker [#5818](https://github.com/kubernetes/minikube/pull/5818) * Make lock names uid and path specific to avoid conflicts [#5912](https://github.com/kubernetes/minikube/pull/5912) -* Remove depreacted annotation storageclass.beta.kubernetes.io [#5954](https://github.com/kubernetes/minikube/pull/5954) +* Remove deprecated annotation storageclass.beta.kubernetes.io [#5954](https://github.com/kubernetes/minikube/pull/5954) * show status in profile list [#5988](https://github.com/kubernetes/minikube/pull/5988) * Use newer gvisor version [#6000](https://github.com/kubernetes/minikube/pull/6000) * Adds dm-crypt support [#5739](https://github.com/kubernetes/minikube/pull/5739) * Add performance analysis packages to minikube ISO [#5942](https://github.com/kubernetes/minikube/pull/5942) -* typo: Fix typo in err_map key [#6010](https://github.com/kubernetes/minikube/pull/6010) Thanks goes out to the merry band of Kubernetes contributors that made this release possible: From 09f0979e95a64cc61b47a03cd5bbc4b6422582d9 Mon Sep 17 00:00:00 2001 From: tstromberg Date: Tue, 10 Dec 2019 17:49:47 -0800 Subject: [PATCH 55/72] More massaging of changes --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cae5ae360e..3a32fc381b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,11 +3,11 @@ ## Version 1.6.0 - 2019-12-10 * Update default k8s version to v1.17.0 [#6042](https://github.com/kubernetes/minikube/pull/6042) +* Make Kubernetes version sticky for a cluster instead of auto-upgrading [#5798](https://github.com/kubernetes/minikube/pull/5798) * cache add: load images to all profiles & skip previously cached images [#5987](https://github.com/kubernetes/minikube/pull/5987) +* Update dashboard to 2.0.0b8 and pre-cache it again [#6039](https://github.com/kubernetes/minikube/pull/6039) * Pre-cache the latest kube-addon-manager [#5935](https://github.com/kubernetes/minikube/pull/5935) * Add sch_netem kernel module for network emulation [#6038](https://github.com/kubernetes/minikube/pull/6038) -* Update dashboard to 2.0.0b8 and pre-cache it again [#6039](https://github.com/kubernetes/minikube/pull/6039) -* Make Kubernetes version sticky for a cluster instead of auto-upgrading [#5798](https://github.com/kubernetes/minikube/pull/5798) * Don't use bash as the entrypoint for docker [#5818](https://github.com/kubernetes/minikube/pull/5818) * Make lock names uid and path specific to avoid conflicts [#5912](https://github.com/kubernetes/minikube/pull/5912) * Remove deprecated annotation storageclass.beta.kubernetes.io [#5954](https://github.com/kubernetes/minikube/pull/5954) From c0349fb9ad3f28e5cde75115142498de41078eac Mon Sep 17 00:00:00 2001 From: tstromberg Date: Tue, 10 Dec 2019 17:53:04 -0800 Subject: [PATCH 56/72] Don't check image versions with the none driver (no crictl) --- test/integration/start_stop_delete_test.go | 56 +++++++++++----------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/test/integration/start_stop_delete_test.go b/test/integration/start_stop_delete_test.go index 8dfd44f667..5b43864614 100644 --- a/test/integration/start_stop_delete_test.go +++ b/test/integration/start_stop_delete_test.go @@ -148,35 +148,37 @@ func TestStartStop(t *testing.T) { } // Make sure that kubeadm did not need to pull in additional images - rr, err = Run(t, exec.CommandContext(ctx, Target(), "ssh", "-p", profile, "sudo crictl images -o json")) - if err != nil { - t.Errorf("%s failed: %v", rr.Args, err) - } - jv := map[string][]struct { - Tags []string `json:"repoTags"` - }{} - err = json.Unmarshal(rr.Stdout.Bytes(), &jv) - if err != nil { - t.Errorf("images unmarshal: %v", err) - } - gotImages := []string{} - for _, img := range jv["images"] { - for _, i := range img.Tags { - // Ignore non-Kubernetes images - if !strings.Contains(i, "ingress") && !strings.Contains(i, "busybox") { - // Remove docker.io for naming consistency between container runtimes - gotImages = append(gotImages, strings.TrimPrefix(i, "docker.io/")) + if !NoneDriver() { + rr, err = Run(t, exec.CommandContext(ctx, Target(), "ssh", "-p", profile, "sudo crictl images -o json")) + if err != nil { + t.Errorf("%s failed: %v", rr.Args, err) + } + jv := map[string][]struct { + Tags []string `json:"repoTags"` + }{} + err = json.Unmarshal(rr.Stdout.Bytes(), &jv) + if err != nil { + t.Errorf("images unmarshal: %v", err) + } + gotImages := []string{} + for _, img := range jv["images"] { + for _, i := range img.Tags { + // Ignore non-Kubernetes images + if !strings.Contains(i, "ingress") && !strings.Contains(i, "busybox") { + // Remove docker.io for naming consistency between container runtimes + gotImages = append(gotImages, strings.TrimPrefix(i, "docker.io/")) + } } } - } - want, err := images.Kubeadm("", tc.version) - if err != nil { - t.Errorf("kubeadm images: %v", tc.version) - } - sort.Strings(want) - sort.Strings(gotImages) - if diff := cmp.Diff(want, gotImages); diff != "" { - t.Errorf("%s images mismatch (-want +got):\n%s", tc.version, diff) + want, err := images.Kubeadm("", tc.version) + if err != nil { + t.Errorf("kubeadm images: %v", tc.version) + } + sort.Strings(want) + sort.Strings(gotImages) + if diff := cmp.Diff(want, gotImages); diff != "" { + t.Errorf("%s images mismatch (-want +got):\n%s", tc.version, diff) + } } if strings.Contains(tc.name, "cni") { From 68d5a3b396b47942a71209ee8ffd34ea11012ea0 Mon Sep 17 00:00:00 2001 From: minikube-bot Date: Tue, 10 Dec 2019 19:55:12 -0800 Subject: [PATCH 57/72] Update releases.json to include v1.6.0 --- deploy/minikube/releases.json | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/deploy/minikube/releases.json b/deploy/minikube/releases.json index 18716cfd74..e9b77dee17 100644 --- a/deploy/minikube/releases.json +++ b/deploy/minikube/releases.json @@ -1,4 +1,12 @@ [ + { + "name": "v1.6.0", + "checksums": { + "darwin": "fd1af02f0fc11fb0bec35b9ae1f6bf2d157f51948155d8b1ddc899521642fc32", + "linux": "48738607ecdb0b00815599230a2a2b17dc90bd3bbcb1b217bace043f78370db3", + "windows": "20e7db220308f06913acd10addb1ec01c87b74245cebc70fa18a979c1b323f34" + } + }, { "name": "v1.5.2", "checksums": { From 9f9abac0aaa9b0d8d75387c33df57c580a08e633 Mon Sep 17 00:00:00 2001 From: Thomas Stromberg Date: Tue, 10 Dec 2019 19:58:06 -0800 Subject: [PATCH 58/72] Version bump doc to v1.6.0 --- site/config.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site/config.toml b/site/config.toml index c8f5420ef6..27f60c098f 100644 --- a/site/config.toml +++ b/site/config.toml @@ -92,7 +92,7 @@ weight = 1 [params] copyright = "The Kubernetes Authors -- " # The latest release of minikube -latest_release = "1.5.2" +latest_release = "1.6.0" privacy_policy = "" From cfe0f5a5b722bcfa2f7028efb024f5a94f5ff4ec Mon Sep 17 00:00:00 2001 From: Thomas Stromberg Date: Wed, 11 Dec 2019 08:13:12 -0800 Subject: [PATCH 59/72] Use md5 to generate unique lock names --- pkg/util/lock/lock.go | 12 ++---------- pkg/util/lock/lock_test.go | 19 ++++++++++--------- 2 files changed, 12 insertions(+), 19 deletions(-) diff --git a/pkg/util/lock/lock.go b/pkg/util/lock/lock.go index 5083fa0d8c..d5c945b9d8 100644 --- a/pkg/util/lock/lock.go +++ b/pkg/util/lock/lock.go @@ -17,12 +17,12 @@ limitations under the License. package lock import ( + "crypto/md5" "fmt" "io/ioutil" "os" "os/user" "regexp" - "strings" "time" "github.com/golang/glog" @@ -78,13 +78,5 @@ func UserMutexSpec(path string) mutex.Spec { func getMutexNameForPath(path string) string { // juju requires that names match ^[a-zA-Z][a-zA-Z0-9-]*$", and be under 40 chars long. - n := strings.Trim(nonString.ReplaceAllString(path, "-"), "-") - // we need to always guarantee an alphanumeric prefix - prefix := "m" - - // Prefer the last 40 chars, as paths tend get more specific toward the end - if len(n) >= 40 { - return prefix + n[len(n)-39:] - } - return prefix + n + return fmt.Sprintf("m%x", md5.Sum([]byte(path))) } diff --git a/pkg/util/lock/lock_test.go b/pkg/util/lock/lock_test.go index 8bb97d0465..d7d7a22fe9 100644 --- a/pkg/util/lock/lock_test.go +++ b/pkg/util/lock/lock_test.go @@ -24,45 +24,46 @@ func TestUserMutexSpec(t *testing.T) { var tests = []struct { description string path string - expected string }{ { description: "standard", path: "/foo/bar", - expected: "mfoo-bar-test", }, { description: "deep directory", path: "/foo/bar/baz/bat", - expected: "mfoo-bar-baz-bat-test", }, { description: "underscores", path: "/foo_bar/baz", - expected: "mfoo-bar-baz-test", }, { description: "starts with number", path: "/foo/2bar/baz", - expected: "mfoo-2bar-baz-test", }, { description: "starts with punctuation", path: "/.foo/bar", - expected: "mfoo-bar-test", }, { description: "long filename", path: "/very-very-very-very-very-very-very-very-long/bar", - expected: "m-very-very-very-very-very-long-bar-test", + }, + { + description: "Windows kubeconfig", + path: `C:\Users\admin/.kube/config`, + }, + { + description: "Windows json", + path: `C:\Users\admin\.minikube\profiles\containerd-20191210T212325.7356633-8584\config.json`, }, } for _, tc := range tests { t.Run(tc.description, func(t *testing.T) { got := UserMutexSpec(tc.path) - if got.Name != tc.expected { - t.Errorf("%s mutex name = %q, expected %q", tc.path, got.Name, tc.expected) + if len(got.Name) > 40 { + t.Errorf("%s mutex name is too long", got.Name) } }) } From af4e690837bbd939c38bfafb9e27d7ad424dce61 Mon Sep 17 00:00:00 2001 From: Thomas Stromberg Date: Wed, 11 Dec 2019 09:14:20 -0800 Subject: [PATCH 60/72] Use sha1 for a larger hash, truncated to 40 chars --- pkg/util/lock/lock.go | 13 ++++++------- pkg/util/lock/lock_test.go | 4 ++-- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/pkg/util/lock/lock.go b/pkg/util/lock/lock.go index d5c945b9d8..6c5eee6ac8 100644 --- a/pkg/util/lock/lock.go +++ b/pkg/util/lock/lock.go @@ -17,12 +17,11 @@ limitations under the License. package lock import ( - "crypto/md5" + "crypto/sha1" "fmt" "io/ioutil" "os" "os/user" - "regexp" "time" "github.com/golang/glog" @@ -32,8 +31,6 @@ import ( ) var ( - // nonString is characters to strip from lock names - nonString = regexp.MustCompile(`[\W_]+`) // forceID is a user id for consistent testing forceID = "" ) @@ -64,9 +61,10 @@ func UserMutexSpec(path string) mutex.Spec { id = u.Uid } } - + name := getMutexNameForPath(fmt.Sprintf("%s-%s", path, id)) + glog.Infof("mutex name for %s: %s", path, name) s := mutex.Spec{ - Name: getMutexNameForPath(fmt.Sprintf("%s-%s", path, id)), + Name: name, Clock: clock.WallClock, // Poll the lock twice a second Delay: 500 * time.Millisecond, @@ -78,5 +76,6 @@ func UserMutexSpec(path string) mutex.Spec { func getMutexNameForPath(path string) string { // juju requires that names match ^[a-zA-Z][a-zA-Z0-9-]*$", and be under 40 chars long. - return fmt.Sprintf("m%x", md5.Sum([]byte(path))) + name := fmt.Sprintf("mk%x", sha1.Sum([]byte(path))) + return name[0:40] } diff --git a/pkg/util/lock/lock_test.go b/pkg/util/lock/lock_test.go index d7d7a22fe9..43656fa943 100644 --- a/pkg/util/lock/lock_test.go +++ b/pkg/util/lock/lock_test.go @@ -62,8 +62,8 @@ func TestUserMutexSpec(t *testing.T) { for _, tc := range tests { t.Run(tc.description, func(t *testing.T) { got := UserMutexSpec(tc.path) - if len(got.Name) > 40 { - t.Errorf("%s mutex name is too long", got.Name) + if len(got.Name) != 40 { + t.Errorf("%s is not 40 chars long", got.Name) } }) } From 129b6a870b5847880712158bd30d745283151b76 Mon Sep 17 00:00:00 2001 From: Thomas Stromberg Date: Wed, 11 Dec 2019 09:54:44 -0800 Subject: [PATCH 61/72] Update log messages --- pkg/util/lock/lock.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pkg/util/lock/lock.go b/pkg/util/lock/lock.go index 6c5eee6ac8..2455cc246d 100644 --- a/pkg/util/lock/lock.go +++ b/pkg/util/lock/lock.go @@ -38,16 +38,16 @@ var ( // WriteFile decorates ioutil.WriteFile with a file lock and retry func WriteFile(filename string, data []byte, perm os.FileMode) error { spec := UserMutexSpec(filename) - glog.Infof("acquiring lock for %s: %+v", filename, spec) + glog.Infof("WriteFile acquiring %s: %+v", filename, spec) releaser, err := mutex.Acquire(spec) if err != nil { - return errors.Wrapf(err, "error acquiring lock for %s", filename) + return errors.Wrapf(err, "failed to acquire lock for %s: %+v", filename, spec) } defer releaser.Release() if err = ioutil.WriteFile(filename, data, perm); err != nil { - return errors.Wrapf(err, "error writing file %s", filename) + return errors.Wrapf(err, "writefile failed for %s", filename) } return err } @@ -62,7 +62,6 @@ func UserMutexSpec(path string) mutex.Spec { } } name := getMutexNameForPath(fmt.Sprintf("%s-%s", path, id)) - glog.Infof("mutex name for %s: %s", path, name) s := mutex.Spec{ Name: name, Clock: clock.WallClock, From c5f65baf6134057af80be0be34e0678c1849743d Mon Sep 17 00:00:00 2001 From: Thomas Stromberg Date: Wed, 11 Dec 2019 11:52:36 -0800 Subject: [PATCH 62/72] Remove uid from hash name, as it is not necessary now that we lock on filenames rather than descriptive names --- pkg/util/lock/lock.go | 23 ++++------------------- pkg/util/lock/lock_test.go | 21 +++++++++++++++++---- 2 files changed, 21 insertions(+), 23 deletions(-) diff --git a/pkg/util/lock/lock.go b/pkg/util/lock/lock.go index 2455cc246d..78f965e76f 100644 --- a/pkg/util/lock/lock.go +++ b/pkg/util/lock/lock.go @@ -21,7 +21,6 @@ import ( "fmt" "io/ioutil" "os" - "os/user" "time" "github.com/golang/glog" @@ -37,7 +36,7 @@ var ( // WriteFile decorates ioutil.WriteFile with a file lock and retry func WriteFile(filename string, data []byte, perm os.FileMode) error { - spec := UserMutexSpec(filename) + spec := pathSpec(filename) glog.Infof("WriteFile acquiring %s: %+v", filename, spec) releaser, err := mutex.Acquire(spec) if err != nil { @@ -52,18 +51,10 @@ func WriteFile(filename string, data []byte, perm os.FileMode) error { return err } -// UserMutexSpec returns a mutex spec that will not collide with other users -func UserMutexSpec(path string) mutex.Spec { - id := forceID - if forceID == "" { - u, err := user.Current() - if err == nil { - id = u.Uid - } - } - name := getMutexNameForPath(fmt.Sprintf("%s-%s", path, id)) +// pathSpec returns a mutex spec for a path +func pathSpec(path string) mutex.Spec { s := mutex.Spec{ - Name: name, + Name: fmt.Sprintf("mk%x", sha1.Sum([]byte(path)))[0:40], Clock: clock.WallClock, // Poll the lock twice a second Delay: 500 * time.Millisecond, @@ -72,9 +63,3 @@ func UserMutexSpec(path string) mutex.Spec { } return s } - -func getMutexNameForPath(path string) string { - // juju requires that names match ^[a-zA-Z][a-zA-Z0-9-]*$", and be under 40 chars long. - name := fmt.Sprintf("mk%x", sha1.Sum([]byte(path))) - return name[0:40] -} diff --git a/pkg/util/lock/lock_test.go b/pkg/util/lock/lock_test.go index 43656fa943..145fd6edaa 100644 --- a/pkg/util/lock/lock_test.go +++ b/pkg/util/lock/lock_test.go @@ -16,14 +16,17 @@ limitations under the License. package lock -import "testing" +import ( + "testing" + + "github.com/juju/mutex" +) func TestUserMutexSpec(t *testing.T) { - forceID = "test" - var tests = []struct { description string path string + expected string }{ { description: "standard", @@ -59,12 +62,22 @@ func TestUserMutexSpec(t *testing.T) { }, } + seen := map[string]string{} + for _, tc := range tests { t.Run(tc.description, func(t *testing.T) { - got := UserMutexSpec(tc.path) + got := pathSpec(tc.path) if len(got.Name) != 40 { t.Errorf("%s is not 40 chars long", got.Name) } + if seen[got.Name] != "" { + t.Fatalf("lock name collision between %s and %s", tc.path, seen[got.Name]) + } + m, err := mutex.Acquire(got) + if err != nil { + t.Errorf("acquire for spec %+v failed: %v", got, err) + } + m.Release() }) } } From 3171493e5129ed195a1363ed13181d72e1773cee Mon Sep 17 00:00:00 2001 From: Thomas Stromberg Date: Wed, 11 Dec 2019 12:01:32 -0800 Subject: [PATCH 63/72] Rename to PathMutexSpec --- pkg/minikube/bootstrapper/certs.go | 2 +- pkg/minikube/kubeconfig/settings.go | 2 +- pkg/util/lock/lock.go | 6 +++--- pkg/util/lock/lock_test.go | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/minikube/bootstrapper/certs.go b/pkg/minikube/bootstrapper/certs.go index 611b5416cc..d0731b24cd 100644 --- a/pkg/minikube/bootstrapper/certs.go +++ b/pkg/minikube/bootstrapper/certs.go @@ -70,7 +70,7 @@ func SetupCerts(cmd command.Runner, k8s config.KubernetesConfig) error { // // If another process updates the shared certificate, it's invalid. // TODO: Instead of racey manipulation of a shared certificate, use per-profile certs - spec := lock.UserMutexSpec(filepath.Join(localPath, "certs")) + spec := lock.PathMutexSpec(filepath.Join(localPath, "certs")) glog.Infof("acquiring lock: %+v", spec) releaser, err := mutex.Acquire(spec) if err != nil { diff --git a/pkg/minikube/kubeconfig/settings.go b/pkg/minikube/kubeconfig/settings.go index 0cd09ec542..85b8f7ca9d 100644 --- a/pkg/minikube/kubeconfig/settings.go +++ b/pkg/minikube/kubeconfig/settings.go @@ -119,7 +119,7 @@ func PopulateFromSettings(cfg *Settings, apiCfg *api.Config) error { // activeContext is true when minikube is the CurrentContext // If no CurrentContext is set, the given name will be used. func Update(kcs *Settings) error { - spec := lock.UserMutexSpec(filepath.Join(kcs.filePath(), "settings.Update")) + spec := lock.PathMutexSpec(filepath.Join(kcs.filePath(), "settings.Update")) glog.Infof("acquiring lock: %+v", spec) releaser, err := mutex.Acquire(spec) if err != nil { diff --git a/pkg/util/lock/lock.go b/pkg/util/lock/lock.go index 78f965e76f..19990d378a 100644 --- a/pkg/util/lock/lock.go +++ b/pkg/util/lock/lock.go @@ -36,7 +36,7 @@ var ( // WriteFile decorates ioutil.WriteFile with a file lock and retry func WriteFile(filename string, data []byte, perm os.FileMode) error { - spec := pathSpec(filename) + spec := PathMutexSpec(filename) glog.Infof("WriteFile acquiring %s: %+v", filename, spec) releaser, err := mutex.Acquire(spec) if err != nil { @@ -51,8 +51,8 @@ func WriteFile(filename string, data []byte, perm os.FileMode) error { return err } -// pathSpec returns a mutex spec for a path -func pathSpec(path string) mutex.Spec { +// PathMutexSpec returns a mutex spec for a path +func PathMutexSpec(path string) mutex.Spec { s := mutex.Spec{ Name: fmt.Sprintf("mk%x", sha1.Sum([]byte(path)))[0:40], Clock: clock.WallClock, diff --git a/pkg/util/lock/lock_test.go b/pkg/util/lock/lock_test.go index 145fd6edaa..8ec94e5f24 100644 --- a/pkg/util/lock/lock_test.go +++ b/pkg/util/lock/lock_test.go @@ -66,7 +66,7 @@ func TestUserMutexSpec(t *testing.T) { for _, tc := range tests { t.Run(tc.description, func(t *testing.T) { - got := pathSpec(tc.path) + got := PathMutexSpec(tc.path) if len(got.Name) != 40 { t.Errorf("%s is not 40 chars long", got.Name) } From d811f6e4284964f7dcf80903eeb88682165b37bf Mon Sep 17 00:00:00 2001 From: Thomas Stromberg Date: Wed, 11 Dec 2019 12:10:28 -0800 Subject: [PATCH 64/72] Remove unused forceID var --- pkg/util/lock/lock.go | 5 ----- 1 file changed, 5 deletions(-) diff --git a/pkg/util/lock/lock.go b/pkg/util/lock/lock.go index 19990d378a..8d2e833ab0 100644 --- a/pkg/util/lock/lock.go +++ b/pkg/util/lock/lock.go @@ -29,11 +29,6 @@ import ( "github.com/pkg/errors" ) -var ( - // forceID is a user id for consistent testing - forceID = "" -) - // WriteFile decorates ioutil.WriteFile with a file lock and retry func WriteFile(filename string, data []byte, perm os.FileMode) error { spec := PathMutexSpec(filename) From 50daf97bde270c1b7d7f6678590daa1a365519ca Mon Sep 17 00:00:00 2001 From: Thomas Stromberg Date: Wed, 11 Dec 2019 12:50:58 -0800 Subject: [PATCH 65/72] Version bump to v1.6.1 --- CHANGELOG.md | 6 ++++++ Makefile | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a32fc381b..15119fbba5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Release Notes +## Version 1.6.1 - 2019-12-11 + +A special bugfix release to fix a Windows regression: + +* lock names: Remove uid suffix & hash entire path [#6059](https://github.com/kubernetes/minikube/pull/6059) + ## Version 1.6.0 - 2019-12-10 * Update default k8s version to v1.17.0 [#6042](https://github.com/kubernetes/minikube/pull/6042) diff --git a/Makefile b/Makefile index f12e972f96..941593fe42 100755 --- a/Makefile +++ b/Makefile @@ -15,7 +15,7 @@ # Bump these on release - and please check ISO_VERSION for correctness. VERSION_MAJOR ?= 1 VERSION_MINOR ?= 6 -VERSION_BUILD ?= 0 +VERSION_BUILD ?= 1 RAW_VERSION=$(VERSION_MAJOR).$(VERSION_MINOR).${VERSION_BUILD} VERSION ?= v$(RAW_VERSION) From f5f7e4f74c304f41faa5861a9d2c658ee6c4a6db Mon Sep 17 00:00:00 2001 From: Thomas Stromberg Date: Wed, 11 Dec 2019 12:57:32 -0800 Subject: [PATCH 66/72] Version bump config.toml to v1.6.1 --- site/config.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site/config.toml b/site/config.toml index 27f60c098f..7387c9b1cc 100644 --- a/site/config.toml +++ b/site/config.toml @@ -92,7 +92,7 @@ weight = 1 [params] copyright = "The Kubernetes Authors -- " # The latest release of minikube -latest_release = "1.6.0" +latest_release = "1.6.1" privacy_policy = "" From b6bb8f5698bda87dec5e060a9844484ff2ed9eae Mon Sep 17 00:00:00 2001 From: minikube-bot Date: Wed, 11 Dec 2019 13:00:26 -0800 Subject: [PATCH 67/72] Update releases.json to include v1.6.1 --- deploy/minikube/releases.json | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/deploy/minikube/releases.json b/deploy/minikube/releases.json index e9b77dee17..fc90643c49 100644 --- a/deploy/minikube/releases.json +++ b/deploy/minikube/releases.json @@ -1,4 +1,12 @@ [ + { + "name": "v1.6.1", + "checksums": { + "darwin": "bcfc181ade08bd2a87fca70f0aa59f9f4b23c893fc2b335b3cb8f05b84ae2d34", + "linux": "cbd526d64531266d42f02667339d3c53e5a399e3abebda63c96b0bbd6b7e935d", + "windows": "1d7372fcf099d583d4140a4ce4aa8f5c2752d3bd0d143e53647aee6221dcb663" + } + }, { "name": "v1.6.0", "checksums": { From a840cb72896cf5a59f6ef9fecbd5880d09e5f2aa Mon Sep 17 00:00:00 2001 From: Kenta Iso Date: Tue, 17 Dec 2019 00:58:45 +0900 Subject: [PATCH 68/72] Fix update-context to use KUBECONFIG when the env is set and add integration test --- cmd/minikube/cmd/update-context.go | 10 +++++++++- test/integration/functional_test.go | 14 ++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/cmd/minikube/cmd/update-context.go b/cmd/minikube/cmd/update-context.go index d0e5e69344..fcdf29aedb 100644 --- a/cmd/minikube/cmd/update-context.go +++ b/cmd/minikube/cmd/update-context.go @@ -17,6 +17,8 @@ limitations under the License. package cmd import ( + "os" + "github.com/spf13/cobra" "github.com/spf13/viper" "k8s.io/minikube/pkg/minikube/cluster" @@ -45,7 +47,13 @@ var updateContextCmd = &cobra.Command{ if err != nil { exit.WithError("Error host driver ip status", err) } - updated, err := kubeconfig.UpdateIP(ip, machineName, constants.KubeconfigPath) + updated := false + kubeConfigPath := os.Getenv("KUBECONFIG") + if kubeConfigPath == "" { + updated, err = kubeconfig.UpdateIP(ip, machineName, constants.KubeconfigPath) + } else { + updated, err = kubeconfig.UpdateIP(ip, machineName, kubeConfigPath) + } if err != nil { exit.WithError("update config", err) } diff --git a/test/integration/functional_test.go b/test/integration/functional_test.go index cdda2dd55d..a21ec2a56b 100644 --- a/test/integration/functional_test.go +++ b/test/integration/functional_test.go @@ -103,6 +103,7 @@ func TestFunctional(t *testing.T) { {"SSHCmd", validateSSHCmd}, {"MySQL", validateMySQL}, {"FileSync", validateFileSync}, + {"UpdateContextCmd", validateUpdateContextCmd}, } for _, tc := range tests { tc := tc @@ -645,6 +646,19 @@ func validateFileSync(ctx context.Context, t *testing.T, profile string) { } } +// validateUpdateContextCmd asserts basic "update-context" command functionality +func validateUpdateContextCmd(ctx context.Context, t *testing.T, profile string) { + rr, err := Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "update-context", "--alsologtostderr", "-v=2")) + if err != nil { + t.Errorf("%s failed: %v", rr.Args, err) + } + + want := []byte("IP was already correctly configured") + if !bytes.Contains(rr.Stdout.Bytes(), want) { + t.Errorf("update-context: got=%q, want=*%q*", rr.Stdout.Bytes(), want) + } +} + // startHTTPProxy runs a local http proxy and sets the env vars for it. func startHTTPProxy(t *testing.T) (*http.Server, error) { port, err := freeport.GetFreePort() From 8a6e94de8f7f03ed06940c45b1c7d83bc8c239aa Mon Sep 17 00:00:00 2001 From: Thomas Stromberg Date: Mon, 16 Dec 2019 15:41:22 -0800 Subject: [PATCH 69/72] jenkins: delete all clusters --- hack/jenkins/common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hack/jenkins/common.sh b/hack/jenkins/common.sh index 60002060c2..01cefed8be 100755 --- a/hack/jenkins/common.sh +++ b/hack/jenkins/common.sh @@ -292,7 +292,7 @@ echo $description echo ">> Cleaning up after ourselves ..." ${SUDO_PREFIX}${MINIKUBE_BIN} tunnel --cleanup || true -${SUDO_PREFIX}${MINIKUBE_BIN} delete >/dev/null 2>/dev/null || true +${SUDO_PREFIX}${MINIKUBE_BIN} delete --all >/dev/null 2>/dev/null || true cleanup_stale_routes || true ${SUDO_PREFIX} rm -Rf "${MINIKUBE_HOME}" || true From f29ea7d4912b151bb7a6a783fbb3cb3e35da12ff Mon Sep 17 00:00:00 2001 From: Aresforchina <18845641183@163.com> Date: Thu, 12 Dec 2019 18:16:54 +0800 Subject: [PATCH 70/72] pkg/minikube/:fix-up typos --- pkg/minikube/translate/translate_test.go | 2 +- pkg/minikube/vmpath/constants.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/minikube/translate/translate_test.go b/pkg/minikube/translate/translate_test.go index fd7a73cf64..1482544eb2 100644 --- a/pkg/minikube/translate/translate_test.go +++ b/pkg/minikube/translate/translate_test.go @@ -96,7 +96,7 @@ func TestT(t *testing.T) { Translations = test.translations got := T(test.input) if test.expected != got { - t.Errorf("T(%v) shoud return %v, but got: %v", test.input, test.expected, got) + t.Errorf("T(%v) should return %v, but got: %v", test.input, test.expected, got) } }) } diff --git a/pkg/minikube/vmpath/constants.go b/pkg/minikube/vmpath/constants.go index cd6b5205d1..7a6cf84f4f 100644 --- a/pkg/minikube/vmpath/constants.go +++ b/pkg/minikube/vmpath/constants.go @@ -17,7 +17,7 @@ limitations under the License. package vmpath const ( - // GuestAddonsDir is the default path of the addons configration + // GuestAddonsDir is the default path of the addons configuration GuestAddonsDir = "/etc/kubernetes/addons" // GuestManifestsDir is where the kubelet should look for static Pod manifests GuestManifestsDir = "/etc/kubernetes/manifests" From ec8c36d48d19768d18e5f8a2075334610642d114 Mon Sep 17 00:00:00 2001 From: Sharif Elgamal Date: Wed, 18 Dec 2019 13:37:12 -0800 Subject: [PATCH 71/72] exclude generated files from linting --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 941593fe42..722d594b31 100755 --- a/Makefile +++ b/Makefile @@ -60,7 +60,8 @@ GOLINT_GOGC ?= 100 GOLINT_OPTIONS = --timeout 4m \ --build-tags "${MINIKUBE_INTEGRATION_BUILD_TAGS}" \ --enable goimports,gocritic,golint,gocyclo,misspell,nakedret,stylecheck,unconvert,unparam,dogsled \ - --exclude 'variable on range scope.*in function literal|ifElseChain' + --exclude 'variable on range scope.*in function literal|ifElseChain' \ + --skip-files "pkg/minikube/translate/translations.go|pkg/minikube/assets/assets.go" # Major version of gvisor image. Increment when there are breaking changes. GVISOR_IMAGE_VERSION ?= 2 From d864ac3f04dabfd2caf55b87c9bd74cb7323021a Mon Sep 17 00:00:00 2001 From: Zhou Hao Date: Thu, 19 Dec 2019 17:48:02 +0800 Subject: [PATCH 72/72] pkg/util: add CalculateSizeInMB test Signed-off-by: zhouhao --- pkg/util/utils_test.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/pkg/util/utils_test.go b/pkg/util/utils_test.go index 26a10724a4..1be9f669fc 100644 --- a/pkg/util/utils_test.go +++ b/pkg/util/utils_test.go @@ -80,3 +80,22 @@ func TestConcatStrings(t *testing.T) { } } } + +func TestCalculateSizeInMB(t *testing.T) { + testData := []struct { + size string + expectedNumber int + }{ + {"1024kb", 1}, + {"1024KB", 1}, + {"1024mb", 1024}, + {"1024b", 0}, + } + + for _, tt := range testData { + number := CalculateSizeInMB(tt.size) + if number != tt.expectedNumber { + t.Fatalf("Expected '%d'' but got '%d'", tt.expectedNumber, number) + } + } +}