mirror of
https://github.com/Alkatrazz24/Funk-lab.git
synced 2026-07-08 10:14:42 +02:00
fix(funk-cluster): grep -c bug + uncordon automatique au démarrage
- check_k8s_pods : grep -c retournait "0\n0" (|| echo 0 inutile quand grep-c affiche 0 même en cas d'absence de match) — utilise un cache intermédiaire pods_output + running=$(grep -c) || running=0 - cmd_start : uncordon automatique si nœuds SchedulingDisabled détectés (séquelle d'un funk-stop --k8s), suivi d'une attente pod infra avant le check — évite de devoir passer --k8s juste pour débloquer le cluster Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
494184b025
commit
f937c2589d
1 changed files with 28 additions and 7 deletions
|
|
@ -152,20 +152,20 @@ check_k8s() {
|
||||||
|
|
||||||
check_k8s_pods() {
|
check_k8s_pods() {
|
||||||
local ns=$1 label=$2
|
local ns=$1 label=$2
|
||||||
local total running
|
local pods_output total running
|
||||||
total=$($KUBECTL get pods -n "$ns" --no-headers 2>/dev/null | wc -l)
|
pods_output=$($KUBECTL get pods -n "$ns" --no-headers 2>/dev/null)
|
||||||
running=$($KUBECTL get pods -n "$ns" --no-headers 2>/dev/null | grep -c "^[^ ]* *[0-9]*/[0-9]* *Running" || echo 0)
|
if [ -z "$pods_output" ]; then
|
||||||
|
|
||||||
if [ "$total" -eq 0 ]; then
|
|
||||||
warn "$label — namespace vide ou inaccessible"
|
warn "$label — namespace vide ou inaccessible"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
total=$(echo "$pods_output" | wc -l)
|
||||||
|
running=$(echo "$pods_output" | grep -c " Running ") || running=0
|
||||||
|
|
||||||
if [ "$running" -eq "$total" ]; then
|
if [ "$running" -eq "$total" ]; then
|
||||||
check_ok "$label — $running/$total Running"
|
check_ok "$label — $running/$total Running"
|
||||||
else
|
else
|
||||||
check_fail "$label — $running/$total Running"
|
check_fail "$label — $running/$total Running"
|
||||||
$KUBECTL get pods -n "$ns" --no-headers 2>/dev/null \
|
echo "$pods_output" \
|
||||||
| grep -v " Running " \
|
| grep -v " Running " \
|
||||||
| awk '{printf " %-45s %s\n", $1, $3}' \
|
| awk '{printf " %-45s %s\n", $1, $3}' \
|
||||||
| head -6
|
| head -6
|
||||||
|
|
@ -419,11 +419,32 @@ cmd_start() {
|
||||||
|
|
||||||
if [ $k8s_up -gt 0 ]; then
|
if [ $k8s_up -gt 0 ]; then
|
||||||
local ready
|
local ready
|
||||||
ready=$($KUBECTL get nodes --no-headers 2>/dev/null | grep -c " Ready" || echo 0)
|
ready=$($KUBECTL get nodes --no-headers 2>/dev/null | grep -c " Ready") || ready=0
|
||||||
echo ""
|
echo ""
|
||||||
echo "[ cluster k8s — santé pods ]"
|
echo "[ cluster k8s — santé pods ]"
|
||||||
if [ "$ready" -gt 0 ]; then
|
if [ "$ready" -gt 0 ]; then
|
||||||
check_ok "Nœuds — $ready/3 Ready"
|
check_ok "Nœuds — $ready/3 Ready"
|
||||||
|
|
||||||
|
# Uncordon automatique si nœuds SchedulingDisabled (séquelle d'un funk-stop --k8s)
|
||||||
|
local uncordoned=0
|
||||||
|
for name in "${K8S_NAMES[@]}"; do
|
||||||
|
if $KUBECTL get node "$name" --no-headers 2>/dev/null | grep -q "SchedulingDisabled"; then
|
||||||
|
$KUBECTL uncordon "$name" 2>/dev/null && ok "$name — uncordonné" || true
|
||||||
|
uncordoned=$((uncordoned + 1))
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# Après uncordon : attendre que les pods infra se re-schedulisent
|
||||||
|
if [ $uncordoned -gt 0 ]; then
|
||||||
|
info "Attente déploiement pods après uncordon (jusqu'à 2 min)..."
|
||||||
|
local sched_elapsed=0
|
||||||
|
until [ "$($KUBECTL get pods -n infra --no-headers 2>/dev/null | grep -c " Running ")" -ge 1 ] \
|
||||||
|
|| [ $sched_elapsed -ge 120 ]; do
|
||||||
|
sleep 10; sched_elapsed=$((sched_elapsed + 10))
|
||||||
|
echo -ne " → Attente pods... ${sched_elapsed}s\r"
|
||||||
|
done; echo ""
|
||||||
|
fi
|
||||||
|
|
||||||
check_k8s_workloads
|
check_k8s_workloads
|
||||||
else
|
else
|
||||||
warn "Nœuds joignables mais pas encore Ready"
|
warn "Nœuds joignables mais pas encore Ready"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue