Commit 6db5739f authored by Vitaly Lipatov's avatar Vitaly Lipatov

route-update.sh: zero-downtime route reload without flush

Replace flush+load with replace-all+remove-stale approach: routes are never missing during reload. Add post-update route count verification. Co-Authored-By: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
parent 061132a4
......@@ -452,10 +452,26 @@ process_routes()
continue
fi
# Flush and load via batch
$ipcmd route flush table "$table" 2>/dev/null
# Zero-downtime reload: replace all, then remove stale
sed "s|^|route replace |; s|$| $route_via|" "$resolved_new" | \
$ipcmd -batch - 2>&1 | grep -v "^$" | head -5
local stale=$(mktemp)
$ipcmd route show table "$table" 2>/dev/null | awk '{print $1}' | sort | \
comm -23 - "$resolved_new" > "$stale"
if [ -s "$stale" ] ; then
vlog "[$name]$label removing $(wc -l < "$stale") stale routes"
sed "s|^|route del |; s|$| table $table|" "$stale" | \
$ipcmd -batch - 2>/dev/null
fi
rm -f "$stale"
# Verify route count matches expected
local actual=$($ipcmd route show table "$table" 2>/dev/null | wc -l)
if [ "$actual" != "$count" ] ; then
log "[$name]$label WARNING: route count mismatch: expected $count, got $actual"
else
vlog "[$name]$label route count OK: $actual"
fi
# Ensure ip rule exists
if ! $ipcmd -N rule show | grep -q "lookup $table.*pref $pref" ; then
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment