-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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(env): Add automatic memory limit handling #6591
feat(env): Add automatic memory limit handling #6591
Conversation
Signed-off-by: dongjiang1989 <dongjiang1989@126.com>
LGTM 🥳 |
Signed-off-by: dongjiang1989 <dongjiang1989@126.com>
Thanks. Done added. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unlike the gomaxprocs change, I wonder if it shouldn't be an opt-in feature? My rationale is that GOMAXPROCS is always set to "some" value while GOMEMLIMIT is unset by default (e.g. math.MaxInt64
).
Also should we really consider the system memory if no k8s limits are set? More food for thoughts from https://www.ardanlabs.com/blog/2024/02/kubernetes-memory-limits-go.html:
If you’re not going to use K8s memory limits, then don’t do anything with GOMEMLIMIT. The Go runtime is really good at finding the sweet spot for your memory requirements.
Co-authored-by: Simon Pasquier <spasquie@redhat.com>
To follow-up with my last comment, I'd suggest that we treat <= 0 values as "don't set GOMEMLIMIT" and > 1 values as 1. |
Signed-off-by: dongjiang1989 <dongjiang1989@126.com>
Thank. Got it. @simonpasquier , PTAL |
Signed-off-by: dongjiang1989 <dongjiang1989@126.com>
Signed-off-by: dongjiang1989 <dongjiang1989@126.com>
Signed-off-by: dongjiang1989 <dongjiang1989@126.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Can you make the same change for the admission webhook too? I'd also advise to factorize the argument parsing in internal/goruntime to avoid duplication.
Signed-off-by: dongjiang1989 <dongjiang1989@126.com>
Signed-off-by: dongjiang1989 <dongjiang1989@126.com>
Apply the same modification to the admission webhook as was done. Setting |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pkg/operator/feature_gates*.go aren't need anymore, right? Also the default isn't 0 for all binaries.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for all the bumps here @dongjiang1989! After all the discussions on the PR, I think we're aligned on not using a feature-gate at all, but just disable the feature if -auto-gomemlimit-ratio
is not set.
This means that we'd need to revert all changes made that are related to feature-gates. Thanks for the patience 🙂
Co-authored-by: Simon Pasquier <spasquie@redhat.com>
Thanks. Got it. Please re-check. @ArthurSens |
Signed-off-by: dongjiang1989 <dongjiang1989@126.com>
Signed-off-by: dongjiang1989 <dongjiang1989@126.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks!
Description
Describe the big picture of your changes here to communicate to the maintainers why we should accept this pull request.
If it fixes a bug or resolves a feature request, be sure to link to that issue.
add auto GOMEMLIMIT setting
Type of change
What type of changes does your code introduce to the Prometheus operator? Put an
x
in the box that apply.CHANGE
(fix or feature that would cause existing functionality to not work as expected)FEATURE
(non-breaking change which adds functionality)BUGFIX
(non-breaking change which fixes an issue)ENHANCEMENT
(non-breaking change which improves existing functionality)NONE
(if none of the other choices apply. Example, tooling, build system, CI, docs, etc.)Verification
Please check the Prometheus-Operator testing guidelines for recommendations about automated tests.
Changelog entry
Please put a one-line changelog entry below. This will be copied to the changelog file during the release process.