From 1bb0e4f6f66e72d3fb00576997a51a15722bb3aa Mon Sep 17 00:00:00 2001 From: "juvenal.diaz" Date: Wed, 21 Oct 2026 20:50:07 -0600 Subject: [PATCH] fix: scope Pimox capacity gate to app deployments --- lib/jeannie/pipeline.sh | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/jeannie/pipeline.sh b/lib/jeannie/pipeline.sh index bcfb3bc..6f7baf7 100644 --- a/lib/jeannie/pipeline.sh +++ b/lib/jeannie/pipeline.sh @@ -6837,6 +6837,7 @@ require_argocd_application_controller() { } require_pimox_app_worker_capacity() { + local scope="${1:-all}" local enabled="${LAB_PIMOX_APP_DEPLOY_REQUIRE_CAPACITY:-true}" local spec_file="${REPO_ROOT}/.lab/pimox-workers.tsv" local minimum_cpus="${LAB_PIMOX_APP_DEPLOY_MIN_CPUS:-2}" @@ -6848,6 +6849,7 @@ require_pimox_app_worker_capacity() { local capacity local ready local failures=0 + local eligible_workers=0 if disabled_value "${enabled}"; then echo "Skipping Pimox worker CPU gate because LAB_PIMOX_APP_DEPLOY_REQUIRE_CAPACITY=${enabled}." @@ -6866,17 +6868,24 @@ require_pimox_app_worker_capacity() { [[ -n "${worker_node}" ]] || continue capacity="$(kubectl --kubeconfig "${KUBECONFIG_PATH}" get node "${worker_node}" -o jsonpath='{.status.capacity.cpu}' 2>/dev/null || true)" ready="$(kubectl --kubeconfig "${KUBECONFIG_PATH}" get node "${worker_node}" -o jsonpath='{.status.conditions[?(@.type=="Ready")].status}' 2>/dev/null || true)" - if [[ "${ready}" != "True" ]] || ! [[ "${capacity}" =~ ^[0-9]+$ ]] || ((capacity < minimum_cpus)); then + if [[ "${ready}" == "True" ]] && [[ "${capacity}" =~ ^[0-9]+$ ]] && ((capacity >= minimum_cpus)); then + eligible_workers=$((eligible_workers + 1)) + elif [[ "${scope}" == "all" ]]; then echo "Pimox worker ${worker_node} must be Ready with at least ${minimum_cpus} Kubernetes CPU(s); Ready=${ready:-missing}, capacity=${capacity:-missing}." >&2 failures=$((failures + 1)) fi done <"${spec_file}" - if ((failures > 0)); then + if [[ "${scope}" == "all" ]] && ((failures > 0)); then echo "Refusing to deploy applications until Pimox workers expose the required Kubernetes CPU capacity." >&2 kubectl --kubeconfig "${KUBECONFIG_PATH}" get nodes -o custom-columns='NAME:.metadata.name,CPUS:.status.capacity.cpu,READY:.status.conditions[?(@.type=="Ready")].status' >&2 || true exit 1 fi + if [[ "${scope}" != "all" ]] && ((eligible_workers == 0)); then + echo "Refusing to deploy ${scope}: no Ready Pimox worker exposes at least ${minimum_cpus} Kubernetes CPU(s)." >&2 + kubectl --kubeconfig "${KUBECONFIG_PATH}" get nodes -o custom-columns='NAME:.metadata.name,CPUS:.status.capacity.cpu,READY:.status.conditions[?(@.type=="Ready")].status' >&2 || true + exit 1 + fi } ensure_pimox_kubeconfig() { @@ -7515,7 +7524,7 @@ apps() { ensure_pimox_kubeconfig require_argocd_application_controller - require_pimox_app_worker_capacity + require_pimox_app_worker_capacity "${app_selector}" if [[ "${deploy_website}" == "true" || "${deploy_demos}" == "true" || "${deploy_registry}" == "true" ]]; then ensure_pimox_registry_storage_path ensure_pimox_registry_endpoint_forwarding "${registry_endpoint}"