fix(docker): the slow-ingest line names which part of the Docker persist took the time (#5181)
persist_host_docker marks docker.status, .swarm, .disk, .logs, .metrics, .events, .containers, .alerts and .reap on the ingest's phase timer, each flushed before its mark so a part's writes are charged to it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -383,6 +383,41 @@ def test_vanished_container_is_reaped(app):
|
||||
assert after == ["keep"] # the vanished container was reaped
|
||||
|
||||
|
||||
@_NEEDS_DB
|
||||
def test_persist_marks_each_part_for_the_slow_ingest_line(app):
|
||||
"""Each part of the docker persist is marked, so the slow-ingest line
|
||||
names the part its time went to (#5181)."""
|
||||
from steward.models.hosts import Host
|
||||
|
||||
class _Marks:
|
||||
def __init__(self):
|
||||
self.names = []
|
||||
|
||||
def mark(self, name):
|
||||
self.names.append(name)
|
||||
|
||||
persist = _persist_fn(app)
|
||||
at = datetime(2026, 10, 6, 23, 0, 0, tzinfo=timezone.utc)
|
||||
c = {"name": "web", "status": "running", "cpu_pct": 1.0, "mem_pct": 1.0,
|
||||
"restart_count": 0, "exit_code": None, "oom_killed": False, "health": None}
|
||||
logs = [(at, [{"container": "web", "stream": "stdout", "ts": None, "line": "hello"}])]
|
||||
marks = _Marks()
|
||||
|
||||
async def _go():
|
||||
async with app.db_sessionmaker() as s:
|
||||
async with s.begin():
|
||||
h = Host(id=str(uuid.uuid4()), name="marks", address="10.9.9.7")
|
||||
s.add(h)
|
||||
await s.flush()
|
||||
await persist(s, h, [(at, [c])], None, None, logs,
|
||||
{"status": "ok", "detail": None, "at": at, "swarm_manager": None},
|
||||
phases=marks)
|
||||
|
||||
asyncio.run(_go())
|
||||
assert marks.names == ["docker.status", "docker.logs", "docker.metrics", "docker.events",
|
||||
"docker.containers", "docker.alerts", "docker.reap"]
|
||||
|
||||
|
||||
@_NEEDS_DB
|
||||
def test_an_empty_snapshot_from_a_docker_that_answered_clears_the_host(app):
|
||||
"""Docker answering with no containers removes the host's rows (#5152); a
|
||||
|
||||
Reference in New Issue
Block a user