Files
FabledSteward/plugins/docker/migrations/versions/docker_013_mem_used.py
T
bvandeusenandClaude Opus 5.5 56063f27a4
CI / lint (push) Successful in 2s
CI / unit (push) Successful in 1m29s
CI / integration (push) Successful in 1m45s
CI / publish (push) Successful in 1m43s
fix(docker): a container's memory is its processes' own; file cache shown on its page (#6030)
The agent sent Docker's working set (usage less inactive_file), which still
counts recently used file cache. A file-heavy container with no limit read
191 GB while its processes held 2.2 GB, and the host's own figure, which
already leaves cache out, disagreed with it.

Agent 1.23.0 sends mem_used_bytes / mem_used_pct (anon + shmem, so
Postgres's shared buffers count; v1: rss + shmem) and mem_cache_bytes
apart. The new names keep the two meanings apart in history and in learned
normals: docker_013 renames the columns, clears the old values and adds
mem_cache_bytes. The Docker page, swarm by-node sums, Busiest Containers,
container detail, normals and the MCP tools all read the new figure. File
cache is shown only on the container's page and in get_container.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 21:27:29 -04:00

37 lines
1.6 KiB
Python

"""A container's memory is its processes' own, with file cache beside it
Renames docker_containers.mem_usage_bytes / mem_pct to mem_used_bytes /
mem_used_pct and adds mem_cache_bytes (#6030). The old figure was Docker's
working set (usage less idle file cache), which still counted recently used
file cache: a container that reads a lot of files showed hundreds of GB it
didn't need. The new figure is anon + shmem, what the processes hold and
can't hand back without swap, read by agent 1.23.0. The old values are
cleared rather than carried under the new names; each container's next
report from an updated agent fills them.
Revision ID: docker_013_mem_used
Revises: docker_012_drop_metrics
Create Date: 2026-10-18
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
revision: str = "docker_013_mem_used"
down_revision: Union[str, None] = "docker_012_drop_metrics"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
op.alter_column("docker_containers", "mem_usage_bytes", new_column_name="mem_used_bytes")
op.alter_column("docker_containers", "mem_pct", new_column_name="mem_used_pct")
op.add_column("docker_containers", sa.Column("mem_cache_bytes", sa.BigInteger, nullable=True))
op.execute("UPDATE docker_containers SET mem_used_bytes = NULL, mem_used_pct = NULL")
def downgrade() -> None:
op.drop_column("docker_containers", "mem_cache_bytes")
op.alter_column("docker_containers", "mem_used_pct", new_column_name="mem_pct")
op.alter_column("docker_containers", "mem_used_bytes", new_column_name="mem_usage_bytes")