Skip to content

cpu and memory limits#42

Merged
yusufozturk merged 1 commit into
mainfrom
dev-docker-updates
Jul 6, 2026
Merged

cpu and memory limits#42
yusufozturk merged 1 commit into
mainfrom
dev-docker-updates

Conversation

@yusufozturk

@yusufozturk yusufozturk commented Jul 6, 2026

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • Bug Fixes
    • Resource settings in generated deployment configurations now only include CPU and memory values when they are explicitly provided.
    • Improved handling of resource limits and reservations so partial settings no longer add unintended default CPU or memory values.

@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

The change modifies how Docker Compose resource limits are populated and rendered. Instead of always defaulting CPU and memory limits when resource limits are enabled, values are now assigned directly from config, and the template conditionally emits cpus/memory fields only when set.

Changes

Conditional Resource Limits

Layer / File(s) Summary
Resource limit population and rendering
internal/orchestrator/docker.go
writeCompose sets HasResourceLimits when either CPU or memory limit is provided and assigns values directly from config without defaults; the Compose template conditionally renders cpus/memory under limits and reservations based on which values are set.

Estimated code review effort: 2 (Simple) | ~10 minutes

Poem

A hop, a skip, a config tweak,
No more defaults forced to speak,
Only cpus and memory shown,
When their values are truly known,
This bunny thumps in approval, squeak! 🐇

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately reflects the main change around CPU and memory limits in Compose rendering.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dev-docker-updates

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
internal/orchestrator/docker.go (1)

269-282: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

reservations mirrors limits exactly, defeating the purpose of a reservation.

Both blocks are populated from the same .CPULimit/.MemLimit values, so the "guaranteed minimum" (reservation) is set equal to the "hard cap" (limit) instead of some fraction below it. This isn't introduced by this diff (the same mirroring existed pre-change per the AI summary), but since these lines are directly touched here, it's worth reconsidering whether reservations should be a fraction of the limit rather than an exact copy, to actually get useful scheduling headroom instead of a static pinned allocation.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/orchestrator/docker.go` around lines 269 - 282, The Docker resource
template in the orchestrator currently sets reservations to the exact same
values as limits, so the reservation has no distinct scheduling meaning. Update
the templating in the Docker compose generation logic around the resource block
in docker.go, using the existing limit fields like .CPULimit and .MemLimit, so
reservations are derived separately from limits (for example as a lower fraction
or other intended minimum) instead of mirroring them exactly.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@internal/orchestrator/docker.go`:
- Around line 1991-1997: Validate the forwarded resource limit values before
they reach docker compose: in the path from cmd/harness/main.go into
internal/orchestrator/docker.go, reject malformed --cpu-limit and --mem-limit
inputs up front instead of passing them through unchanged as CPULimit and
MemLimit. Add parsing/validation where these flags are consumed so bad CLI/env
values fail with a clear error before HasResourceLimits is used to populate
compose cpus/memory settings.

---

Nitpick comments:
In `@internal/orchestrator/docker.go`:
- Around line 269-282: The Docker resource template in the orchestrator
currently sets reservations to the exact same values as limits, so the
reservation has no distinct scheduling meaning. Update the templating in the
Docker compose generation logic around the resource block in docker.go, using
the existing limit fields like .CPULimit and .MemLimit, so reservations are
derived separately from limits (for example as a lower fraction or other
intended minimum) instead of mirroring them exactly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6b155c2d-50e0-45d1-b84b-6d0d1a5aec61

📥 Commits

Reviewing files that changed from the base of the PR and between f043743 and aa378d2.

📒 Files selected for processing (1)
  • internal/orchestrator/docker.go

Comment thread internal/orchestrator/docker.go
@yusufozturk yusufozturk merged commit d5faedc into main Jul 6, 2026
5 checks passed
@yusufozturk yusufozturk deleted the dev-docker-updates branch July 6, 2026 05:38
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