Skip to content

feat(docker): expose memory (RAM) limit as an Advanced View field (OS-467) - #2673

Merged
tom mortensen (limetech) merged 2 commits into
masterfrom
feature/os-467-docker-memory-limit
Jul 21, 2026
Merged

feat(docker): expose memory (RAM) limit as an Advanced View field (OS-467)#2673
tom mortensen (limetech) merged 2 commits into
masterfrom
feature/os-467-docker-memory-limit

Conversation

@elibosley

@elibosley Eli Bosley (elibosley) commented Jun 19, 2026

Copy link
Copy Markdown
Member

Summary

Docker memory limits were only available through Extra Parameters; this adds a first-class Advanced View field and preserves it through template save, edit-mode loading, and Docker command generation.

Why This Exists

OS-467 asks for the existing docker --memory capability to be available in the Add/Edit Container UI. The initial implementation saved <Memory> to the user template, but QA found that xmlToVar() dropped the element before both edit-mode settings and xmlToCommand() consumed it.

Resolution

The Advanced View form accepts a byte count or Docker byte suffix, postToXML() stores it as <Memory>, and xmlToVar() now decodes that element into the canonical settings array. xmlToCommand() emits the first-class --memory argument before Extra Parameters so the documented duplicate-flag precedence remains unchanged.

Reviewer Considerations

  • Confirm Memory belongs alongside CPUset in the common XML-to-settings conversion; that path feeds both edit-mode repopulation and command generation.
  • Templates created before this feature omit <Memory>, so the conversion intentionally defaults the value to an empty string.
  • A duplicate --memory in Extra Parameters remains later in the command and therefore wins; the help text documents this behavior.
  • Docker enforces its 6 MiB minimum at container creation. Client validation checks the value shape without duplicating Docker runtime policy.

Behavior Changes

  • Advanced View shows a Memory limit field near Extra Parameters.
  • Values such as 512m, 2g, or a raw byte count persist in the container XML and repopulate when editing.
  • A non-empty value emits --memory=<value> in the Docker create command.
  • An empty value keeps the existing unlimited default and emits no memory flag.
  • Invalid shapes such as 512mb are rejected by browser validation.

Implementation Summary

  • Add the contMemory Advanced View form field and localized help text.
  • Save the submitted value as <Memory> in the container XML template.
  • Decode <Memory> in xmlToVar() so settings and command generation receive it.
  • Add the first-class memory flag before Extra Parameters in the Docker create command.

Verification

  • php -d short_open_tag=1 -l emhttp/plugins/dynamix.docker.manager/include/Helpers.php — passed.
  • Targeted PHP regression harness — passed XML-to-settings preservation, missing-element empty default, first-class flag generation, duplicate-flag ordering, and empty-value omission.
  • Initial hardware QA verified field visibility, browser validation, empty-limit behavior, Extra Parameters precedence, CPU pinning, and adjacent settings. Hardware re-verification of the corrected round trip is pending on the regenerated PR plugin.

Risk

Low. The QA fix adds one optional XML mapping with an empty fallback; existing templates and containers keep their prior behavior when no memory value is present.

Summary by CodeRabbit

  • New Features
    • Added a Memory limit field when creating Docker containers.
    • Supports byte values with b, k, m, or g suffixes.
    • Allows leaving the field empty for no memory limit.
    • Applies the configured limit to newly created containers.
    • Documented the minimum supported value and precedence of Extra Parameters settings.

@coderabbitai

coderabbitai Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

The Docker container form now accepts a memory limit, documents its syntax and precedence, persists the value in XML, and includes it in generated docker create commands.

Changes

Docker memory limit

Layer / File(s) Summary
Memory limit form field
emhttp/plugins/dynamix.docker.manager/include/CreateDocker.php, emhttp/languages/en_US/helptext.txt
Adds the contMemory input and documents accepted units, the minimum value, empty-field behavior, and Extra Parameters precedence.
Memory limit persistence and command wiring
emhttp/plugins/dynamix.docker.manager/include/Helpers.php
Stores and reads Memory in container XML, derives a conditional --memory= argument, and adds it to the generated Docker command.

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

Sequence Diagram(s)

sequenceDiagram
  participant Form
  participant XML
  participant Command
  participant Docker
  Form->>XML: submit contMemory
  XML->>Command: provide Memory
  Command->>Docker: execute docker create with --memory
Loading

Suggested reviewers: squidly271

Poem

A rabbit taps a memory field,
With bytes and megabytes revealed.
XML carries the value through,
Docker gets its limit too.
Hop, hop—containers now obey!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: exposing a Docker memory limit field in Advanced View.
✨ 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 feature/os-467-docker-memory-limit

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@github-actions

github-actions Bot commented Jun 19, 2026

Copy link
Copy Markdown

🔧 PR Test Plugin Available

A test plugin has been generated for this PR that includes the modified files.

Version: 2026.07.15.1628
Build: View Workflow Run

📥 Installation Instructions:

Install via Unraid Web UI:

  1. Go to Plugins → Install Plugin
  2. Copy and paste this URL:
https://preview.dl.unraid.net/pr-plugins/pr-2673/webgui-pr-2673.plg
  1. Click Install

Alternative: Direct Download

⚠️ Important Notes:

  • Testing only: This plugin is for testing PR changes
  • Backup included: Original files are automatically backed up
  • Easy removal: Files are restored when plugin is removed
  • Conflicts: Remove this plugin before installing production updates
  • Post-merge behavior: This preview stays available after merge until preview storage expires or it is manually cleaned up

📝 Modified Files:

Click to expand file list
emhttp/languages/en_US/helptext.txt
emhttp/plugins/dynamix.docker.manager/include/CreateDocker.php
emhttp/plugins/dynamix.docker.manager/include/Helpers.php

🔄 To Remove:

Navigate to Plugins → Installed Plugins and remove webgui-pr-2673, or run:

plugin remove webgui-pr-2673

🤖 This comment is automatically generated and will be updated with each new push to this PR.

Eli Bosley (elibosley) added a commit that referenced this pull request Jun 19, 2026
…(OS-469) (#2674)

## Summary
Implements
[OS-469](https://linear.app/lime-technology/issue/OS-469/pr-test-plugin-ship-a-diffpatch-so-multiple-pr-plugins-can-stack-on).
The per-PR test plugin used to package changed files as **whole-file
copies**, overwrite them on install, and **abort** if another
`webgui-pr-*` plugin already managed any of the same files — so two PRs
touching one file (e.g.
[#2672](#2672) +
[#2673](#2673), both editing
`CreateDocker.php`) couldn't be tested together.

Now it ships a **unified diff** and `patch`-applies it, so
non-overlapping edits to the same file stack.

## How it works
- **Build** (`pr-plugin-build.yml`): for changed **text** files, stage
base + head versions in system layout and emit `pr.patch` (`diff -ruN`,
paths apply with `patch -p1` at `/`). Changed **binary** files are
copied whole into `binary/` with a `binary_files.txt` list. Both go in
the same tarball.
- **Plugin** (`generate-pr-plugin.sh`): on install, `patch -p1 --dry-run
--forward` first — **abort with a clear message on a real reject**
(overlapping change), otherwise apply and save `applied.patch`. Binaries
are whole-file replaced with a per-binary conflict guard. On remove (and
before update), reverse the patch (`patch -R`) and restore binary
backups.
- **Upload/R2 plumbing unchanged** — still a single tarball with the
same URL/SHA wiring.

## Validation (local simulation)
- Two patches editing the same file at different lines → **both apply,
both changes coexist**.
- Reversing one → **only that change is removed, the other stays**.
- Overlapping edits → **dry-run fails → install aborts** cleanly.
- Generated `.plg` is well-formed XML (all placeholders substituted);
`bash -n` + YAML parse clean.

## Notes / still to verify
- Real validation needs CI + an Unraid box installing two stacked PR
plugins. Conveniently, **this PR touches `.github/**`, so it will itself
build a PR test plugin with the new code** — a live smoke test of the
generator.
- Binary deletions aren't handled (rare); text add/modify/delete are.
- `patch` is present in the Unraid base; uses `--forward`/`--batch` for
non-interactive apply with fuzz.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Chores**
* Improved plugin install/update and uninstall to use a deterministic,
patch-based manifest workflow for safer reversibility.
* Enhanced plugin package generation to build a patch-oriented payload,
distinguishing text changes from full binary replacements.
* Updated the uninstall confirmation flow to reflect the new removal
behavior.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Add a "Memory limit" field to the Docker Add/Edit form (Advanced View)
that maps to docker --memory, instead of requiring users to hand-write
it in Extra Parameters. Empty leaves the container unlimited (unchanged
default). The value round-trips through the container XML template
(<Memory>) and is emitted as --memory=<value> in the docker create
command.

Closes OS-467

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@elibosley
Eli Bosley (elibosley) force-pushed the feature/os-467-docker-memory-limit branch from d441925 to 4d18192 Compare June 19, 2026 14:37
Eli Bosley (elibosley) added a commit that referenced this pull request Jun 23, 2026
…rop shared-file edits

- Save mode is now much faster: pipe the single-pass streaming zip
  (scripts/flash_backup) into the destination file instead of appending each
  top-level item to a growing archive (one zip invocation vs many).
- On completion the save job raises an Unraid notification (the tray bell) with a
  click-to-download link, exposes the saved file for download via a docroot
  symlink, and the GUI shows a Download button next to the saved path.
- Revert the helptext.txt and .gitignore edits to base so this PR touches only
  its own files. helptext.txt was the single file shared with other in-flight PR
  test plugins (#2671, #2673), which made the stacked PR-plugin patch fail to
  apply; with it gone, #2677 stacks cleanly.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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 `@emhttp/plugins/dynamix.docker.manager/include/CreateDocker.php`:
- Around line 1151-1152: Update the contMemory handling in the Docker creation
flow, including its server-side validation before docker create, to reject or
normalize numeric values below the documented 6 MiB minimum, including 0, 1, and
5m. Align the input validation pattern or related form validation with this
minimum while preserving the unlimited option and valid unit formats.
🪄 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: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 415baf6e-7c51-49c0-bc01-835969934acd

📥 Commits

Reviewing files that changed from the base of the PR and between 644ab82 and a09982b.

📒 Files selected for processing (3)
  • emhttp/languages/en_US/helptext.txt
  • emhttp/plugins/dynamix.docker.manager/include/CreateDocker.php
  • emhttp/plugins/dynamix.docker.manager/include/Helpers.php

Comment thread emhttp/plugins/dynamix.docker.manager/include/CreateDocker.php
@unraid-bot Unraid Bot (unraid-bot) added the 7.4.0 Approved for release 7.4.0 (auto-managed by notification-worker) label Jul 15, 2026
@limetech
tom mortensen (limetech) merged commit 79f2ceb into master Jul 21, 2026
5 checks passed
@limetech
tom mortensen (limetech) deleted the feature/os-467-docker-memory-limit branch July 21, 2026 20:19
@unraid-bot Unraid Bot (unraid-bot) removed 7.4.0 Approved for release 7.4.0 (auto-managed by notification-worker) labels Jul 21, 2026
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.

3 participants