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

feat: auto set GOMEMLIMIT when memory is limited (backport #14882) #15196

Merged
merged 3 commits into from
Jan 10, 2025

Conversation

mergify[bot]
Copy link
Contributor

@mergify mergify bot commented Jan 9, 2025

Motivation/summary

By default memlimit uses all the memory available on the host but if cgroups are used and the process is being limited we want to use the correct max memory.
Use automemlimit lib to set memory limit
Run check every 30s
Similar approach as automaxprocs

Test has to be performed manually (see below) because we can't really restrict the process memory :(

Checklist

For functional changes, consider:

  • Is it observable through the addition of either logging or metrics?
  • Is its use being published in telemetry to enable product improvement?
  • Have system tests been added to avoid regression?

How to test these changes

  • make apm-server
  • docker run -it -v ./:/apm-server --memory=4096m golang
  • cd /apm-server && ./apm-server -e
  • observe the the log line changing the memlimit

Related issues

Closes #14475


This is an automatic backport of pull request #14882 done by [Mergify](https://mergify.com).

* feat: auto set GOMEMLIMIT when memory is limited

use automemlimit lib to set memory limit
run check every 30s

* lint: run make update

* feat: fallback to system if cgroup is not available

(cherry picked from commit 4940a7e)

# Conflicts:
#	NOTICE.txt
#	go.mod
#	go.sum
@mergify mergify bot requested a review from a team as a code owner January 9, 2025 16:22
@mergify mergify bot added the conflicts There is a conflict in the backported pull request label Jan 9, 2025
Copy link
Contributor Author

mergify bot commented Jan 9, 2025

Cherry-pick of 4940a7e has failed:

On branch mergify/bp/8.x/pr-14882
Your branch is up to date with 'origin/8.x'.

You are currently cherry-picking commit 4940a7ea.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	modified:   internal/beatcmd/beat.go
	new file:   internal/beatcmd/memlimit.go

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   NOTICE.txt
	both modified:   go.mod
	both modified:   go.sum

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

@1pkg 1pkg enabled auto-merge (squash) January 10, 2025 00:59
@kruskall
Copy link
Member

@Mergifyio queue

Copy link
Contributor Author

mergify bot commented Jan 10, 2025

queue

✅ The pull request has been merged automatically

The pull request has been merged automatically at 3cd7dc3

@mergify mergify bot merged commit 3cd7dc3 into 8.x Jan 10, 2025
12 checks passed
@mergify mergify bot deleted the mergify/bp/8.x/pr-14882 branch January 10, 2025 13:41
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.

2 participants