Merge branch 'master' of https://github.com/kubernetes/minikube into fix-json-output

pull/10232/head
Priya Wadhwa 2021-01-25 10:53:36 -08:00
commit 6e1ae7e70f
9 changed files with 222 additions and 177 deletions

View File

@ -26,7 +26,10 @@ KIC_VERSION ?= $(shell egrep "Version =" pkg/drivers/kic/types.go | cut -d \" -f
ISO_VERSION ?= v1.17.0
# Dashes are valid in semver, but not Linux packaging. Use ~ to delimit alpha/beta
DEB_VERSION ?= $(subst -,~,$(RAW_VERSION))
DEB_REVISION ?= 2
RPM_VERSION ?= $(DEB_VERSION)
RPM_REVISION ?= 0
# used by hack/jenkins/release_build_and_upload.sh and KVM_BUILD_IMAGE, see also BUILD_IMAGE below
GO_VERSION ?= 1.15.5
@ -397,6 +400,7 @@ clean: ## Clean build
rm -f pkg/minikube/assets/assets.go
rm -f pkg/minikube/translate/translations.go
rm -rf ./vendor
rm -rf /tmp/tmp.*.minikube_*
.PHONY: gendocs
gendocs: out/docs/minikube.md ## Generate documentation
@ -462,40 +466,44 @@ out/docs/minikube.md: $(shell find "cmd") $(shell find "pkg/minikube/constants")
go run -ldflags="$(MINIKUBE_LDFLAGS)" -tags gendocs hack/help_text/gen_help_text.go
deb_version:
@echo $(DEB_VERSION)
@echo $(DEB_VERSION)-$(DEB_REVISION)
out/minikube_$(DEB_VERSION).deb: out/minikube_$(DEB_VERSION)-0_amd64.deb
out/minikube_$(DEB_VERSION).deb: out/minikube_$(DEB_VERSION)-$(DEB_REVISION)_amd64.deb
cp $< $@
out/minikube_$(DEB_VERSION)-0_%.deb: out/minikube-linux-%
cp -r installers/linux/deb/minikube_deb_template out/minikube_$(DEB_VERSION)
chmod 0755 out/minikube_$(DEB_VERSION)/DEBIAN
sed -E -i 's/--VERSION--/'$(DEB_VERSION)'/g' out/minikube_$(DEB_VERSION)/DEBIAN/control
sed -E -i 's/--ARCH--/'$*'/g' out/minikube_$(DEB_VERSION)/DEBIAN/control
out/minikube_$(DEB_VERSION)-$(DEB_REVISION)_%.deb: out/minikube-linux-%
$(eval DEB_PACKAGING_DIRECTORY_$*=$(shell mktemp -d --suffix ".minikube_$(DEB_VERSION)-$*-deb"))
cp -r installers/linux/deb/minikube_deb_template/* $(DEB_PACKAGING_DIRECTORY_$*)/
chmod 0755 $(DEB_PACKAGING_DIRECTORY_$*)/DEBIAN
sed -E -i 's/--VERSION--/'$(DEB_VERSION)'/g' $(DEB_PACKAGING_DIRECTORY_$*)/DEBIAN/control
sed -E -i 's/--ARCH--/'$*'/g' $(DEB_PACKAGING_DIRECTORY_$*)/DEBIAN/control
if [ "$*" = "amd64" ]; then \
sed -E -i 's/--RECOMMENDS--/virtualbox/' out/minikube_$(DEB_VERSION)/DEBIAN/control; \
sed -E -i 's/--RECOMMENDS--/virtualbox/' $(DEB_PACKAGING_DIRECTORY_$*)/DEBIAN/control; \
else \
sed -E -i '/Recommends: --RECOMMENDS--/d' out/minikube_$(DEB_VERSION)/DEBIAN/control; \
sed -E -i '/Recommends: --RECOMMENDS--/d' $(DEB_PACKAGING_DIRECTORY_$*)/DEBIAN/control; \
fi
mkdir -p out/minikube_$(DEB_VERSION)/usr/bin
cp $< out/minikube_$(DEB_VERSION)/usr/bin/minikube
fakeroot dpkg-deb --build out/minikube_$(DEB_VERSION) $@
rm -rf out/minikube_$(DEB_VERSION)
mkdir -p $(DEB_PACKAGING_DIRECTORY_$*)/usr/bin
cp $< $(DEB_PACKAGING_DIRECTORY_$*)/usr/bin/minikube
fakeroot dpkg-deb --build $(DEB_PACKAGING_DIRECTORY_$*) $@
rm -rf $(DEB_PACKAGING_DIRECTORY_$*)
rpm_version:
@echo $(RPM_VERSION)
@echo $(RPM_VERSION)-$(RPM_REVISION)
out/minikube-$(RPM_VERSION).rpm: out/minikube-$(RPM_VERSION)-0.x86_64.rpm
out/minikube-$(RPM_VERSION).rpm: out/minikube-$(RPM_VERSION)-$(RPM_REVISION).x86_64.rpm
cp $< $@
out/minikube-$(RPM_VERSION)-0.%.rpm: out/minikube-linux-%
cp -r installers/linux/rpm/minikube_rpm_template out/minikube-$(RPM_VERSION)
sed -E -i 's/--VERSION--/'$(RPM_VERSION)'/g' out/minikube-$(RPM_VERSION)/minikube.spec
sed -E -i 's|--OUT--|'$(PWD)/out'|g' out/minikube-$(RPM_VERSION)/minikube.spec
$(eval RPM_PACKAGING_DIRECTORY_$*=$(shell mktemp -d --suffix ".minikube_$(RPM_VERSION)-$*-rpm"))
cp -r installers/linux/rpm/minikube_rpm_template/* $(RPM_PACKAGING_DIRECTORY_$*)/
sed -E -i 's/--VERSION--/'$(RPM_VERSION)'/g' $(RPM_PACKAGING_DIRECTORY_$*)/minikube.spec
sed -E -i 's|--OUT--|'$(PWD)/out'|g' $(RPM_PACKAGING_DIRECTORY_$*)/minikube.spec
rpmbuild -bb -D "_rpmdir $(PWD)/out" --target $* \
out/minikube-$(RPM_VERSION)/minikube.spec
@mv out/$*/minikube-$(RPM_VERSION)-0.$*.rpm out/ && rmdir out/$*
rm -rf out/minikube-$(RPM_VERSION)
$(RPM_PACKAGING_DIRECTORY_$*)/minikube.spec
@mv out/$*/minikube-$(RPM_VERSION)-$(RPM_REVISION).$*.rpm out/ && rmdir out/$*
rm -rf $(RPM_PACKAGING_DIRECTORY_$*)
.PHONY: apt
apt: out/Release ## Generate apt package file

View File

@ -1,4 +1,12 @@
[
{
"name": "v1.17.0",
"checksums": {
"darwin": "ad2b4de4b3f8863c2cfa9f5072cdc787141b0587fb9855dd645242253489fab3",
"linux": "e312901e12c347d0e4eec74d94b8d75512943eb62479b441bb1332f05cde0d09",
"windows": "dcae6ee972a49c4389d5e3ea81039b826cda55fefbe23b9273eeb46514abe244"
}
},
{
"name": "v1.16.0",
"checksums": {

View File

@ -55,6 +55,9 @@ Update the version numbers in `Makefile`:
- beta releases use: `v$(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_BUILD)`
- major/minor releases use: `v$(VERSION_MAJOR).$(VERSION_MINOR).0`
- if the ISO was updated, a patch release may use `v$(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_BUILD)`
* `DEB_REVISION`, `RPM_REVISION`
- for all major/minor releases, set to 0
- if updating .deb/.rpm files without a major/minor release, increment by 1
{{% alert title="Warning" color="warning" %}}
Merge this PR only if all non-experimental integration tests pass!

View File

@ -40,131 +40,129 @@ import (
)
func TestDownloadOnly(t *testing.T) {
for _, r := range []string{"crio", "docker", "containerd"} {
t.Run(r, func(t *testing.T) {
// Stores the startup run result for later error messages
var rrr *RunResult
// Stores the startup run result for later error messages
var rrr *RunResult
profile := UniqueProfileName(r)
ctx, cancel := context.WithTimeout(context.Background(), Minutes(30))
defer Cleanup(t, profile, cancel)
profile := UniqueProfileName("download-only")
ctx, cancel := context.WithTimeout(context.Background(), Minutes(30))
defer Cleanup(t, profile, cancel)
containerRuntime := ContainerRuntime()
versions := []string{
constants.OldestKubernetesVersion,
constants.DefaultKubernetesVersion,
constants.NewestKubernetesVersion,
versions := []string{
constants.OldestKubernetesVersion,
constants.DefaultKubernetesVersion,
constants.NewestKubernetesVersion,
}
for _, v := range versions {
t.Run(v, func(t *testing.T) {
defer PostMortemLogs(t, profile)
// --force to avoid uid check
args := append([]string{"start", "-o=json", "--download-only", "-p", profile, "--force", "--alsologtostderr", fmt.Sprintf("--kubernetes-version=%s", v)}, StartArgs()...)
rt, err := Run(t, exec.CommandContext(ctx, Target(), args...))
if rrr == nil {
// Preserve the initial run-result for debugging
rrr = rt
}
for _, v := range versions {
t.Run(v, func(t *testing.T) {
defer PostMortemLogs(t, profile)
// --force to avoid uid check
args := append([]string{"start", "-o=json", "--download-only", "-p", profile, "--force", "--alsologtostderr", fmt.Sprintf("--kubernetes-version=%s", v), fmt.Sprintf("--container-runtime=%s", r)}, StartArgs()...)
rt, err := Run(t, exec.CommandContext(ctx, Target(), args...))
if rrr == nil {
// Preserve the initial run-result for debugging
rrr = rt
}
if err != nil {
t.Errorf("failed to download only. args: %q %v", args, err)
}
t.Run("check json events", func(t *testing.T) {
s := bufio.NewScanner(bytes.NewReader(rt.Stdout.Bytes()))
for s.Scan() {
var rtObj map[string]interface{}
err = json.Unmarshal(s.Bytes(), &rtObj)
if err != nil {
t.Errorf("failed to parse output: %v", err)
} else if step, ok := rtObj["data"]; ok {
if stepMap, ok := step.(map[string]interface{}); ok {
if stepMap["currentstep"] == "" {
t.Errorf("Empty step number for %v", stepMap["name"])
}
}
}
}
})
// skip for none, as none driver does not have preload feature.
if !NoneDriver() {
if download.PreloadExists(v, r, true) {
// Just make sure the tarball path exists
if _, err := os.Stat(download.TarballPath(v, r)); err != nil {
t.Errorf("failed to verify preloaded tarball file exists: %v", err)
}
return
}
}
imgs, err := images.Kubeadm("", v)
if err != nil {
t.Errorf("failed to get kubeadm images for %v: %+v", v, err)
}
// skip verify for cache images if --driver=none
if !NoneDriver() {
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)
_, err := os.Stat(fp)
if err != nil {
t.Errorf("expected image file exist at %q but got error: %v", fp, err)
}
}
}
// checking binaries downloaded (kubelet,kubeadm)
for _, bin := range constants.KubernetesReleaseBinaries {
fp := filepath.Join(localpath.MiniPath(), "cache", "linux", v, bin)
_, err := os.Stat(fp)
if err != nil {
t.Errorf("expected the file for binary exist at %q but got error %v", fp, err)
}
}
// If we are on darwin/windows, check to make sure OS specific kubectl has been downloaded
// as well for the `minikube kubectl` command
if runtime.GOOS == "linux" {
return
}
binary := "kubectl"
if runtime.GOOS == "windows" {
binary = "kubectl.exe"
}
fp := filepath.Join(localpath.MiniPath(), "cache", runtime.GOOS, v, binary)
if _, err := os.Stat(fp); err != nil {
t.Errorf("expected the file for binary exist at %q but got error %v", fp, err)
}
})
if err != nil {
t.Errorf("failed to download only. args: %q %v", args, err)
}
// This is a weird place to test profile deletion, but this test is serial, and we have a profile to delete!
t.Run("DeleteAll", func(t *testing.T) {
defer PostMortemLogs(t, profile)
if !CanCleanup() {
t.Skip("skipping, as cleanup is disabled")
}
rr, err := Run(t, exec.CommandContext(ctx, Target(), "delete", "--all"))
if err != nil {
t.Errorf("failed to delete all. args: %q : %v", rr.Command(), err)
t.Run("check json events", func(t *testing.T) {
s := bufio.NewScanner(bytes.NewReader(rt.Stdout.Bytes()))
for s.Scan() {
var rtObj map[string]interface{}
err = json.Unmarshal(s.Bytes(), &rtObj)
if err != nil {
t.Errorf("failed to parse output: %v", err)
} else if step, ok := rtObj["data"]; ok {
if stepMap, ok := step.(map[string]interface{}); ok {
if stepMap["currentstep"] == "" {
t.Errorf("Empty step number for %v", stepMap["name"])
}
}
}
}
})
// Delete should always succeed, even if previously partially or fully deleted.
t.Run("DeleteAlwaysSucceeds", func(t *testing.T) {
defer PostMortemLogs(t, profile)
if !CanCleanup() {
t.Skip("skipping, as cleanup is disabled")
// skip for none, as none driver does not have preload feature.
if !NoneDriver() {
if download.PreloadExists(v, containerRuntime, true) {
// Just make sure the tarball path exists
if _, err := os.Stat(download.TarballPath(v, containerRuntime)); err != nil {
t.Errorf("failed to verify preloaded tarball file exists: %v", err)
}
return
}
rr, err := Run(t, exec.CommandContext(ctx, Target(), "delete", "-p", profile))
}
imgs, err := images.Kubeadm("", v)
if err != nil {
t.Errorf("failed to get kubeadm images for %v: %+v", v, err)
}
// skip verify for cache images if --driver=none
if !NoneDriver() {
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)
_, err := os.Stat(fp)
if err != nil {
t.Errorf("expected image file exist at %q but got error: %v", fp, err)
}
}
}
// checking binaries downloaded (kubelet,kubeadm)
for _, bin := range constants.KubernetesReleaseBinaries {
fp := filepath.Join(localpath.MiniPath(), "cache", "linux", v, bin)
_, err := os.Stat(fp)
if err != nil {
t.Errorf("failed to delete. args: %q: %v", rr.Command(), err)
t.Errorf("expected the file for binary exist at %q but got error %v", fp, err)
}
})
}
// If we are on darwin/windows, check to make sure OS specific kubectl has been downloaded
// as well for the `minikube kubectl` command
if runtime.GOOS == "linux" {
return
}
binary := "kubectl"
if runtime.GOOS == "windows" {
binary = "kubectl.exe"
}
fp := filepath.Join(localpath.MiniPath(), "cache", runtime.GOOS, v, binary)
if _, err := os.Stat(fp); err != nil {
t.Errorf("expected the file for binary exist at %q but got error %v", fp, err)
}
})
}
// This is a weird place to test profile deletion, but this test is serial, and we have a profile to delete!
t.Run("DeleteAll", func(t *testing.T) {
defer PostMortemLogs(t, profile)
if !CanCleanup() {
t.Skip("skipping, as cleanup is disabled")
}
rr, err := Run(t, exec.CommandContext(ctx, Target(), "delete", "--all"))
if err != nil {
t.Errorf("failed to delete all. args: %q : %v", rr.Command(), err)
}
})
// Delete should always succeed, even if previously partially or fully deleted.
t.Run("DeleteAlwaysSucceeds", func(t *testing.T) {
defer PostMortemLogs(t, profile)
if !CanCleanup() {
t.Skip("skipping, as cleanup is disabled")
}
rr, err := Run(t, exec.CommandContext(ctx, Target(), "delete", "-p", profile))
if err != nil {
t.Errorf("failed to delete. args: %q: %v", rr.Command(), err)
}
})
}
func TestDownloadOnlyKic(t *testing.T) {

View File

@ -26,41 +26,34 @@ import (
"testing"
)
// TestOffline makes sure minikube works without internet, once it the user has already cached the images, This test has to run after TestDownloadOnly!
// TestOffline makes sure minikube works without internet, once it the user has already cached the images, This test has to run after TestDownloadOnly
func TestOffline(t *testing.T) {
t.Run("group", func(t *testing.T) {
for _, rt := range []string{"docker", "crio", "containerd"} {
rt := rt
t.Run(rt, func(t *testing.T) {
MaybeParallel(t)
MaybeParallel(t)
rt := ContainerRuntime()
if rt != "docker" && arm64Platform() {
t.Skipf("skipping %s - only docker runtime supported on arm64. See https://github.com/kubernetes/minikube/issues/10144", t.Name())
}
if rt != "docker" && arm64Platform() {
t.Skipf("skipping %s - only docker runtime supported on arm64. See https://github.com/kubernetes/minikube/issues/10144", t.Name())
}
if rt != "docker" && NoneDriver() {
t.Skipf("skipping %s - incompatible with none driver", t.Name())
}
if rt != "docker" && NoneDriver() {
t.Skipf("skipping %s - incompatible with none driver", t.Name())
}
profile := UniqueProfileName(fmt.Sprintf("offline-%s", rt))
ctx, cancel := context.WithTimeout(context.Background(), Minutes(15))
defer CleanupWithLogs(t, profile, cancel)
profile := UniqueProfileName(fmt.Sprintf("offline-%s", rt))
ctx, cancel := context.WithTimeout(context.Background(), Minutes(15))
defer CleanupWithLogs(t, profile, cancel)
startArgs := []string{"start", "-p", profile, "--alsologtostderr", "-v=1", "--memory=2000", "--wait=true"}
startArgs = append(startArgs, StartArgs()...)
c := exec.CommandContext(ctx, Target(), startArgs...)
env := os.Environ()
// RFC1918 address that unlikely to host working a proxy server
env = append(env, "HTTP_PROXY=172.16.1.1:1")
env = append(env, "HTTP_PROXYS=172.16.1.1:1")
startArgs := []string{"start", "-p", profile, "--alsologtostderr", "-v=1", "--memory=2000", "--wait=true", "--container-runtime", rt}
startArgs = append(startArgs, StartArgs()...)
c := exec.CommandContext(ctx, Target(), startArgs...)
env := os.Environ()
// RFC1918 address that unlikely to host working a proxy server
env = append(env, "HTTP_PROXY=172.16.1.1:1")
env = append(env, "HTTP_PROXYS=172.16.1.1:1")
c.Env = env
rr, err := Run(t, c)
if err != nil {
// Fatal so that we may collect logs before stop/delete steps
t.Fatalf("%s failed: %v", rr.Command(), err)
}
})
}
})
c.Env = env
rr, err := Run(t, c)
if err != nil {
// Fatal so that we may collect logs before stop/delete steps
t.Fatalf("%s failed: %v", rr.Command(), err)
}
}

View File

@ -30,6 +30,9 @@ func TestDockerFlags(t *testing.T) {
if NoneDriver() {
t.Skip("skipping: none driver does not support ssh or bundle docker")
}
if ContainerRuntime() != "docker" {
t.Skipf("skipping: only runs with docker container runtime, currently testing %s", ContainerRuntime())
}
MaybeParallel(t)
profile := UniqueProfileName("docker-flags")
@ -82,16 +85,36 @@ func TestForceSystemdFlag(t *testing.T) {
t.Errorf("failed to start minikube with args: %q : %v", rr.Command(), err)
}
rr, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "docker info --format {{.CgroupDriver}}"))
containerRuntime := ContainerRuntime()
switch containerRuntime {
case "docker":
validateDockerSystemd(ctx, t, profile)
case "containerd":
validateContainerdSystemd(ctx, t, profile)
}
}
func validateDockerSystemd(ctx context.Context, t *testing.T, profile string) {
rr, err := Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "docker info --format {{.CgroupDriver}}"))
if err != nil {
t.Errorf("failed to get docker cgroup driver. args %q: %v", rr.Command(), err)
}
if !strings.Contains(rr.Output(), "systemd") {
t.Fatalf("expected systemd cgroup driver, got: %v", rr.Output())
}
}
func validateContainerdSystemd(ctx context.Context, t *testing.T, profile string) {
rr, err := Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "cat /etc/containerd/config.toml"))
if err != nil {
t.Errorf("failed to get docker cgroup driver. args %q: %v", rr.Command(), err)
}
if !strings.Contains(rr.Output(), "systemd_cgroup = true") {
t.Fatalf("expected systemd cgroup driver, got: %v", rr.Output())
}
}
func TestForceSystemdEnv(t *testing.T) {
if NoneDriver() {
t.Skip("skipping: none driver does not support ssh or bundle docker")
@ -109,13 +132,11 @@ func TestForceSystemdEnv(t *testing.T) {
if err != nil {
t.Errorf("failed to start minikube with args: %q : %v", rr.Command(), err)
}
rr, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "docker info --format {{.CgroupDriver}}"))
if err != nil {
t.Errorf("failed to get docker cgroup driver. args %q: %v", rr.Command(), err)
}
if !strings.Contains(rr.Output(), "systemd") {
t.Fatalf("expected systemd cgroup driver, got: %v", rr.Output())
containerRuntime := ContainerRuntime()
switch containerRuntime {
case "docker":
validateDockerSystemd(ctx, t, profile)
case "containerd":
validateContainerdSystemd(ctx, t, profile)
}
}

View File

@ -159,7 +159,11 @@ func validateNodeLabels(ctx context.Context, t *testing.T, profile string) {
}
// check functionality of minikube after evaling docker-env
// TODO: Add validatePodmanEnv for crio runtime: #10231
func validateDockerEnv(ctx context.Context, t *testing.T, profile string) {
if cr := ContainerRuntime(); cr != "docker" {
t.Skipf("only validate docker env with docker container runtime, currently testing %s", cr)
}
defer PostMortemLogs(t, profile)
mctx, cancel := context.WithTimeout(ctx, Seconds(120))
defer cancel()

View File

@ -38,6 +38,9 @@ func TestSkaffold(t *testing.T) {
if NoneDriver() {
t.Skip("none driver doesn't support `minikube docker-env`; skaffold depends on this command")
}
if cr := ContainerRuntime(); cr != "docker" {
t.Skipf("skaffold requires docker-env, currently testing %s container runtime", cr)
}
profile := UniqueProfileName("skaffold")
ctx, cancel := context.WithTimeout(context.Background(), Minutes(5))

View File

@ -24,8 +24,15 @@ spec:
app: mysql
spec:
containers:
- image: mysql:5.6
- image: mysql:5.7
name: mysql
resources:
requests:
memory: "512Mi"
cpu: "600m"
limits:
memory: "700Mi"
cpu: "700m"
env:
# Use secret in real usage
- name: MYSQL_ROOT_PASSWORD