From a85e3e1462e1f09889b1b835647a6ba880cdb2fd Mon Sep 17 00:00:00 2001 From: Yury Kovalev Date: Mon, 22 Dec 2025 13:10:46 +0100 Subject: [PATCH] fix(e2e-tests): wait for status.conditions to exist before using kubectl wait --- dev/env/scripts/lib.sh | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/dev/env/scripts/lib.sh b/dev/env/scripts/lib.sh index 1a59f3f6d1..818cf0adc5 100644 --- a/dev/env/scripts/lib.sh +++ b/dev/env/scripts/lib.sh @@ -290,35 +290,33 @@ wait_for_cluster_resource_to_appear() { return 1 } +wait_for_crd() { + local name="$1" + local seconds="${2:-180}" -wait_for_resource_condition() { - local namespace="$1" - local kind="$2" - local name="$3" - local condition="$4" - - if ! wait_for_resource_to_appear "${namespace}" "${kind}" "${name}"; then + # First wait for the CRD to appear + if ! wait_for_cluster_resource_to_appear crd "${name}"; then return 1 fi - log "Waiting for ${kind}/${name} in namespace ${namespace} to have status ${condition}" - $KUBECTL -n "${namespace}" wait --for="${condition}" --timeout="3m" "${kind}/${name}" -} -wait_for_cluster_resource_condition() { - local kind="$1" - local name="$2" - local condition="$3" + log "Waiting for crd/${name} status.conditions to appear" + # Wait for status.conditions to exist before using kubectl wait + for _ in $(seq "$seconds"); do + local conditions + conditions=$($KUBECTL get crd "${name}" -o jsonpath='{.status.conditions}' 2>/dev/null || echo "") + if [[ -n "$conditions" && "$conditions" != "[]" ]]; then + log "crd/${name} status.conditions appeared, waiting for established condition" + break + fi + sleep 1 + done - if ! wait_for_cluster_resource_to_appear "${kind}" "${name}"; then + if [[ -z "$conditions" || "$conditions" == "[]" ]]; then + log "Giving up after ${seconds}s waiting for crd/${name} status.conditions to appear" return 1 fi - log "Waiting for ${kind}/${name} to have status ${condition}" - $KUBECTL wait --for "${condition}" --timeout="3m" "${kind}/${name}" -} -wait_for_crd() { - local name="$1" - wait_for_cluster_resource_condition crd "$name" "jsonpath={.status.conditions[?(@.type==\"Established\")].status}=True" + $KUBECTL wait --for "condition=established" --timeout="3m" "crd/${name}" } assemble_kubeconfig() {