Skip to content

Commit

Permalink
make clusterapi wait timeout configurable (#865)
Browse files Browse the repository at this point in the history
add an environment to make timeout configurable
for timeoutMachineReady
  • Loading branch information
jichenjc authored and k8s-ci-robot committed Apr 9, 2019
1 parent b03dc0e commit 3534230
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
3 changes: 3 additions & 0 deletions cmd/clusterctl/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand Down
16 changes: 15 additions & 1 deletion cmd/clusterctl/clusterdeployer/clusterclient/clusterclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 3534230

Please sign in to comment.