Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get available limit from cgroups if set #9879

Merged
merged 3 commits into from Jun 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions container-disc/src/main/sh/vespa-start-container-daemon.sh
Expand Up @@ -71,6 +71,11 @@ configure_memory() {
available="$VESPA_TOTAL_MEMORY_MB"
else
available=`free -m | grep Mem | tr -s ' ' | cut -f2 -d' '`
if hash cgget 2>/dev/null; then
available_cgroup_bytes=$(cgget -nv -r memory.limit_in_bytes /)
available_cgroup=$((available_cgroup_bytes >> 20))
available=$((available > available_cgroup ? available_cgroup : available))
fi
fi

jvm_heapsize=$((available * jvm_heapSizeAsPercentageOfPhysicalMemory / 100))
Expand Down
Expand Up @@ -118,6 +118,7 @@ public void createContainer(NodeAgentContext context, ContainerData containerDat
if (minMainMemoryAvailableMb > 0) {
// VESPA_TOTAL_MEMORY_MB is used to make any jdisc container think the machine
// only has this much physical memory (overrides total memory reported by `free -m`).
// TODO: Remove after all tenants are running > 7.67
command.withEnvironment("VESPA_TOTAL_MEMORY_MB", Long.toString(minMainMemoryAvailableMb));
}

Expand Down