interpret wait flags
parent
f4950bc76d
commit
e4eae47e86
|
@ -44,6 +44,7 @@ import (
|
|||
cmdcfg "k8s.io/minikube/cmd/minikube/cmd/config"
|
||||
"k8s.io/minikube/pkg/drivers/kic/oci"
|
||||
"k8s.io/minikube/pkg/minikube/bootstrapper/bsutil"
|
||||
"k8s.io/minikube/pkg/minikube/bootstrapper/bsutil/kverify"
|
||||
"k8s.io/minikube/pkg/minikube/bootstrapper/images"
|
||||
"k8s.io/minikube/pkg/minikube/config"
|
||||
"k8s.io/minikube/pkg/minikube/constants"
|
||||
|
@ -109,7 +110,7 @@ const (
|
|||
downloadOnly = "download-only"
|
||||
dnsProxy = "dns-proxy"
|
||||
hostDNSResolver = "host-dns-resolver"
|
||||
waitUntilHealthy = "wait"
|
||||
waitComponents = "wait"
|
||||
force = "force"
|
||||
dryRun = "dry-run"
|
||||
interactive = "interactive"
|
||||
|
@ -171,7 +172,7 @@ func initMinikubeFlags() {
|
|||
startCmd.Flags().String(criSocket, "", "The cri socket path to be used.")
|
||||
startCmd.Flags().String(networkPlugin, "", "The name of the network plugin.")
|
||||
startCmd.Flags().Bool(enableDefaultCNI, false, "Enable the default CNI plugin (/etc/cni/net.d/k8s.conf). Used in conjunction with \"--network-plugin=cni\".")
|
||||
startCmd.Flags().Bool(waitUntilHealthy, true, "Block until the apiserver is servicing API requests")
|
||||
startCmd.Flags().StringSlice(waitComponents, kverify.DefaultWaitsKeys, fmt.Sprintf("comma separated list of kuberentes components to wait to verify after start. defaults to %q, available options: %q . can also specify 'all' or 'none'", kverify.DefaultWaitsKeys, kverify.AllWaitsKeys))
|
||||
startCmd.Flags().Duration(waitTimeout, 6*time.Minute, "max time to wait per Kubernetes core services to be healthy.")
|
||||
startCmd.Flags().Bool(nativeSSH, true, "Use native Golang SSH client (default true). Set to 'false' to use the command line 'ssh' command when accessing the docker machine. Useful for the machine drivers when they will not start with 'Waiting for SSH'.")
|
||||
startCmd.Flags().Bool(autoUpdate, true, "If set, automatically updates drivers to the latest version. Defaults to true.")
|
||||
|
@ -1200,3 +1201,45 @@ func getKubernetesVersion(old *config.ClusterConfig) string {
|
|||
}
|
||||
return nv
|
||||
}
|
||||
|
||||
// interpretWaitFlag interprets the wait flag and respects the legacy minikube users
|
||||
// returns waitForAPI, waitForSysPod, waitForSA
|
||||
func interpretWaitFlag(cmd cobra.Command) map[string]bool {
|
||||
if !cmd.Flags().Changed(waitComponents) {
|
||||
glog.Infof("Wait Components : %+v", kverify.DefaultWaits)
|
||||
return kverify.DefaultWaits
|
||||
}
|
||||
|
||||
waitFlags, err := cmd.Flags().GetStringSlice(waitComponents)
|
||||
if err != nil {
|
||||
glog.Infof("failed to get wait from flags, will use default wait components : %+v", kverify.DefaultWaits)
|
||||
return kverify.DefaultWaits
|
||||
}
|
||||
|
||||
// before minikube 1.9.0, wait flag was boolean
|
||||
if (len(waitFlags) == 1 && waitFlags[0] == "true") || (len(waitFlags) == 1 && waitFlags[0] == "all") {
|
||||
return kverify.AllWaitsCompo
|
||||
}
|
||||
|
||||
// respecting legacy flag format --wait=false
|
||||
// before minikube 1.9.0, wait flag was boolean
|
||||
if (len(waitFlags) == 1 && waitFlags[0] == "false") || len(waitFlags) == 1 && waitFlags[0] == "none" {
|
||||
return kverify.NoWaitsCompo
|
||||
}
|
||||
|
||||
waitCompos := map[string]bool{}
|
||||
for _, wc := range waitFlags {
|
||||
seen := false
|
||||
for _, valid := range kverify.AllValidWaitsList {
|
||||
if wc == valid {
|
||||
waitCompos[wc] = true
|
||||
seen = true
|
||||
continue
|
||||
}
|
||||
}
|
||||
if !seen {
|
||||
glog.Warning("invalid wait component flag %q. valid options are %q", wc, strings.Join(kverify.AllValidWaitsList, ","))
|
||||
}
|
||||
}
|
||||
return waitCompos
|
||||
}
|
||||
|
|
|
@ -35,19 +35,28 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
// APIServer is the name used in the flags for k8s api server
|
||||
APIServer = "apiserver"
|
||||
// SystemPod is the name used in the flags for pods in the kube system
|
||||
SystemPods = "system_pods"
|
||||
// DefaultSA is the name used in the flags for default service account
|
||||
DefaultSA = "default_sa"
|
||||
// APIServerWait is the name used in the flags for k8s api server
|
||||
APIServerWait = "apiserver"
|
||||
// SystemPodsWait is the name used in the flags for pods in the kube system
|
||||
SystemPodsWait = "system_pods"
|
||||
// DefaultSAWait is the name used in the flags for default service account
|
||||
DefaultSAWait = "default_sa"
|
||||
)
|
||||
|
||||
// DefaultWaits is the default components to wait for
|
||||
var DefaultWaits = []string{APIServer, SystemPods}
|
||||
// DefaultWaits is map of the the default components to wait for
|
||||
var DefaultWaits = map[string]bool{APIServerWait: true, SystemPodsWait: true}
|
||||
|
||||
// AvailableWaits is list of possible components that user can choose to wait for
|
||||
var AvailableWaits = []string{APIServer, SystemPods, DefaultSA}
|
||||
// DefaultWaitsKeys is list of all default components to wait for
|
||||
var DefaultWaitsKeys = []string{APIServerWait, SystemPodsWait}
|
||||
|
||||
// NoWaitsCompo is map of componets to wait for if specified 'none' or 'false'
|
||||
var NoWaitsCompo = map[string]bool{}
|
||||
|
||||
// AllWaitsCompo is map for waiting for all components.
|
||||
var AllWaitsCompo = map[string]bool{APIServerWait: true, SystemPodsWait: true, DefaultSAWait: true}
|
||||
|
||||
// AllValidWaitsList list of all valid components to wait for
|
||||
var AllValidWaitsList = []string{APIServerWait, SystemPodsWait, DefaultSAWait}
|
||||
|
||||
// minLogCheckTime how long to wait before spamming error logs to console
|
||||
const minLogCheckTime = 30 * time.Second
|
||||
|
|
Loading…
Reference in New Issue