From 60d8f34095dc0bdd365ec05fca5790c0fd8123a0 Mon Sep 17 00:00:00 2001 From: Zahari Dichev Date: Mon, 12 Oct 2020 18:26:00 +0300 Subject: [PATCH] avoid waiting when creating calico cluster with kind (#5064) Currently the --wait flag times out when creating a calico cluster. The result is that we end up waiting for 5 minutes to simply emit a warning and continue. Instead we can check the readiness of some k8s components to ensure our cluster is up and running and avoid the delay. Signed-off-by: Zahari Dichev zaharidichev@gmail.com --- bin/_test-helpers.sh | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/bin/_test-helpers.sh b/bin/_test-helpers.sh index f4fca770f..8bb7b5d3e 100644 --- a/bin/_test-helpers.sh +++ b/bin/_test-helpers.sh @@ -138,7 +138,29 @@ check_linkerd_binary() { create_kind_cluster() { local name=$1 local config=$2 - "$bindir"/kind create cluster --name "$name" --config "$test_directory"/configs/"$config".yaml --wait 300s 2>&1 + if [ "$config" = "cni-calico" ]; then + # this is a workaround the fact that the --wait + # flag always times out with the calico setup + # the result of that is that we are always + # wasting 5m on this job + # issue: https://github.com/kubernetes-sigs/kind/issues/1889 + cp_pod="kube-apiserver-cni-calico-deep-control-plane" + cm_pod="kube-controller-manager-cni-calico-deep-control-plane" + ks_pod="kube-scheduler-cni-calico-deep-control-plane" + etcd_pod="etcd-cni-calico-deep-control-plane" + + "$bindir"/kind create cluster --name "$name" --config "$test_directory"/configs/"$config".yaml 2>&1 + echo 'Waiting for api server' + kubectl --context="$context" -n kube-system wait --for=condition=initialized --timeout=120s pod/"$cp_pod" > /dev/null 2>&1 + echo 'Waiting for kube controller' + kubectl --context="$context" -n kube-system wait --for=condition=initialized --timeout=120s pod/"$cm_pod" > /dev/null 2>&1 + echo 'Waiting for kube scheduler' + kubectl --context="$context" -n kube-system wait --for=condition=initialized --timeout=120s pod/"$ks_pod" > /dev/null 2>&1 + echo 'Waiting for kube etcd' + kubectl --context="$context" -n kube-system wait --for=condition=initialized --timeout=120s pod/"$etcd_pod" > /dev/null 2>&1 + else + "$bindir"/kind create cluster --name "$name" --config "$test_directory"/configs/"$config".yaml --wait 300s 2>&1 + fi exit_on_err 'error creating KinD cluster' export context="kind-$name" }