Убрал journal event dropped by acl из journal adapter, чтобы ACL-drop больше не писался обратно в тот же journald-поток и не создавал петлю.

This commit is contained in:
Ilgiz Kalmetyev 2026-04-13 21:48:11 +05:00
parent cd21ef14cb
commit 6e515bfbc6
9 changed files with 15 additions and 21 deletions

View File

@ -1,4 +1,4 @@
from __future__ import annotations
from __future__ import annotations
import asyncio
import logging
@ -196,27 +196,10 @@ class JournalAdapter(SourceAdapterProtocol):
reading = self.parser.parse(raw_entry)
decision = self._acl_decision(raw_entry)
if decision is not None and not decision.allowed:
logger.debug(
"journal event filtered before cache",
extra={
"source_key": self.source_key,
"cursor": reading.cursor.value,
"event_type": self._event_label(reading),
},
)
# Do not log ACL drops here: journald-ingested logs would
# re-enter the same adapter and create a feedback loop.
await self._save_cursor(reading)
self._current_cursor = reading.cursor
logger.info(
"journal event dropped by acl",
extra=build_log_context(
source_id=self.source_id,
source_key=self.source_key,
channel=self.ingestion_channel,
status=SourceStatus.HEALTHY.value,
cursor=reading.cursor.value,
acl=decision.to_dict(),
),
)
continue
await self._cache_reading(reading, decision=decision)
logger.debug(

View File

@ -1,6 +1,7 @@
from __future__ import annotations
from __future__ import annotations
import asyncio
import logging
from datetime import datetime, timezone
from pathlib import Path
from uuid import UUID
@ -289,6 +290,16 @@ def test_journal_drop_rules_still_advance_cursor() -> None:
asyncio.run(_run_journal_drop_cursor_scenario())
def test_journal_acl_drops_do_not_emit_journal_logs(
caplog: pytest.LogCaptureFixture,
) -> None:
caplog.set_level(logging.INFO)
asyncio.run(_run_journal_drop_cursor_scenario())
assert all(
record.message != "journal event dropped by acl" for record in caplog.records
)
def test_dbus_acl_is_applied_before_canonical_ingestion() -> None:
asyncio.run(_run_dbus_acl_ingress_scenario())