diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index 8f66a2a..e9f74bb 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -256,6 +256,10 @@ jobs: local timeout_seconds="$4" local elapsed=0 local handled + local ready + local healthy + local generation + local observed_generation while [ "${elapsed}" -lt "${timeout_seconds}" ]; do handled="$(kubectl -n "${namespace}" get "${resource}" -o jsonpath='{.status.lastHandledReconcileAt}' 2>/dev/null || true)" @@ -267,6 +271,18 @@ jobs: elapsed=$((elapsed + 5)) done + ready="$(kubectl -n "${namespace}" get "${resource}" -o jsonpath='{.status.conditions[?(@.type=="Ready")].status}' 2>/dev/null || true)" + healthy="$(kubectl -n "${namespace}" get "${resource}" -o jsonpath='{.status.conditions[?(@.type=="Healthy")].status}' 2>/dev/null || true)" + generation="$(kubectl -n "${namespace}" get "${resource}" -o jsonpath='{.metadata.generation}' 2>/dev/null || true)" + observed_generation="$(kubectl -n "${namespace}" get "${resource}" -o jsonpath='{.status.observedGeneration}' 2>/dev/null || true)" + + if [ "${ready}" = "True" ] && [ "${observed_generation}" = "${generation}" ]; then + if [ -z "${healthy}" ] || [ "${healthy}" = "True" ]; then + echo "${resource} did not report reconcile ${reconcile_at}, but it is already Ready; continuing" + return 0 + fi + fi + echo "Timed out waiting for ${resource} to handle reconcile ${reconcile_at}" >&2 kubectl -n "${namespace}" describe "${resource}" || true exit 1 @@ -603,6 +619,10 @@ jobs: local timeout_seconds="$4" local elapsed=0 local handled + local ready + local healthy + local generation + local observed_generation while [ "${elapsed}" -lt "${timeout_seconds}" ]; do handled="$(kubectl -n "${namespace}" get "${resource}" -o jsonpath='{.status.lastHandledReconcileAt}' 2>/dev/null || true)" @@ -614,6 +634,18 @@ jobs: elapsed=$((elapsed + 5)) done + ready="$(kubectl -n "${namespace}" get "${resource}" -o jsonpath='{.status.conditions[?(@.type=="Ready")].status}' 2>/dev/null || true)" + healthy="$(kubectl -n "${namespace}" get "${resource}" -o jsonpath='{.status.conditions[?(@.type=="Healthy")].status}' 2>/dev/null || true)" + generation="$(kubectl -n "${namespace}" get "${resource}" -o jsonpath='{.metadata.generation}' 2>/dev/null || true)" + observed_generation="$(kubectl -n "${namespace}" get "${resource}" -o jsonpath='{.status.observedGeneration}' 2>/dev/null || true)" + + if [ "${ready}" = "True" ] && [ "${observed_generation}" = "${generation}" ]; then + if [ -z "${healthy}" ] || [ "${healthy}" = "True" ]; then + echo "${resource} did not report reconcile ${reconcile_at}, but it is already Ready; continuing" + return 0 + fi + fi + echo "Timed out waiting for ${resource} to handle reconcile ${reconcile_at}" >&2 kubectl -n "${namespace}" describe "${resource}" || true exit 1