fix: scope Pimox capacity gate to app deployments
Homelab Main / validate (push) Waiting to run Details
Homelab Main / running-update (push) Blocked by required conditions Details
Homelab Main / debian-ops (push) Blocked by required conditions Details

This commit is contained in:
juvenal.diaz 2026-10-21 20:50:07 -06:00
parent 20e98064e0
commit 1bb0e4f6f6
1 changed files with 12 additions and 3 deletions

View File

@ -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}"