From 505bb379718d48270cc644748bfddc4ef8da9c57 Mon Sep 17 00:00:00 2001 From: "juvenal.diaz" Date: Mon, 5 Oct 2026 13:52:09 -0600 Subject: [PATCH] fix: verify app rollouts after image updates --- lib/jeannie/pipeline.sh | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/lib/jeannie/pipeline.sh b/lib/jeannie/pipeline.sh index 3258f4e..576e0da 100644 --- a/lib/jeannie/pipeline.sh +++ b/lib/jeannie/pipeline.sh @@ -4641,6 +4641,13 @@ wait_for_deployment_ready() { desired_replicas="$(kubectl --kubeconfig "${KUBECONFIG_PATH}" -n "${namespace}" get deployment "${deployment}" -o jsonpath='{.spec.replicas}' 2>/dev/null || true)" desired_replicas="${desired_replicas:-1}" + if ! kubectl --kubeconfig "${KUBECONFIG_PATH}" -n "${namespace}" rollout status "deployment/${deployment}" --timeout="${timeout_seconds}s"; then + echo "Timed out waiting for deployment/${deployment} rollout in namespace ${namespace}" >&2 + dump_argocd_debug "${app}" + dump_namespace_debug "${namespace}" + exit 1 + fi + until ready_replicas="$(kubectl --kubeconfig "${KUBECONFIG_PATH}" -n "${namespace}" get deployment "${deployment}" -o jsonpath='{.status.readyReplicas}' 2>/dev/null)"; \ (( ${ready_replicas:-0} >= desired_replicas )); do if ((elapsed >= timeout_seconds)); then @@ -4654,6 +4661,27 @@ wait_for_deployment_ready() { done } +cleanup_disabled_deployment_pods() { + local namespace="$1" + local deployment="$2" + local selector="$3" + local app="$4" + local desired_replicas + + desired_replicas="$(kubectl --kubeconfig "${KUBECONFIG_PATH}" -n "${namespace}" get deployment "${deployment}" -o jsonpath='{.spec.replicas}' 2>/dev/null || true)" + if [[ "${desired_replicas:-0}" != "0" ]]; then + return 0 + fi + + echo "Cleaning up stale pods for disabled deployment/${deployment} in namespace ${namespace}." + if ! kubectl --kubeconfig "${KUBECONFIG_PATH}" -n "${namespace}" delete pod -l "${selector}" --ignore-not-found --wait=true --timeout=120s; then + echo "Failed to clean up stale pods for deployment/${deployment} in namespace ${namespace}" >&2 + dump_argocd_debug "${app}" + dump_namespace_debug "${namespace}" + exit 1 + fi +} + deploy_gitea() { local mode="${LAB_GITEA_DEPLOY:-true}" local gitea_host="${LAB_GITEA_HOST:-${LAB_DEBIAN_LAN_IP:-192.168.100.73}}" @@ -6783,7 +6811,10 @@ apps() { apply_gitea_runner_secret_file refresh_argocd_application gitea-runner if [[ "${LAB_CLUSTER_PROFILE:-debian}" == "pimox" ]] && ! truthy "${LAB_APPS_WAIT_GITEA_RUNNER_ON_PIMOX:-false}"; then - echo "Skipping Gitea Kubernetes runner readiness on Pimox; the current runner manifest needs a Docker socket and is tracked as a follow-up." + wait_for_namespace gitea-runner gitea-runner "${app_resource_wait_seconds}" + wait_for_namespaced_resource gitea-runner deployment gitea-runner gitea-runner "${app_resource_wait_seconds}" + cleanup_disabled_deployment_pods gitea-runner gitea-runner app=gitea-runner gitea-runner + echo "Skipping Gitea Kubernetes runner readiness on Pimox; the current runner manifest needs a Docker socket and is kept scaled down." else wait_for_namespace gitea-runner gitea-runner "${app_resource_wait_seconds}" wait_for_namespaced_resource gitea-runner deployment gitea-runner gitea-runner "${app_resource_wait_seconds}"