diff --git a/cmd/clusterctl/README.md b/cmd/clusterctl/README.md index 42b63ebe3c85..5b3147030417 100644 --- a/cmd/clusterctl/README.md +++ b/cmd/clusterctl/README.md @@ -61,6 +61,9 @@ https://github.com/kubernetes-sigs/cluster-api/issues/158 and https://github.com Additional advanced flags can be found via help. +Also, some environment variables are supported: +`CLUSTER_API_MACHINE_READY_TIMEOUT`: set this value to adjust the timeout value in minutes for a machine to become ready, The default timeout is currently 30 minutes, `export CLUSTER_API_MACHINE_READY_TIMEOUT=45` will extend the timeout value to 45 minutes. + ```shell ./clusterctl create cluster --help ``` diff --git a/cmd/clusterctl/clusterdeployer/clusterclient/clusterclient.go b/cmd/clusterctl/clusterdeployer/clusterclient/clusterclient.go index bc4fcf4a38d0..5e955a0ec978 100644 --- a/cmd/clusterctl/clusterdeployer/clusterclient/clusterclient.go +++ b/cmd/clusterctl/clusterdeployer/clusterclient/clusterclient.go @@ -55,6 +55,10 @@ const ( machineClusterLabelName = "cluster.k8s.io/cluster-name" ) +const ( + TimeoutMachineReady = "CLUSTER_API_MACHINE_READY_TIMEOUT" +) + // Provides interaction with a cluster type Client interface { Apply(string) error @@ -968,7 +972,17 @@ func waitForClusterResourceReady(cs clientset.Interface) error { } func waitForMachineReady(cs clientset.Interface, machine *clusterv1.Machine) error { - err := util.PollImmediate(retryIntervalResourceReady, timeoutMachineReady, func() (bool, error) { + timeout := timeoutMachineReady + if p := os.Getenv(TimeoutMachineReady); p != "" { + t, err := strconv.Atoi(p) + if err == nil { + // only valid value will be used + timeout = time.Duration(t) * time.Minute + klog.V(4).Info("Setting wait for machine timeout value to ", timeout) + } + } + + err := util.PollImmediate(retryIntervalResourceReady, timeout, func() (bool, error) { klog.V(2).Infof("Waiting for Machine %v to become ready...", machine.Name) m, err := cs.ClusterV1alpha1().Machines(machine.Namespace).Get(machine.Name, metav1.GetOptions{}) if err != nil {