cpu and memory limits#42
Conversation
WalkthroughThe 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 ChangesConditional Resource Limits
Estimated code review effort: 2 (Simple) | ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
internal/orchestrator/docker.go (1)
269-282: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value
reservationsmirrorslimitsexactly, defeating the purpose of a reservation.Both blocks are populated from the same
.CPULimit/.MemLimitvalues, 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
📒 Files selected for processing (1)
internal/orchestrator/docker.go
Summary by CodeRabbit