feat(syslog): a device through Docker's address is placed by its name, or a device address set on it (#6096)
CI / lint (push) Successful in 2s
CI / unit (push) Successful in 1m32s
CI / integration (push) Successful in 1m42s
CI / publish (push) Successful in 20s

The SNMP poll asks each device's sysName in the same GET and keeps it
(snmp_003_sys_name). A syslog source told apart by name finds its own
address from the SNMP device (reported or given name) or host of that
name, so its lines reach the SNMP device's and host's pages again; the
edit page gains Device address, which always wins (syslog_004).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-19 12:24:58 -04:00
co-authored by Claude Opus 5.5
parent 5ce3dfe69d
commit fcd58224de
14 changed files with 184 additions and 32 deletions
+21 -3
View File
@@ -6,7 +6,7 @@ from types import SimpleNamespace as NS
import pytest
from werkzeug.datastructures import MultiDict
from plugins.syslog.service import DEFAULT_RANGE, line_filter, severity_level, sources_for
from plugins.syslog.service import DEFAULT_RANGE, device_address, line_filter, severity_level, sources_for
def test_a_severity_reads_by_name_alias_or_number():
@@ -24,8 +24,8 @@ def test_a_page_filter_drops_what_does_not_read():
assert line_filter(MultiDict({"severity": "4", "range": "7d"})).args() == {"severity": "4", "range": "7d"}
def _src(sid, state="accepted", host_id=None, address="10.0.0.5"):
return NS(id=sid, state=state, host_id=host_id, address=address)
def _src(sid, state="accepted", host_id=None, address="10.0.0.5", sender="", device_address=""):
return NS(id=sid, state=state, host_id=host_id, address=address, sender=sender, device_address=device_address)
def test_a_page_shows_sources_bound_to_its_host_or_unbound_at_its_address():
@@ -36,3 +36,21 @@ def test_a_page_shows_sources_bound_to_its_host_or_unbound_at_its_address():
# An SNMP device bound to no host matches by its address alone.
assert [s.id for s in sources_for(sources, None, "10.0.0.5")] == ["by-address"]
assert sources_for(sources, None, None) == []
def test_a_device_through_dockers_address_is_placed_by_its_name_or_the_address_set():
"""#6096: through Swarm's ingress every line comes from Docker's address;
the device's own is the one set on it, else that of the SNMP device or
host its name is."""
named = {"vdnt-ds923": "192.168.0.7", "vdnt-as6508t": "192.168.0.5"}
syn = _src("syn", address="10.0.0.19", sender="VDNT-DS923")
asus = _src("asus", address="10.0.0.19", sender="VDNT-AS6508T", device_address="192.168.0.50")
lone = _src("lone", address="10.0.0.19", sender="router")
assert device_address(syn, named) == "192.168.0.7"
assert device_address(asus, named) == "192.168.0.50" # set by hand wins
assert device_address(lone, named) == "10.0.0.19"
assert device_address(_src("plain", sender=""), named) == "10.0.0.5"
sources = [syn, asus, lone]
assert [s.id for s in sources_for(sources, None, "192.168.0.7", named)] == ["syn"]
assert [s.id for s in sources_for(sources, None, "192.168.0.50", named)] == ["asus"]
assert sources_for(sources, None, "192.168.0.7") == [] # no names: Docker's address only