WAN: ticket sustained slowdowns; reboot drops no longer mean "unstable" #60

Merged
jared merged 2 commits from wan-degradation into main 2026-11-23 23:58:12 -05:00
Owner

Closes #58.

Why

  • No ticket for the real problem: on 2026-11-23 and 24 the WAN was slow or lossy for about 20 hours, and nothing opened a ticket.
  • A ticket for the fix: the only ticket (Tinker 460506581) came from the reboot that fixed it.
    • The WAN history shows the owner's AT&T-app reboot, then Smart Power power-cycling the modem at 04:03 and again at 04:09.
    • That caused two short drops, and UniFi's "WAN failed multiple times" opened the ticket.

What changes

  • New wan_degraded ticket (P2).

    • Opens when at least half of the last 2 hours of UniFi WAN-health periods were slow, lossy or down. That needs at least an hour of data, and the share is configurable as modem.degraded_fraction.
    • Closes with a recovery note once the last 2 hours are at most a quarter bad. The 2-hour exit stops it closing and reopening during a patchy day.
    • Includes a slow ping from the modem itself, from the logged-in checks, when there is one.
    • Suggests the Restart modem button.
  • "WAN connection unstable" waits 10 minutes before deciding. That gives time for the modem's uptime reset to show up. It then opens only if at least 2 drops in the last 24 hours aren't explained by a restart: anything from 5 minutes before to 15 minutes after.

  • One restart history from three sources:

    • Smart Power entries from the UniFi log
    • uptime resets, which catch AT&T-app, modem-button or power-loss reboots
    • the Restart modem button

    Entries within 15 minutes count as one restart.

  • Both tickets list the last 7 days of restarts and how long each one lasted. After 2 or more restarts in a week they add: "ask AT&T for a replacement BGW320".

Replay against prod's real last 24 hours of WAN health

  • OPEN 11-23 06:50 (12 of 24 bad), RESOLVE 11-23 18:15
  • OPEN 11-24 01:30, about 2.5 hours before the owner noticed and rebooted

With a 1-hour exit it closed at 10:00 and reopened at 10:15, which is why the exit is 2 hours. Under the new rule, last night's reboot drops (both inside the 04:03 and 04:09 restart window) would not have opened "unstable".

Also found

Smart Power power-cycles the modem while it's rebooting on purpose. It did this on 11-20 during the restart, and twice on 11-24 after the app reboot. So an intentional reboot turns into two or three power cycles. Worth considering:

  • lengthening Smart Power's wait before it acts, in UniFi
  • having the Restart modem button pause it

Not changed here.

Tests

635 passed. flake8 and bandit are clean, and there are no em or en dashes.

  • TestWanDegraded:
    • opens after two bad hours
    • an occasional slow period does nothing
    • resolves
    • stays as it is in between
    • does nothing with no timeline
    • mentions a slow ping from the modem
  • TestWanLog:
    • waits before deciding
    • drops with no restart open the ticket
    • reboot drops alone don't
    • the Gandalf button explains its own drop
    • the ticket lists restarts and suggests a replacement
  • test_modem: restart episodes, unexplained drops, the restart lines and replacement hint, and the degradation and recovery thresholds.

🤖 Generated with Claude Code

Closes #58. ## Why - **No ticket for the real problem:** on 2026-11-23 and 24 the WAN was slow or lossy for about 20 hours, and nothing opened a ticket. - **A ticket for the fix:** the only ticket (Tinker 460506581) came from the reboot that fixed it. - The WAN history shows the owner's AT&T-app reboot, then Smart Power power-cycling the modem at 04:03 and again at 04:09. - That caused two short drops, and UniFi's "WAN failed multiple times" opened the ticket. ## What changes - **New `wan_degraded` ticket (P2).** - **Opens** when at least half of the last 2 hours of UniFi WAN-health periods were slow, lossy or down. That needs at least an hour of data, and the share is configurable as `modem.degraded_fraction`. - **Closes** with a recovery note once the last 2 hours are at most a quarter bad. The 2-hour exit stops it closing and reopening during a patchy day. - **Includes** a slow ping from the modem itself, from the logged-in checks, when there is one. - **Suggests** the Restart modem button. - **"WAN connection unstable" waits 10 minutes before deciding.** That gives time for the modem's uptime reset to show up. It then opens only if at least 2 drops in the last 24 hours aren't explained by a restart: anything from 5 minutes before to 15 minutes after. - **One restart history from three sources:** - Smart Power entries from the UniFi log - uptime resets, which catch AT&T-app, modem-button or power-loss reboots - the Restart modem button Entries within 15 minutes count as one restart. - **Both tickets list the last 7 days of restarts** and how long each one lasted. After 2 or more restarts in a week they add: "ask AT&T for a replacement BGW320". ## Replay against prod's real last 24 hours of WAN health - `OPEN 11-23 06:50` (12 of 24 bad), `RESOLVE 11-23 18:15` - `OPEN 11-24 01:30`, about 2.5 hours before the owner noticed and rebooted With a 1-hour exit it closed at 10:00 and reopened at 10:15, which is why the exit is 2 hours. Under the new rule, last night's reboot drops (both inside the 04:03 and 04:09 restart window) would not have opened "unstable". ## Also found Smart Power power-cycles the modem while it's rebooting on purpose. It did this on 11-20 during the restart, and twice on 11-24 after the app reboot. So an intentional reboot turns into two or three power cycles. Worth considering: - lengthening Smart Power's wait before it acts, in UniFi - having the Restart modem button pause it Not changed here. ## Tests 635 passed. flake8 and bandit are clean, and there are no em or en dashes. - **`TestWanDegraded`:** - opens after two bad hours - an occasional slow period does nothing - resolves - stays as it is in between - does nothing with no timeline - mentions a slow ping from the modem - **`TestWanLog`:** - waits before deciding - drops with no restart open the ticket - reboot drops alone don't - the Gandalf button explains its own drop - the ticket lists restarts and suggests a replacement - **`test_modem`:** restart episodes, unexplained drops, the restart lines and replacement hint, and the degradation and recovery thresholds. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
jared added 1 commit 2026-11-23 23:51:42 -05:00
WAN: ticket sustained slowdowns; reboot drops no longer mean "unstable"
Lint / JS (eslint) (push) Successful in 11s
Lint / Python (flake8) (push) Successful in 1m28s
Lint / Notify on failure (push) Skipped
Lint / Deploy (push) Skipped
Security / Python Security (bandit) (push) Successful in 1m38s
Lint / Python (flake8) (pull_request) Successful in 57s
Test / Python Tests (pytest) (push) Successful in 1m20s
Lint / JS (eslint) (pull_request) Successful in 17s
Lint / Notify on failure (pull_request) Skipped
Lint / Deploy (pull_request) Skipped
Security / Python Security (bandit) (pull_request) Successful in 2m54s
Test / Python Tests (pytest) (pull_request) Successful in 3m9s
a31437f2e5
On 2026-11-23/24 the WAN was degraded for about 20 hours with no ticket,
and the only ticket came from the owner's reboot fixing it.

- wan_degraded (P2): half or more of the last 2 hours of UniFi WAN health
  periods slow, lossy or down. Closes with a recovery note once the last
  2 hours are at most a quarter bad. Mentions a slow ping from the modem.
- "WAN connection unstable" waits 10 minutes, then counts only drops that
  no modem restart explains (Smart Power, uptime reset, or the Restart
  modem button, folded into one restart when within 15 minutes).
- Both list the last 7 days of restarts and how long each lasted, and
  suggest asking AT&T for a replacement after 2+ restarts in a week.

Closes #58

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jared added 1 commit 2026-11-23 23:52:28 -05:00
WAN degraded: a modem restart resets the judgement
Lint / JS (eslint) (push) Successful in 10s
Lint / Python (flake8) (push) Successful in 49s
Lint / Notify on failure (push) Skipped
Lint / Deploy (push) Skipped
Lint / JS (eslint) (pull_request) Successful in 11s
Lint / Python (flake8) (pull_request) Successful in 50s
Lint / Notify on failure (pull_request) Skipped
Lint / Deploy (pull_request) Skipped
Security / Python Security (bandit) (push) Successful in 1m8s
Test / Python Tests (pytest) (push) Successful in 1m21s
Security / Python Security (bandit) (pull_request) Successful in 1m5s
Test / Python Tests (pytest) (pull_request) Successful in 1m31s
3e3069d2aa
Only health periods from 15 minutes after the latest restart count, so a
slowdown the restart fixed neither opens a ticket on deploy nor holds one
open. Replay: opens 11-24 01:30, resolves 04:20 after the reboot.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Author
Owner

Follow-up commit: a modem restart resets the degraded check.

The bug it fixes: the 2-hour window still held the bad stretch from before last night's reboot. Deploying would have opened a "degraded" ticket straight away for a problem already fixed.

The change: only WAN-health periods from 15 minutes after the latest restart now count. This also closes an open degraded alert soon after a restart, which #58 asked for.

Replay with real WAN history and restarts:

Event Time
Open 11-23 06:50
Resolve 11-23 18:15
Open 11-24 01:30
Resolve 11-24 04:20 (after the reboot)

Nothing is open now, so deploying won't cut a ticket. 636 tests pass.

**Follow-up commit: a modem restart resets the degraded check.** **The bug it fixes:** the 2-hour window still held the bad stretch from before last night's reboot. Deploying would have opened a "degraded" ticket straight away for a problem already fixed. **The change:** only WAN-health periods from 15 minutes after the latest restart now count. This also closes an open degraded alert soon after a restart, which #58 asked for. **Replay with real WAN history and restarts:** | Event | Time | |---|---| | Open | 11-23 06:50 | | Resolve | 11-23 18:15 | | Open | 11-24 01:30 | | Resolve | 11-24 04:20 (after the reboot) | Nothing is open now, so deploying won't cut a ticket. 636 tests pass.
jared scheduled this pull request to auto merge when all checks succeed 2026-11-23 23:56:42 -05:00
jared merged commit a7792063ba into main 2026-11-23 23:58:12 -05:00
jared deleted branch wan-degradation 2026-11-23 23:58:16 -05:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: LotusGuild/gandalf#60