From 5e438f1c10af69016c3009b42571b3e5753ee8f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Gr=C3=A4ff?= Date: Mon, 9 Sep 2024 07:42:01 +0200 Subject: [PATCH] Ingress readiness check in integration tests (#1225) * Check if ingress is ready (run-int-tests) * Check if ingress is ready (run-int-tests) --- hack/int-test-helper/install-landscaper-dual | 42 ++++++++++++++++---- 1 file changed, 35 insertions(+), 7 deletions(-) diff --git a/hack/int-test-helper/install-landscaper-dual b/hack/int-test-helper/install-landscaper-dual index 063e8b5483..039312306b 100755 --- a/hack/int-test-helper/install-landscaper-dual +++ b/hack/int-test-helper/install-landscaper-dual @@ -46,13 +46,13 @@ if [[ -z $TARGET_SHOOT_KUBECONFIG_PATH ]]; then exit 1 fi -if [[ -z RESOURCE_SHOOT_KUBECONFIG_PATH ]]; then +if [[ -z $RESOURCE_SHOOT_KUBECONFIG_PATH ]]; then echo "Resource shoot kubeconfig path (-r) is required" >&2 print_help exit 1 fi -if [[ -z INGRESS_URL ]]; then +if [[ -z $INGRESS_URL ]]; then echo "Ingress url (-i) is required" >&2 print_help exit 1 @@ -190,25 +190,53 @@ helm upgrade --kubeconfig="${TARGET_SHOOT_KUBECONFIG_PATH}" --install --wait --c -f "${WORKDIR}/landscaper-controller-values.yaml" -f "${WORKDIR}/registry-values.yaml" landscaper-controller "${WORKDIR}/landscaper-controller" +# Wait until landscaper and the ingress for the webhook are ready. +# To allow retries, we must not exit at the first error. +set +e + echo "> Wait for Landscaper being ready" -landscaper_ready=false retries_left=20 -while [ "$landscaper_ready" = false ]; do +while true; do + echo "Is landscaper ready: ${retries_left} tries left" kubectl --kubeconfig="${RESOURCE_SHOOT_KUBECONFIG_PATH}" get customresourcedefinitions.apiextensions.k8s.io deployitems.landscaper.gardener.cloud if [ "$?" = 0 ]; then - landscaper_ready=true + echo "Landscaper is ready" + break fi - if [ "retries_left" == 0 ]; then - >&2 echo "landscaper is not ready after max retries" + retries_left="$((${retries_left}-1))" + if [ "${retries_left}" -eq 0 ]; then + >&2 echo "Landscaper is not ready after max retries" exit 1 fi + sleep 1 +done + + +echo "> Wait for ingress being ready: ${INGRESS_URL}" +retries_left=300 + +while true; do + echo "Is ingress ready: ${retries_left} tries left" + loadbalancer_ip=$(kubectl --kubeconfig="${TARGET_SHOOT_KUBECONFIG_PATH}" get ingress -n ls-system landscaper-controller-webhooks -o jsonpath='{.status.loadBalancer.ingress[0].ip}') + if [ "$?" = 0 -a -n "${loadbalancer_ip}" ]; then + echo "Ingress is ready" + break + fi + retries_left="$((${retries_left}-1))" + if [ "${retries_left}" -eq 0 ]; then + >&2 echo "Ingress is not ready after max retries" + exit 1 + fi + sleep 1 done +set -e + echo "> Deploy Helm Deployer" ocm get resources --repo $OCI_REPO "${COMPONENT_NAME}/helm-deployer:${LANDSCAPER_VERSION}" helm-deployer-image -o json > "${WORKDIR}/helm-deployer-image-resource.json"