[PR #64] [MERGED] feat(pve): configurable default container memory (replace hardcoded 4GB) #65

Closed
opened 2026-10-15 12:51:44 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/games-on-whales/LXC2Docker/pull/64
Author: @JBailes
Created: 6/5/2026
Status: ✅ Merged
Merged: 6/5/2026
Merged by: @JBailes

Base: main ← Head: feat/configurable-default-memory


📝 Commits (1)

  • 24a8131 feat(pve): configurable default container memory (replace hardcoded 4GB)

📊 Changes

8 files changed (+142 additions, -7 deletions)

View changed files

📝 cmd/docker-lxc-daemon/main.go (+6 -0)
📝 internal/api/containers.go (+10 -0)
📝 internal/lxc/config.go (+13 -5)
📝 internal/lxc/manager.go (+7 -1)
➕ internal/lxc/memory.go (+60 -0)
➕ internal/lxc/memory_test.go (+44 -0)
📝 internal/lxc/pve_tarball.go (+1 -1)
📝 readme.md (+1 -0)

📄 Description

Problem

PVE CTs created without an explicit --memory were hardcoded to memory: 4096 in writePVEConfig. Any memory-heavy workload that doesn't set a limit (e.g. Wolf's WolfSteam game CTs) gets silently OOM-killed by the cgroup at ~4 GB — observed as deterministic, renderer-independent, log-silent crashes at game world-load.

Fix

Resolve a CT's memory by precedence:

  1. docker --memory (HostConfig.Memory)
  2. dld.memory label (per-container, e.g. dld.memory=32G)
  3. --default-memory daemon flag
  4. host total RAM — no artificial cap, matching Docker's Memory=0 semantics

Proxmox requires a concrete number, so we resolve one instead of leaving a low placeholder. The legacy (non-PVE) path is unchanged.

Changes

  • internal/lxc/memory.go (new): ParseMemorySize ("16G"/"32768M"/bytes) + hostMemoryBytes (reads /proc/meminfo)
  • internal/lxc/config.go: writePVEConfig resolves memory by the above precedence
  • internal/lxc/manager.go: Manager.DefaultMemoryBytes, threaded to both writePVEConfig call sites
  • cmd/.../main.go: --default-memory flag
  • internal/api/containers.go: dld.memory label
  • tests + readme flags table

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/games-on-whales/LXC2Docker/pull/64 **Author:** [@JBailes](https://github.com/JBailes) **Created:** 6/5/2026 **Status:** ✅ Merged **Merged:** 6/5/2026 **Merged by:** [@JBailes](https://github.com/JBailes) **Base:** `main` ← **Head:** `feat/configurable-default-memory` --- ### 📝 Commits (1) - [`24a8131`](https://github.com/games-on-whales/LXC2Docker/commit/24a813158f0ada76e390d09f92d2881a0b08c231) feat(pve): configurable default container memory (replace hardcoded 4GB) ### 📊 Changes **8 files changed** (+142 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `cmd/docker-lxc-daemon/main.go` (+6 -0) 📝 `internal/api/containers.go` (+10 -0) 📝 `internal/lxc/config.go` (+13 -5) 📝 `internal/lxc/manager.go` (+7 -1) ➕ `internal/lxc/memory.go` (+60 -0) ➕ `internal/lxc/memory_test.go` (+44 -0) 📝 `internal/lxc/pve_tarball.go` (+1 -1) 📝 `readme.md` (+1 -0) </details> ### 📄 Description ## Problem PVE CTs created without an explicit `--memory` were hardcoded to `memory: 4096` in `writePVEConfig`. Any memory-heavy workload that doesn't set a limit (e.g. Wolf's WolfSteam game CTs) gets silently OOM-killed by the cgroup at ~4 GB — observed as deterministic, renderer-independent, log-silent crashes at game world-load. ## Fix Resolve a CT's memory by precedence: 1. `docker --memory` (HostConfig.Memory) 2. `dld.memory` label (per-container, e.g. `dld.memory=32G`) 3. `--default-memory` daemon flag 4. host total RAM — no artificial cap, matching Docker's `Memory=0` semantics Proxmox requires a concrete number, so we resolve one instead of leaving a low placeholder. The legacy (non-PVE) path is unchanged. ## Changes - `internal/lxc/memory.go` (new): `ParseMemorySize` ("16G"/"32768M"/bytes) + `hostMemoryBytes` (reads /proc/meminfo) - `internal/lxc/config.go`: `writePVEConfig` resolves memory by the above precedence - `internal/lxc/manager.go`: `Manager.DefaultMemoryBytes`, threaded to both `writePVEConfig` call sites - `cmd/.../main.go`: `--default-memory` flag - `internal/api/containers.go`: `dld.memory` label - tests + readme flags table --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-15 12:51:44 +00:00
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
games-on-whales/LXC2Docker#65
No description provided.