Skip to content

Stop deactivating blackbox device links during UISP import - #1150

Merged
rubendax merged 4 commits into
nycmeshnet:mainfrom
rubendax:uisp-import-fixes
Nov 20, 2026
Merged

rubendax merged 4 commits into
nycmeshnet:mainfrom
rubendax:uisp-import-fixes

Conversation

@rubendax

Copy link
Copy Markdown
Collaborator

Don't mark blackBox links inactive just because they're missing from UISP

Problem

At the end of each import, import_and_sync_uisp_links marks every Active link whose uisp_id is no longer in UISP as Inactive, immediately and with no grace period.

UISP can't detect links that touch blackBox devices, such as MikroTik routers. Those links exist in UISP because someone created them by hand. In a recent UISP snapshot, all 465 links touching a blackBox device had origin: manual. If a hand-drawn link is deleted or lost in UISP, the MeshDB link is marked Inactive even when it's still up. When a volunteer sets it back to Active, the next hourly import reverts it again.

Example: the NN2481↔NN1447 60 GHz link kept going back to Inactive while it was carrying traffic. It only stayed fixed after its uisp_id was cleared by hand.

Change

  • New constant UISP_DEVICE_TYPES_WITHOUT_LINK_DETECTION = ["blackBox"] in uisp_import/constants.py.
  • import_and_sync_uisp_links takes an optional uisp_devices list. When it's given, links where either end is a blackBox device are skipped when sweeping for links that are missing from UISP. A skip is logged; nothing else changes.
  • run_update_from_uisp and run_uisp_on_demand_import fetch the UISP device list once and pass it to both the device and the link import, so there are no extra UISP API calls.
  • The sweep loads both devices of each link in the same query, so the new check doesn't add two database queries per link.

Unchanged

  • Links between devices UISP can detect links for, e.g. Ubiquiti radios, are still marked Inactive when they disappear from UISP. That's usually correct, e.g. when a station moves to a different sector.
  • Links whose end device was deleted from UISP are still marked Inactive.
  • Links UISP can detect keep getting their status from UISP as before.
  • Callers that don't pass uisp_devices behave exactly as before.

FYI

Manually created links between non-blackBox devices (about 120 in UISP) are still marked Inactive if they disappear, because once a link is gone we can't tell if it was manually created. A follow-up PR adding a grace period for links missing from UISP will cover these.

Don't mark links inactive for "missing from UISP" when either end is a blackBox device (manually added non-ubiquiti device), since UISP can't actually detect those links and they only exist there if created by hand.
@codecov

codecov Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.16%. Comparing base (38df0f7) to head (f7d4aba).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1150      +/-   ##
==========================================
+ Coverage   95.02%   95.16%   +0.13%     
==========================================
  Files         100      100              
  Lines        4605     4612       +7     
==========================================
+ Hits         4376     4389      +13     
+ Misses        229      223       -6     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@rubendax
rubendax merged commit 5213c6b into nycmeshnet:main Nov 20, 2026
14 checks passed
@rubendax
rubendax deleted the uisp-import-fixes branch November 20, 2026 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants