Archived
fix(ha/cluster-init): detect StandAlone DRBD state in sync wait loop
Check NixOS configurations / eval-hosts (push) Successful in 10m21s
Check NixOS configurations / eval-hosts (push) Successful in 10m21s
If the DRBD peer connection drops during the initial sync wait (cs:StandAlone), the loop would spin forever printing "waiting for sync progress" with no indication of what's wrong. Now parses cs: from /proc/drbd each tick and dies with a clear error if StandAlone is detected. Also shows the cs: field in the non-syncing message so the actual connection state is always visible. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -250,17 +250,23 @@ while true; do
|
|||||||
log "DRBD initial sync complete (dstate: $_dstate)"
|
log "DRBD initial sync complete (dstate: $_dstate)"
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
|
# Parse connection state from /proc/drbd (cs:SyncSource, cs:Connected, cs:StandAlone …)
|
||||||
|
_cs=$(grep -oE 'cs:[A-Za-z]+' /proc/drbd 2>/dev/null | head -1 | sed 's/cs://' || echo "unknown")
|
||||||
# /proc/drbd uses variable whitespace: "sync'ed: 5.2%" (two spaces).
|
# /proc/drbd uses variable whitespace: "sync'ed: 5.2%" (two spaces).
|
||||||
_pct=$(grep -oE "sync'ed:[[:space:]]+[0-9.]+" /proc/drbd 2>/dev/null | grep -oE "[0-9.]+" | head -1 || echo "")
|
_pct=$(grep -oE "sync'ed:[[:space:]]+[0-9.]+" /proc/drbd 2>/dev/null | grep -oE "[0-9.]+" | head -1 || echo "")
|
||||||
_eta=$(grep -oE "finish:[[:space:]]+[0-9:]+" /proc/drbd 2>/dev/null | grep -oE "[0-9:]+$" | head -1 || echo "")
|
_eta=$(grep -oE "finish:[[:space:]]+[0-9:]+" /proc/drbd 2>/dev/null | grep -oE "[0-9:]+$" | head -1 || echo "")
|
||||||
_spd=$(grep -oE "speed:[[:space:]]+[0-9,]+" /proc/drbd 2>/dev/null | grep -oE "[0-9,]+$" | head -1 || echo "")
|
_spd=$(grep -oE "speed:[[:space:]]+[0-9,]+" /proc/drbd 2>/dev/null | grep -oE "[0-9,]+$" | head -1 || echo "")
|
||||||
_sync_iter=$(( _sync_iter + 1 ))
|
_sync_iter=$(( _sync_iter + 1 ))
|
||||||
_sc="${_sync_chars[$_sync_iter % 4]}"
|
_sc="${_sync_chars[$_sync_iter % 4]}"
|
||||||
if [[ -n "$_pct" ]]; then
|
if [[ "$_cs" == "StandAlone" ]]; then
|
||||||
|
printf "\r%-80s\r" ""
|
||||||
|
die "DRBD is StandAlone — peer connection lost (dstate: $_dstate). " \
|
||||||
|
"Check corosync/network and re-run cluster-init."
|
||||||
|
elif [[ -n "$_pct" ]]; then
|
||||||
printf "\r [%s] syncing: %s%% done — ETA %s @ %s K/s " \
|
printf "\r [%s] syncing: %s%% done — ETA %s @ %s K/s " \
|
||||||
"$_sc" "$_pct" "${_eta:-??:??:??}" "${_spd:-?}"
|
"$_sc" "$_pct" "${_eta:-??:??:??}" "${_spd:-?}"
|
||||||
else
|
else
|
||||||
printf "\r [%s] dstate: %s — waiting for sync progress " "$_sc" "$_dstate"
|
printf "\r [%s] cs:%s dstate:%s — waiting for sync to start " "$_sc" "$_cs" "$_dstate"
|
||||||
fi
|
fi
|
||||||
sleep 3
|
sleep 3
|
||||||
done
|
done
|
||||||
|
|||||||
Reference in New Issue
Block a user