Skip to content

Add memory partitioning for LXD containers, PostgreSQL, Tomcat, and Doris - #87

Open
jason-p-pickering wants to merge 6 commits into
mainfrom
feature/memory-partitioning
Open

Add memory partitioning for LXD containers, PostgreSQL, Tomcat, and Doris#87
jason-p-pickering wants to merge 6 commits into
mainfrom
feature/memory-partitioning

Conversation

@jason-p-pickering

Copy link
Copy Markdown

Summary

  • Adds an optional lxd_memory_limit inventory variable, wired into every container-creating role's LXD config: dict (postgres, create-instance, proxy, monitoring, integration, backups, and the standalone Doris setup playbook) via conditional combine().
  • Adds optional doris_fe_heap_size/doris_be_mem_limit variables to apache-doris-setup.yml, applied via a surgical -Xmx token replace (fe.conf) and mem_limit lineinfile (be.conf), each notifying a restart handler.
  • Documents these new variables plus several pre-existing-but-undocumented ones (pg_shared_buffers, pg_work_mem, pg_maintenance_work_mem, pg_effective_cache_size, pg_max_connections, heap_memory_size) in deploy/inventory/hosts.template, including a new example [apache_doris] group.
  • All new variables are optional — unset behavior is unchanged.

Design spec: docs/superpowers/specs/2026-07-06-memory-partitioning-design.md
Implementation plan: docs/superpowers/plans/2026-07-06-memory-partitioning.md

Test plan

  • ansible-lint/yamllint reviewed on all modified files (only pre-existing, unrelated warnings — missing collections, pre-existing var-naming/line-length issues elsewhere in the repo)
  • ansible-playbook --syntax-check on dhis2.yml, playbooks/apache-doris-setup.yml, and backup.yml
  • ansible-inventory --graph against the updated hosts.template confirms it still parses, including the new [apache_doris] group
  • Manually verified on a real memory-constrained deployment (LXD limits.memory caps, Postgres conf.d/custom override, Tomcat heap, Doris FE/BE tuning) before being codified here
  • No Molecule/CI coverage added for the LXD memory limit path — Molecule uses the Docker driver, not LXD, so this code path isn't exercised in CI regardless (explicit, approved non-goal)

🤖 Generated with Claude Code

jason-p-pickering and others added 6 commits July 6, 2026 08:43
Codifies manually-verified memory partitioning (LXD limits.memory,
Postgres/Tomcat/Doris tuning) into Ansible inventory variables and
role changes, so memory-constrained hosts don't need hand-tuning
rediscovered on every deployment.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
The final review found a 7th container-creating lxd_container task that
was missed when lxd_memory_limit was wired into the other 6 (postgres,
create-instance x2, proxy, monitoring, integration, doris). Apply the
identical combine() pattern to the backup container so it can be capped
too, matching the feature's stated goal of letting an operator cap any
LXD container's memory.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
The spec described doris_fe_heap_size as setting a whole JAVA_OPTS line
via lineinfile, replacing both -Xmx and -Xms. The shipped implementation
in apache-doris-setup.yml actually uses ansible.builtin.replace with
regex -Xmx\S+ to surgically swap only the -Xmx token, deliberately
leaving -Xms and Doris's other default JVM flags (GC, metaspace, etc.)
untouched. Update the doc so it matches the approved code.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@sonarqubecloud

sonarqubecloud Bot commented Jul 6, 2026

Copy link
Copy Markdown

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