From 37a1d3bc0b67ec65d6476e0678e082f23db3dac5 Mon Sep 17 00:00:00 2001 From: Pablo Caderno Date: Mon, 10 Aug 2020 15:08:39 +1000 Subject: [PATCH 1/3] Added startHostTimeout flag Signed-off-by: Pablo Caderno --- cmd/minikube/cmd/start_flags.go | 4 +++- go.mod | 1 - pkg/minikube/config/types.go | 2 ++ pkg/minikube/machine/cluster_test.go | 2 ++ pkg/minikube/machine/start.go | 2 +- site/content/en/docs/commands/start.md | 1 + 6 files changed, 9 insertions(+), 3 deletions(-) diff --git a/cmd/minikube/cmd/start_flags.go b/cmd/minikube/cmd/start_flags.go index 3ecbfff8c8..e59beae662 100644 --- a/cmd/minikube/cmd/start_flags.go +++ b/cmd/minikube/cmd/start_flags.go @@ -91,6 +91,7 @@ const ( dryRun = "dry-run" interactive = "interactive" waitTimeout = "wait-timeout" + startHostTimeout = "starthost-timeout" nativeSSH = "native-ssh" minUsableMem = 1024 // Kubernetes will not start with less than 1GB minRecommendedMem = 2000 // Warn at no lower than existing configurations @@ -114,7 +115,6 @@ func initMinikubeFlags() { // e.g. iso-url => $ENVPREFIX_ISO_URL viper.SetEnvKeyReplacer(strings.NewReplacer("-", "_")) viper.AutomaticEnv() - startCmd.Flags().Bool(force, false, "Force minikube to perform possibly dangerous operations") startCmd.Flags().Bool(interactive, true, "Allow user prompts for more information") startCmd.Flags().Bool(dryRun, false, "dry-run mode. Validates configuration, but does not mutate system state") @@ -137,6 +137,7 @@ func initMinikubeFlags() { startCmd.Flags().Bool(enableDefaultCNI, false, "DEPRECATED: Replaced by --cni=bridge") startCmd.Flags().String(cniFlag, "", "CNI plug-in to use. Valid options: auto, bridge, calico, cilium, flannel, kindnet, or path to a CNI manifest (default: auto)") startCmd.Flags().StringSlice(waitComponents, kverify.DefaultWaitList, fmt.Sprintf("comma separated list of Kubernetes components to verify and wait for after starting a cluster. defaults to %q, available options: %q . other acceptable values are 'all' or 'none', 'true' and 'false'", strings.Join(kverify.DefaultWaitList, ","), strings.Join(kverify.AllComponentsList, ","))) + startCmd.Flags().Duration(startHostTimeout, 4*time.Minute, "max time to wait per host to start.") 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.") @@ -309,6 +310,7 @@ func generateClusterConfig(cmd *cobra.Command, existing *config.ClusterConfig, k HostDNSResolver: viper.GetBool(hostDNSResolver), HostOnlyNicType: viper.GetString(hostOnlyNicType), NatNicType: viper.GetString(natNicType), + StartHostTimeout: viper.GetDuration(startHostTimeout), KubernetesConfig: config.KubernetesConfig{ KubernetesVersion: k8sVersion, ClusterName: ClusterFlagValue(), diff --git a/go.mod b/go.mod index 4b431d9c82..bb925b15ae 100644 --- a/go.mod +++ b/go.mod @@ -72,7 +72,6 @@ require ( github.com/zchee/go-vmnet v0.0.0-20161021174912-97ebf9174097 golang.org/x/build v0.0.0-20190927031335-2835ba2e683f golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37 - golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6 // indirect golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a golang.org/x/sys v0.0.0-20200523222454-059865788121 diff --git a/pkg/minikube/config/types.go b/pkg/minikube/config/types.go index 47df5d1480..42a3e5c26b 100644 --- a/pkg/minikube/config/types.go +++ b/pkg/minikube/config/types.go @@ -18,6 +18,7 @@ package config import ( "net" + "time" "github.com/blang/semver" ) @@ -68,6 +69,7 @@ type ClusterConfig struct { Nodes []Node Addons map[string]bool VerifyComponents map[string]bool // map of components to verify and wait for after start. + StartHostTimeout time.Duration } // KubernetesConfig contains the parameters used to configure the VM Kubernetes. diff --git a/pkg/minikube/machine/cluster_test.go b/pkg/minikube/machine/cluster_test.go index 80e5e7389e..a516509202 100644 --- a/pkg/minikube/machine/cluster_test.go +++ b/pkg/minikube/machine/cluster_test.go @@ -68,6 +68,7 @@ var defaultClusterConfig = config.ClusterConfig{ Driver: driver.Mock, DockerEnv: []string{"MOCK_MAKE_IT_PROVISION=true"}, Nodes: []config.Node{{Name: "minikube"}}, + StartHostTimeout: 4 * time.Minute, } func TestCreateHost(t *testing.T) { @@ -281,6 +282,7 @@ func TestStartHostConfig(t *testing.T) { Driver: driver.Mock, DockerEnv: []string{"FOO=BAR"}, DockerOpt: []string{"param=value"}, + StartHostTimeout: 4 * time.Minute, } h, _, err := StartHost(api, &cfg, &config.Node{Name: "minikube"}) diff --git a/pkg/minikube/machine/start.go b/pkg/minikube/machine/start.go index a52e2481f3..6ce3c7b387 100644 --- a/pkg/minikube/machine/start.go +++ b/pkg/minikube/machine/start.go @@ -157,7 +157,7 @@ func createHost(api libmachine.API, cfg *config.ClusterConfig, n *config.Node) ( cstart := time.Now() glog.Infof("libmachine.API.Create for %q (driver=%q)", cfg.Name, cfg.Driver) - if err := timedCreateHost(h, api, 4*time.Minute); err != nil { + if err := timedCreateHost(h, api, cfg.StartHostTimeout); err != nil { return nil, errors.Wrap(err, "creating host") } glog.Infof("duration metric: libmachine.API.Create for %q took %s", cfg.Name, time.Since(cstart)) diff --git a/site/content/en/docs/commands/start.md b/site/content/en/docs/commands/start.md index 75088e6a0e..65b355047b 100644 --- a/site/content/en/docs/commands/start.md +++ b/site/content/en/docs/commands/start.md @@ -87,6 +87,7 @@ minikube start [flags] --preload If set, download tarball of preloaded images if available to improve start time. Defaults to true. (default true) --registry-mirror strings Registry mirrors to pass to the Docker daemon --service-cluster-ip-range string The CIDR to be used for service cluster IPs. (default "10.96.0.0/12") + --starthost-timeout duration max time to wait per host to start. (default 4m0s) --uuid string Provide VM UUID to restore MAC address (hyperkit driver only) --vm Filter to use only VM Drivers --vm-driver driver DEPRECATED, use driver instead. From 9354d2c0e51bef355b4d8359d650f9ab4a1d839e Mon Sep 17 00:00:00 2001 From: Pablo Caderno Date: Tue, 11 Aug 2020 19:05:12 +1000 Subject: [PATCH 2/3] Removed extra flag add. Set default value if not specified by the user. Signed-off-by: Pablo Caderno --- cmd/minikube/cmd/start_flags.go | 6 ++---- pkg/minikube/machine/cluster_test.go | 2 -- pkg/minikube/machine/start.go | 3 +++ 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/cmd/minikube/cmd/start_flags.go b/cmd/minikube/cmd/start_flags.go index e59beae662..4cd92ce4b7 100644 --- a/cmd/minikube/cmd/start_flags.go +++ b/cmd/minikube/cmd/start_flags.go @@ -91,7 +91,6 @@ const ( dryRun = "dry-run" interactive = "interactive" waitTimeout = "wait-timeout" - startHostTimeout = "starthost-timeout" nativeSSH = "native-ssh" minUsableMem = 1024 // Kubernetes will not start with less than 1GB minRecommendedMem = 2000 // Warn at no lower than existing configurations @@ -137,8 +136,7 @@ func initMinikubeFlags() { startCmd.Flags().Bool(enableDefaultCNI, false, "DEPRECATED: Replaced by --cni=bridge") startCmd.Flags().String(cniFlag, "", "CNI plug-in to use. Valid options: auto, bridge, calico, cilium, flannel, kindnet, or path to a CNI manifest (default: auto)") startCmd.Flags().StringSlice(waitComponents, kverify.DefaultWaitList, fmt.Sprintf("comma separated list of Kubernetes components to verify and wait for after starting a cluster. defaults to %q, available options: %q . other acceptable values are 'all' or 'none', 'true' and 'false'", strings.Join(kverify.DefaultWaitList, ","), strings.Join(kverify.AllComponentsList, ","))) - startCmd.Flags().Duration(startHostTimeout, 4*time.Minute, "max time to wait per host to start.") - startCmd.Flags().Duration(waitTimeout, 6*time.Minute, "max time to wait per Kubernetes core services to be healthy.") + startCmd.Flags().Duration(waitTimeout, 6*time.Minute, "max time to wait per Kubernetes or host 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.") startCmd.Flags().Bool(installAddons, true, "If set, install addons. Defaults to true.") @@ -310,7 +308,7 @@ func generateClusterConfig(cmd *cobra.Command, existing *config.ClusterConfig, k HostDNSResolver: viper.GetBool(hostDNSResolver), HostOnlyNicType: viper.GetString(hostOnlyNicType), NatNicType: viper.GetString(natNicType), - StartHostTimeout: viper.GetDuration(startHostTimeout), + StartHostTimeout: viper.GetDuration(waitTimeout), KubernetesConfig: config.KubernetesConfig{ KubernetesVersion: k8sVersion, ClusterName: ClusterFlagValue(), diff --git a/pkg/minikube/machine/cluster_test.go b/pkg/minikube/machine/cluster_test.go index a516509202..80e5e7389e 100644 --- a/pkg/minikube/machine/cluster_test.go +++ b/pkg/minikube/machine/cluster_test.go @@ -68,7 +68,6 @@ var defaultClusterConfig = config.ClusterConfig{ Driver: driver.Mock, DockerEnv: []string{"MOCK_MAKE_IT_PROVISION=true"}, Nodes: []config.Node{{Name: "minikube"}}, - StartHostTimeout: 4 * time.Minute, } func TestCreateHost(t *testing.T) { @@ -282,7 +281,6 @@ func TestStartHostConfig(t *testing.T) { Driver: driver.Mock, DockerEnv: []string{"FOO=BAR"}, DockerOpt: []string{"param=value"}, - StartHostTimeout: 4 * time.Minute, } h, _, err := StartHost(api, &cfg, &config.Node{Name: "minikube"}) diff --git a/pkg/minikube/machine/start.go b/pkg/minikube/machine/start.go index 6ce3c7b387..afeaa3f071 100644 --- a/pkg/minikube/machine/start.go +++ b/pkg/minikube/machine/start.go @@ -157,6 +157,9 @@ func createHost(api libmachine.API, cfg *config.ClusterConfig, n *config.Node) ( cstart := time.Now() glog.Infof("libmachine.API.Create for %q (driver=%q)", cfg.Name, cfg.Driver) + if cfg.StartHostTimeout == 0 { + cfg.StartHostTimeout = 6 * time.Minute + } if err := timedCreateHost(h, api, cfg.StartHostTimeout); err != nil { return nil, errors.Wrap(err, "creating host") } From 0d7686a1e16922ba6bcd4436f581cd21e2983dd1 Mon Sep 17 00:00:00 2001 From: Pablo Caderno Date: Tue, 11 Aug 2020 19:08:27 +1000 Subject: [PATCH 3/3] updated documentation Signed-off-by: Pablo Caderno --- site/content/en/docs/commands/start.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/site/content/en/docs/commands/start.md b/site/content/en/docs/commands/start.md index 65b355047b..22aae361d2 100644 --- a/site/content/en/docs/commands/start.md +++ b/site/content/en/docs/commands/start.md @@ -87,12 +87,11 @@ minikube start [flags] --preload If set, download tarball of preloaded images if available to improve start time. Defaults to true. (default true) --registry-mirror strings Registry mirrors to pass to the Docker daemon --service-cluster-ip-range string The CIDR to be used for service cluster IPs. (default "10.96.0.0/12") - --starthost-timeout duration max time to wait per host to start. (default 4m0s) --uuid string Provide VM UUID to restore MAC address (hyperkit driver only) --vm Filter to use only VM Drivers --vm-driver driver DEPRECATED, use driver instead. --wait strings comma separated list of Kubernetes components to verify and wait for after starting a cluster. defaults to "apiserver,system_pods", available options: "apiserver,system_pods,default_sa,apps_running,node_ready" . other acceptable values are 'all' or 'none', 'true' and 'false' (default [apiserver,system_pods]) - --wait-timeout duration max time to wait per Kubernetes core services to be healthy. (default 6m0s) + --wait-timeout duration max time to wait per Kubernetes or host to be healthy. (default 6m0s) ``` ### Options inherited from parent commands