From 8e7d0f43a9b589ea8b9d2123707e180381056ee9 Mon Sep 17 00:00:00 2001 From: Enrico Candino Date: Wed, 4 Dec 2024 20:44:43 +0100 Subject: [PATCH] changed cluster creation backoff (#156) --- cli/cmds/cluster/create.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/cli/cmds/cluster/create.go b/cli/cmds/cluster/create.go index 575f4cc..159dd2b 100644 --- a/cli/cmds/cluster/create.go +++ b/cli/cmds/cluster/create.go @@ -7,6 +7,7 @@ import ( "os" "path/filepath" "strings" + "time" "github.com/rancher/k3k/cli/cmds" "github.com/rancher/k3k/pkg/apis/k3k.io/v1alpha1" @@ -20,6 +21,7 @@ import ( apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/util/wait" "k8s.io/apiserver/pkg/authentication/user" clientgoscheme "k8s.io/client-go/kubernetes/scheme" "k8s.io/client-go/tools/clientcmd" @@ -183,9 +185,17 @@ func create(clx *cli.Context) error { ORG: []string{user.SystemPrivilegedGroup}, ExpiryDate: 0, } + logrus.Infof("waiting for cluster to be available..") + + // retry every 5s for at most 2m + availableBackoff := wait.Backoff{ + Duration: 5 * time.Second, + Cap: 2 * time.Minute, + } + var kubeconfig []byte - if err := retry.OnError(controller.Backoff, apierrors.IsNotFound, func() error { + if err := retry.OnError(availableBackoff, apierrors.IsNotFound, func() error { kubeconfig, err = cfg.Extract(ctx, ctrlClient, cluster, host[0]) if err != nil { return err