Skip to content

[stable35] fix(linux): report container memory limits instead of the host's - #1121

Merged
kesselb merged 1 commit into
stable35from
backport/1118/stable35
Sep 9, 2026
Merged

kesselb merged 1 commit into
stable35from
backport/1118/stable35

Conversation

@backportbot

@backportbot backportbot Bot commented Sep 9, 2026

Copy link
Copy Markdown

Backport of PR #1118

/proc/meminfo is not namespaced, so inside Docker, Kubernetes or AIO the
Monitoring page and the OCS API reported the host's RAM rather than the
memory Nextcloud is actually allowed to use. On a 2 GiB container running
on a 64 GiB host, that is off by a factor of 32.

Where a cgroup memory limit applies, read the limit and usage from it
instead, preferring the v2 unified hierarchy and falling back to v1.
Reclaimable page cache is discounted from the usage so that MemAvailable
keeps the meaning it has in /proc/meminfo, and swap is taken from
memory.swap.* on v2 and derived from the memsw counters on v1.

A cgroup that is not more restrictive than the host is ignored, which
covers both "max" on v2 and the near-PHP_INT_MAX sentinel on v1, so hosts
without a limit keep reporting exactly what they reported before.

Signed-off-by: Frank Karlitschek <frank.karlitschek@nextcloud.com>
Assisted-by: Claude Code:claude-opus-5
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@backportbot backportbot Bot added 3. to review AI assisted This PR contains AI-assisted commits labels Sep 9, 2026
@backportbot backportbot Bot added this to the Nextcloud 35 milestone Sep 9, 2026
@karlitschek

Copy link
Copy Markdown
Member

@kesselb
kesselb merged commit 4282657 into stable35 Sep 9, 2026
41 of 42 checks passed
@kesselb
kesselb deleted the backport/1118/stable35 branch September 9, 2026 17:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review AI assisted This PR contains AI-assisted commits

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants