diff --git a/migration/vyos-unifi-switch b/migration/vyos-unifi-switch index c4e1d67..945ceed 100755 --- a/migration/vyos-unifi-switch +++ b/migration/vyos-unifi-switch @@ -224,8 +224,32 @@ to_vyos() { fi rm -f "$tmp" - say "committed. Waiting 25s for PPPoE and services to settle..." - sleep 25 + # Poll, do not sample once. + # + # A cutover attempt failed here on a fixed 25s wait. That is far too short for + # a WAN: PPPoE is PADI/PADO/PADR/PADS then LCP, auth and IPCP, routinely 15-30s + # by itself, and both lines had just been released by the USG seconds earlier. + # ISPs commonly hold the previous session and MAC binding for minutes before + # leasing to the "same" CPE again -- which is precisely what a cloned MAC looks + # like to them. One sample at 25s reported a healthy setup as broken and + # reverted it. + # + # There is still a deadline, because commit-confirm is running: stop well + # before it so the decision is ours rather than the timer's. + local budget="${HEALTH_BUDGET:-180}" waited=0 step=15 + say "committed. Polling health for up to ${budget}s (commit-confirm has ${CONFIRM_MINUTES} min)..." + while :; do + sleep "$step"; waited=$(( waited + step )) + if health_checks >/dev/null 2>&1; then + say "healthy after ${waited}s" + break + fi + if [ "$waited" -ge "$budget" ]; then + say "still unhealthy after ${waited}s -- final check:" + break + fi + say " not healthy yet at ${waited}s, still waiting..." + done say "health checks:" if health_checks; then