Skip to content

fix(selfhost): add memory limits to docker-compose services#2569

Merged
JSONbored merged 2 commits into
mainfrom
fix/docker-compose-resource-limits
Jul 2, 2026
Merged

fix(selfhost): add memory limits to docker-compose services#2569
JSONbored merged 2 commits into
mainfrom
fix/docker-compose-resource-limits

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Summary

  • No service in docker-compose.yml declared a memory or CPU limit, including the core gittensory app itself. Any --profile combination let one runaway optional service (Ollama loading a multi-GB model, Postgres, Qdrant, or the whole observability stack) exhaust host RAM and OOM-kill or starve the core review pipeline container instead of the intended optional service — the gap perf(selfhost): profile stack resources and tune defaults #1828 calls out, with zero mitigation anywhere in the compose file.
  • Added deploy.resources.limits.memory to the core gittensory/redis services and every heavyweight optional service (postgres, qdrant, ollama, prometheus, loki, tempo, grafana), each overridable via a documented .env variable (GITTENSORY_MEM_LIMIT, OLLAMA_MEM_LIMIT, etc.) so an operator can size a bigger/smaller host without editing the compose file.
  • Validated with docker compose --profile postgres --profile pgbouncer --profile qdrant --profile ollama --profile observability config (and confirmed the resolved byte values, e.g. 8g8589934592).

Closes #2495.

Scope

  • The PR title follows type(scope): short summary Conventional Commit format, for example fix(api): restore profile access checks.
  • This PR is focused and does not mix unrelated backend, UI, MCP, docs, dependency, and deploy changes.
  • This follows CONTRIBUTING.md and does not reintroduce GitHub Pages, VitePress, site/, or CNAME.
  • I linked an issue, or this is small enough that the summary explains why an issue is not needed.

Validation

  • git diff --check
  • npm run actionlint
  • npm run typecheck
  • npm run test:coverage locally — this is a docker-compose.yml/.env.example/test/** change with no src/** lines, so it carries no Codecov patch obligation; the new structural YAML assertions pass.
  • npm run test:workers
  • npm run build:mcp
  • npm run test:mcp-pack
  • npm run ui:openapi:check
  • npm run ui:lint
  • npm run ui:typecheck
  • npm run ui:build
  • npm audit --audit-level=moderate
  • New or changed behavior has unit/integration tests for new branches, fallback paths, and sanitizer boundaries

Safety

  • No secrets, wallet details, hotkeys, coldkeys, user PATs, private keys, raw trust scores, private rankings, or private maintainer evidence are exposed.
  • Public GitHub text stays sanitized, low-noise, and does not imply compensation guarantees or optimization tactics.
  • Auth, cookie, CORS, GitHub App, Cloudflare, or session changes include negative-path tests. — N/A.
  • API/OpenAPI/MCP behavior is updated and tested where needed. — N/A.
  • UI changes use live API data or real empty/error/loading states, not production mock/demo fallbacks. — N/A, no UI changes.
  • Visible UI changes include a UI Evidence section below — N/A, no UI changes.
  • Public docs/changelogs are updated where needed; changelogs are only edited for release-prep PRs.

Notes

@dosubot dosubot Bot added the size:S label Jul 2, 2026
@loopover-orb

loopover-orb Bot commented Jul 2, 2026

Copy link
Copy Markdown

Tip

🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩

✅ Gittensory review result - approve/merge recommended

Review updated: 2026-07-02 09:39:51 UTC

3 files · 1 AI reviewer · no blockers · readiness 80/100 · CI green · clean

✅ Suggested Action - Approve/Merge

  • safe to merge

Review summary
The change consistently adds documented memory-limit knobs for the core and heavyweight optional Compose services, and the structural test verifies the YAML/default-env contract. The notable risk is that the implementation uses the `deploy` stanza, whose enforcement depends on the Compose runtime rather than merely appearing in `docker compose config`; the diff’s own validation only proves rendering, not container limits. I do not see a diff-local breakage in the provided files.

Nits — 6 non-blocking
  • nit: docker-compose.yml:97 documents this as protecting `docker compose` self-host runs, but `deploy.resources` enforcement is runtime-dependent; add a short comment or doc note saying which Compose versions/modes this was validated against, or use the service-level limit fields if this must work for plain local Compose everywhere.
  • nit: .env.example:190 says every service below gets a memory cap, but `alertmanager`, `promtail`, `otel-collector`, and `litestream` are also services in this Compose stack and are intentionally not listed; tighten the wording to avoid implying total coverage.
  • nit: test/unit/selfhost-compose-resource-limits.test.ts:29 only checks the raw YAML string, so it would miss a syntactically valid value that `docker compose` does not accept; consider adding a small table of accepted unit suffixes or documenting why raw structural coverage is enough here.
  • docker-compose.yml:97: either confirm and document the exact `docker compose` version/mode that enforces `deploy.resources.limits.memory`, or switch to the Compose service-level memory limit mechanism used by local `docker compose up` if broad self-host compatibility is required.
  • test/unit/selfhost-compose-resource-limits.test.ts:14: include the service set rationale in the test name or a comment so future changes do not accidentally interpret this as all services rather than the selected heavyweight services.
  • PR author also opened the linked issue — Link an issue that was opened by a different contributor, or provide a rationale for why this self-authored issue represents genuine discovery work.
Signal Result Evidence
Code review ✅ No blockers 1 reviewer
Linked issue ✅ Linked #2495
Related work ⚠️ 3 scoped overlaps Top overlaps are listed below; lower-confidence bulk is hidden.
Change scope ❌ 8/20 High review scope from cached public metadata (size label size:S; 1 linked issue).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 65 registered-repo PR(s), 55 merged, 553 issue(s).
Contributor context ✅ Confirmed Gittensor contributor JSONbored; Gittensor profile; 65 PR(s), 553 issue(s).
Gate result ✅ Passing No configured blocker found.
Review context
Contributor next steps
  • Treat this as maintainer-lane context rather than normal contributor-lane activity.
  • Review top overlaps.
  • Add a concise scope and risk note.
  • No action.
  • Check active issues and PRs before submitting.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.

🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed


💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →.

Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers.

  • Re-run Gittensory review

@loopover-orb loopover-orb Bot added gittensor gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. labels Jul 2, 2026
@JSONbored JSONbored self-assigned this Jul 2, 2026
@codecov

codecov Bot commented Jul 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.98%. Comparing base (3564f67) to head (7c16a3f).
⚠️ Report is 30 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2569      +/-   ##
==========================================
+ Coverage   95.95%   95.98%   +0.02%     
==========================================
  Files         226      229       +3     
  Lines       25427    25816     +389     
  Branches     9245     9391     +146     
==========================================
+ Hits        24399    24780     +381     
- Misses        417      425       +8     
  Partials      611      611              

see 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

JSONbored added 2 commits July 2, 2026 02:22
No service declared a memory or CPU limit, including the core gittensory
app itself. Any --profile combination let one runaway optional service
(Ollama loading a multi-GB model, Postgres, Qdrant, or the whole
observability stack) exhaust host RAM and OOM-kill or starve the core
review pipeline container instead of the intended optional service --
the exact gap #1828 calls out, with zero mitigation anywhere in the
compose file.

Add deploy.resources.limits.memory to the core gittensory/redis
services and every heavyweight optional service (postgres, qdrant,
ollama, prometheus, loki, tempo, grafana), each overridable via a
documented .env variable so an operator can size a bigger/smaller host
without editing the compose file.
@JSONbored
JSONbored force-pushed the fix/docker-compose-resource-limits branch from cdd5ce0 to 7c16a3f Compare July 2, 2026 09:24
@JSONbored
JSONbored merged commit 4f4fb34 into main Jul 2, 2026
13 checks passed
@JSONbored
JSONbored deleted the fix/docker-compose-resource-limits branch July 2, 2026 09:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier.

Development

Successfully merging this pull request may close these issues.

fix(selfhost): add memory/CPU resource limits to docker-compose services

1 participant