feat(docker): schema for lifecycle events + swarm topology
Adds the milestone-77 storage that doesn't fit on the per-container row:
* docker_events — lifecycle (start/stop/die/oom/health_change), to be
derived by diffing consecutive host snapshots; host-scoped, indexed for
timeline lookups (host_id, container_name, at) and retention pruning (at).
* docker_swarm_services / docker_swarm_nodes — manager-reported Swarm
topology (desired-vs-running replicas, node role/availability/status).
Migration docker_004 extends the docker branch (down_revision docker_003);
purely additive, no DROP+recreate. event/mode/role are plain strings (no
CHECK whitelist), matching how docker_containers models status. Integration
guard asserts the three new host-scoped tables exist.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016Jg27rgypiW2efULXJDtMC
This commit is contained in:
@@ -53,6 +53,28 @@ def test_docker_tables_are_host_scoped(app):
|
||||
asyncio.run(_go())
|
||||
|
||||
|
||||
@_NEEDS_DB
|
||||
def test_events_and_swarm_tables_exist(app):
|
||||
"""docker_004 created the lifecycle + swarm topology tables with host_id FKs."""
|
||||
from sqlalchemy import text
|
||||
|
||||
async def _go():
|
||||
async with app.db_sessionmaker() as s:
|
||||
for tbl in ("docker_events", "docker_swarm_services", "docker_swarm_nodes"):
|
||||
cols = {r[0] for r in (await s.execute(text(
|
||||
"SELECT column_name FROM information_schema.columns "
|
||||
"WHERE table_name = :t"), {"t": tbl})).all()}
|
||||
assert cols, f"{tbl} missing entirely"
|
||||
assert "host_id" in cols, f"{tbl} missing host_id"
|
||||
# docker_events carries the lifecycle columns the ingest derivation writes.
|
||||
ev_cols = {r[0] for r in (await s.execute(text(
|
||||
"SELECT column_name FROM information_schema.columns "
|
||||
"WHERE table_name = 'docker_events'"))).all()}
|
||||
assert {"event", "container_name", "at", "detail"} <= ev_cols
|
||||
|
||||
asyncio.run(_go())
|
||||
|
||||
|
||||
def _persist_fn(app):
|
||||
"""Resolve persist_host_docker via the registered capability if the docker
|
||||
plugin is loaded, else import it directly (the import is safe only when the
|
||||
|
||||
Reference in New Issue
Block a user