swap to bool

pull/8095/head
Sharif Elgamal 2020-05-15 15:24:33 -07:00
parent 9c17c9214d
commit 1cc7404e76
4 changed files with 16 additions and 10 deletions

View File

@ -886,6 +886,8 @@ func createNode(cc config.ClusterConfig, kubeNodeName string, existing *config.C
return cc, config.Node{}, err
}
// Make sure that existing nodes honor if KubernetesVersion gets specified on restart
// KubernetesVersion is the only attribute that the user can override in the Node object
for _, n := range existing.Nodes {
n.KubernetesVersion = getKubernetesVersion(&cc)
cc.Nodes = append(cc.Nodes, n)

View File

@ -76,12 +76,7 @@ func remoteTarballURL(k8sVersion, containerRuntime string) string {
}
// PreloadExists returns true if there is a preloaded tarball that can be used
func PreloadExists(k8sVersion, containerRuntime string) bool {
// TODO: debug why this func is being called two times
glog.Infof("Checking if preload exists for k8s version %s and runtime %s", k8sVersion, containerRuntime)
if !viper.GetBool("preload") {
return false
}
func PreloadExists(k8sVersion, containerRuntime string, forcePreload ...bool) bool {
// and https://github.com/kubernetes/minikube/issues/6934
// to track status of adding crio
@ -90,6 +85,17 @@ func PreloadExists(k8sVersion, containerRuntime string) bool {
return false
}
force := false
if len(forcePreload) > 0 {
force = forcePreload[0]
}
// TODO: debug why this func is being called two times
glog.Infof("Checking if preload exists for k8s version %s and runtime %s", k8sVersion, containerRuntime)
if !viper.GetBool("preload") && !force {
return false
}
// Omit remote check if tarball exists locally
targetPath := TarballPath(k8sVersion, containerRuntime)
if _, err := os.Stat(targetPath); err == nil {

View File

@ -30,7 +30,6 @@ import (
"strings"
"testing"
"github.com/spf13/viper"
"k8s.io/minikube/pkg/minikube/bootstrapper/images"
"k8s.io/minikube/pkg/minikube/constants"
"k8s.io/minikube/pkg/minikube/download"
@ -74,8 +73,7 @@ func TestDownloadOnly(t *testing.T) {
// skip for none, as none driver does not have preload feature.
if !NoneDriver() {
viper.Set("preload", true)
if download.PreloadExists(v, r) {
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)

View File

@ -328,7 +328,7 @@ func validateStatusCmd(ctx context.Context, t *testing.T, profile string) {
// Custom format
rr, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "status", "-f", "host:{{.Host}},kublet:{{.Kubelet}},apiserver:{{.APIServer}},kubeconfig:{{.Kubeconfig}}"))
if err != nil {
t.Errorf("failed to run minikube status with custom format: args %q: %v", rr.Command(), err)
t.Errorf("failed to run minikube status with custom format: args %q: %v", rr.Command(te), err)
}
re := `host:([A-z]+),kublet:([A-z]+),apiserver:([A-z]+),kubeconfig:([A-z]+)`
match, _ := regexp.MatchString(re, rr.Stdout.String())