fix(syslog): a row from before the name split, last seen as a device, stays that device's (#6096)
CI / lint (push) Successful in 2s
CI / unit (push) Successful in 1m29s
CI / integration (push) Successful in 1m39s
CI / publish (push) Successful in 19s

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-19 12:16:08 -04:00
co-authored by Claude Opus 5.5
parent db185fa9e2
commit 5ce3dfe69d
2 changed files with 23 additions and 0 deletions
+9
View File
@@ -249,6 +249,15 @@ async def store_lines(session, lines: list[Received]) -> None:
sources = {(s.address, s.sender): s for s in (await session.execute(
select(SyslogSource).where(SyslogSource.address.in_(addresses)))).scalars()}
new = [k for k in by_sender if k not in sources]
for key in [k for k in new if k[1]]:
# A row from before devices at Docker's address were told apart by
# name, last seen under this one, is this device: it keeps its state
# and name rather than a new row being offered beside it.
before = sources.get((key[0], ""))
if before is not None and before.hostname_seen == key[1]:
before.sender = key[1]
sources[key] = sources.pop((key[0], ""))
new.remove(key)
if new:
known = (await session.execute(select(func.count()).select_from(SyslogSource))).scalar_one()
for key in new: