Repository navigation
Fix: duplicate Link objects for MLO links with rotating UISP UUIDs - #1143
WillNilges wants to merge 3 commits into
Conversation
UISP reports MLO links (e.g. Wave-MLO6 pairs) as one data-link object per radio, all on the same device pair, and the objects' UUIDs rotate whenever the MLO link re-establishes. The orphan-adoption fallback (added for rotating ethernet link UUIDs) was designed for one link per device pair: it re-points every orphaned row on the pair to the incoming UUID, so each import adopted all stale rows onto the first sublink's new ID, after which the second sublink's ID found nothing to adopt and created a brand-new row. Net effect: +1 duplicate Link per re-establishment, all rows sharing the same (now-stale) uisp_id. This produced 24 near-identical links for nycmesh-713-mlo6-3461 <-> nycmesh-3461-mlo6-713. The two sublink objects are distinguishable by their per-end interface identification (e.g. wifi0/main vs wifi1/backup), which identifies the radio and is stable across UUID rotation. Persist that identification on Link (from/to interface name + description) and use it to narrow orphan adoption candidates: - if an orphaned row's interface signature matches the incoming link, adopt only the matching row(s); - if no orphaned row matches but some have known interfaces, the incoming link is a different radio -> create it instead of adopting; - if there is no interface info (legacy rows / bare payloads), keep the existing device-pair-only behavior. Note: the top-level 'frequency' field is misreported for MLO sublinks (both report 5710 MHz despite one being a 320 MHz 6 GHz channel), so it is not used for matching; link type remains mislabeled until UISP fixes its reporting. The existing 23 duplicate rows are not auto-cleaned; they converge onto current IDs and gain interface data on the next import, after which they can be deleted manually.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1143 +/- ##
==========================================
- Coverage 95.00% 94.99% -0.01%
==========================================
Files 100 100
Lines 4605 4639 +34
==========================================
+ Hits 4375 4407 +32
- Misses 230 232 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Co-authored-by: Willard Nilges <willardnilges@gmail.com>
|
Strangely the referenced |
lotia
left a comment
There was a problem hiding this comment.
A couple of suggestions, which will are not semantically relevant. Other than that it looks good to me.
I have NOT run tests locally since they are slow and also tend to fail when they don't in CI. I have look at the CI test output and we have passing tests!
| } | ||
| } | ||
| } | ||
| if from_iface is not None: |
There was a problem hiding this comment.
This is a nitpick and semantically irrelevant but you did ask for a detailed review 😉
Understand this is a test but want to clarify whether you were checking for the actual None object/type rather than a falsy value where the general idiom is
if not from_iface:note that the above will also be true for 0, False and "" so my suggestion may be bunk here.
| from_end["interface"] = { | ||
| "identification": {"type": "wlan", "name": from_iface[0], "description": from_iface[1]} | ||
| } | ||
| if to_iface is not None: |
Problem
Device
nycmesh-713-mlo6-3461(NN 713) accumulated 24 near-identical Link rows connecting it tonycmesh-3461-mlo6-713(NN 3461) — all sharing the sameuisp_id, which no longer exists in UISP. This was the only duplicate group in the entire 2,945-link table, i.e. specific to this link pair.Root cause (verified against live UISP + MeshDB data):
import_and_sync_uisp_links(added in Fix: slack spam due to rotating UISP link UUIDs #700 for rotating ethernet link UUIDs) is designed for one link per device pair: it re-points every orphaned row on the pair to the incoming UUID. Each import therefore adopted all 23 stale rows onto the first sublink's new ID, after which the second sublink's ID found nothing to adopt and created a new row. Net: +1 duplicate per re-establishment, and all rows converge on the same (now-stale)uisp_id.Note: the top-level
frequencyfield is misreported for MLO sublinks (both report 5710 MHz even though one is a 320 MHz 6 GHz channel), so the link type is mislabeled "5 GHz Airmax" on both — a UISP-side issue that should eventually be fixed there.Fix
The two sublink objects are distinguishable by their per-end interface identification (e.g.
wifi0/mainvswifi1/backup), which identifies the radio and is stable across UUID rotation. This PR:Link: new nullablefrom_interface_name,from_interface_description,to_interface_name,to_interface_description(migration0015, mirrored onHistoricalLink).Tests
test_uisp_import.py: MLO rotation adopts the correct row per radio (no new rows); a genuinely new radio creates a row; legacy NULL-interface rows still adopt and gain interface data; no-interface payloads keep legacy behavior.pytest(unit),mypy,black,isort,flake8all pass. (test_nn.py::TestNNRaceConditionfails on cleanmainas well — pre-existing.)Data cleanup (separate, manual)
The existing 23 duplicate rows are not auto-deleted. After this deploys, the next import converges them onto current UUIDs and stamps their interfaces; then 22 of the 23 can be deleted.