Skip to content

Cap container memory+swap together; allow Postgres server settings - #61

Merged
aersam merged 2 commits into
mainfrom
ci-memory-limits
Oct 22, 2026
Merged

aersam merged 2 commits into
mainfrom
ci-memory-limits

Conversation

@aersam

@aersam aersam commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Why

The on-prem CI agents (BMS_OnPrem, 4 GB RAM / 2 GB swap each) run out of memory and go down. pgdevkit's shared pgdevkit-postgres container has no memory cap by default, and PGDEVKIT_TESTDB_MEM_LIMIT alone left the swap limit unbounded, so a container "limited" to e.g. 1g could still spill into swap and thrash the agent.

Changes

  • PGDEVKIT_TESTDB_MEM_LIMIT now also sets memswap_limit to the same value (the --memory-swap=<same> idiom). New PGDEVKIT_TESTDB_MEMSWAP_LIMIT overrides it (-1 = unlimited swap, the old behaviour). Same for PGDEVKIT_TESTDB_MSSQL_*. No limit is applied when MEM_LIMIT is unset, as before.
  • New PGDEVKIT_TESTDB_PG_SETTINGS (e.g. shared_buffers=128MB max_connections=50): whitespace-separated key=value pairs (values may contain commas, e.g. search_path=a,b, but no spaces) appended as -c key=value to the Postgres start command, after the defaults.
  • MEMSWAP_LIMIT without a MEM_LIMIT is ignored (Docker/Podman need both).
  • Version bump 0.16.1 -> 0.17.0 (pyproject.toml, uv.lock).
  • README + tests.

Behaviour change

Anyone who already sets *_MEM_LIMIT now also gets a matching swap cap. Set *_MEMSWAP_LIMIT=-1 to opt out.

Not verified

  • Rootless podman only enforces memory limits when the cgroup v2 memory controller is delegated to the user. Unit tests cover the kwargs passed to the Docker API, not enforcement on the agents; check on a test branch that the container still starts on devops_onprem-*.
  • As before, limits only apply when pgdevkit creates the container: remove a stale pgdevkit-postgres on the agents (podman rm -f pgdevkit-postgres) for them to take effect.

🤖 Generated with Claude Code

@aersam
aersam marked this pull request as ready for review October 22, 2026 14:08
@aersam
aersam merged commit 023125a into main Oct 22, 2026
2 checks passed
aersam and others added 2 commits October 22, 2026 15:57
A MEM_LIMIT now also sets the memory+swap limit to the same value so the test
container cannot spill into swap on small CI agents (override with
PGDEVKIT_TESTDB_MEMSWAP_LIMIT, -1 = unlimited). PGDEVKIT_TESTDB_PG_SETTINGS adds
-c key=value server settings, e.g. shared_buffers=128MB max_connections=50.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…thout memory limit; bump to 0.17.0

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant