fix(marker): clean inherited markers on def delete

delete_marker_definition removed the def but left the inherited global-*
copies on every link: it called stop_marker(), which rejects inherited
markers (409), and the ControllerError was swallowed as a warning. The
orphaned copies were in-memory only (_persist_markers filters inherited
markers) so a restart hid the symptom, but during a running session they
were undeletable via either the per-link or project API.

Add the same inherited=True bypass that update_marker already has, and
pass it from the def-delete fan-out so the copies are removed for real.
This commit is contained in:
YueGuobin committed 2026-07-16 00:39:52 +08:00
1 parent 98bcd5eddd
commit cdc27c37a7
2 files changed
+5 -3

No files matched your search

+4 -2
View File
@@ -367,7 +367,7 @@ class UDPLink(Link):
self._project.emit_notification("link.updated", self.asdict())
self._project.dump()
async def stop_marker(self, name):
async def stop_marker(self, name, inherited=False):
"""
Remove a traffic-insight marker from this link.
@@ -376,12 +376,14 @@ class UDPLink(Link):
drops it from uBridge. Mirrors how deleting a packet filter works.
:param name: filter name to remove
:param inherited: set by project-level def-delete to bypass the
inheritance guard (the project layer is the legitimate remover)
"""
if name not in self._markers:
raise ControllerNotFoundError(f"Marker '{name}' not found on link {self._id}")
if self._markers[name].get("inherited_from"):
if self._markers[name].get("inherited_from") and not inherited:
raise ControllerError(
f"Marker '{name}' is inherited from the project-level "
f"definition '{self._markers[name]['inherited_from']}'. "