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

Add configurable container minimum memory limit #7832

Conversation

roman-kiselenko
Copy link
Member

@roman-kiselenko roman-kiselenko commented Mar 4, 2024

What type of PR is this?

/kind feature

What this PR does / why we need it:

Provide a way to configure container minimum memory limit per OCI runtime.

Which issue(s) this PR fixes:

Fixes #7694

Special notes for your reviewer:

None

Does this PR introduce a user-facing change?

Add configurable container minimum memory limit that can be set per OCI runtime.

@openshift-ci openshift-ci bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. labels Mar 4, 2024
@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 4, 2024
@openshift-ci openshift-ci bot added dco-signoff: yes Indicates the PR's author has DCO signed all their commits. kind/feature Categorizes issue or PR as related to a new feature. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Mar 4, 2024
Copy link
Contributor

openshift-ci bot commented Mar 4, 2024

Hi @roman-kiselenko. Thanks for your PR.

I'm waiting for a cri-o member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@kwilczynski
Copy link
Member

/ok-to-test

@openshift-ci openshift-ci bot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Mar 4, 2024
@saschagrunert
Copy link
Member

@roman-kiselenko do you mind rebasing on top of the latest main branch?

@roman-kiselenko
Copy link
Member Author

@roman-kiselenko do you mind rebasing on top of the latest main branch?

@saschagrunert

It's not ready yet, I'm almost done with the implementation, and after adding some test will perform rebase and request the review. 🙏

@roman-kiselenko roman-kiselenko force-pushed the feature/configurable-minimum-memory-limit branch 2 times, most recently from f24bec4 to 56871bd Compare March 5, 2024 09:47
@openshift-ci openshift-ci bot added dco-signoff: no Indicates the PR's author has not DCO signed all their commits. and removed dco-signoff: yes Indicates the PR's author has DCO signed all their commits. labels Mar 5, 2024
@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 5, 2024
@roman-kiselenko roman-kiselenko force-pushed the feature/configurable-minimum-memory-limit branch from 56871bd to e496350 Compare March 5, 2024 09:52
@openshift-ci openshift-ci bot added dco-signoff: yes Indicates the PR's author has DCO signed all their commits. and removed dco-signoff: no Indicates the PR's author has not DCO signed all their commits. labels Mar 5, 2024
Copy link

codecov bot commented Mar 5, 2024

Codecov Report

Merging #7832 (9fa92d1) into main (f63de87) will increase coverage by 0.88%.
Report is 68 commits behind head on main.
The diff coverage is 27.08%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7832      +/-   ##
==========================================
+ Coverage   48.94%   49.82%   +0.88%     
==========================================
  Files         151      153       +2     
  Lines       16426    16635     +209     
==========================================
+ Hits         8039     8288     +249     
+ Misses       7412     7324      -88     
- Partials      975     1023      +48     

@kwilczynski
Copy link
Member

kwilczynski commented Mar 5, 2024

@roman-kiselenko, looks great so far! Thank you! 🚀

Some ideas on how this would be deployed.

  • There will be a default hardcoded limit, a minimal memory limit, we will fallback to if nothing else is set

(somewhere within the code base)

const defaultContainerMinimumMemory = 7.5 * 1024 * 1024 // 7.5 MiB
  • crio.conf will take the following (for the relevant tables TOML tables):

A default of 7.5 or 12 MiB (something that remains to be seen) is overridden by the following:

(within a crio.conf configuration file)

[crio.runtime]
container_minimum_memory = "7680K"

Which then overrides this setting for a specific runtime, such as crun, for example:

[crio.runtime.runtimes.crun]
container_minimum_memory = "384K"

(somewhere in the terminal on the commnad-line)

Above, irregardless where the value was set, can be then overridden with directly specifying value via a command-line switch such as the --default-container-minimum-memory, or for a specific runtime via the --runtimes command-line switch that has a specific format to follow.


Since both Docker and Podman allow users to supply values using more of a human-friendly way, such as ability to provide units next to values, which makes it easier to say 7.5M (or 7.5m) to denote 7.5 MiB rather than 7864320 (bytes), which is easy to get wrong.

This parsing and conversion to bytes can be done using the RAMInBytes() helper from the go-units package that we already include as dependency.

Granted, this then makes it a little more inconvenient to deal with in therm of the type of the field with a corresponding configuration type (as in, Go type, that is). However, since this value is used once when setting up cgroups into which the container will be place, so at a very beginning, then there is no need to cache this and a calculation of a bytes value on-the-fly via some helper would be fine, I belive.

Thoughts?

@roman-kiselenko roman-kiselenko force-pushed the feature/configurable-minimum-memory-limit branch 2 times, most recently from 38a0c39 to 40655e5 Compare March 6, 2024 08:08
@roman-kiselenko
Copy link
Member Author

@kwilczynski SGTM.

I've done changes from int64 to string representation, going to add some tests now.

@roman-kiselenko roman-kiselenko force-pushed the feature/configurable-minimum-memory-limit branch 3 times, most recently from 5873249 to 262b873 Compare March 6, 2024 16:40
@roman-kiselenko roman-kiselenko marked this pull request as ready for review March 6, 2024 16:51
@roman-kiselenko roman-kiselenko force-pushed the feature/configurable-minimum-memory-limit branch 2 times, most recently from 2696308 to 74dfb15 Compare April 12, 2024 13:46
@roman-kiselenko
Copy link
Member Author

Do we want to add an integration test for that feature?

Added some integration tests, PTAL

test/image.bats Outdated Show resolved Hide resolved
@roman-kiselenko roman-kiselenko force-pushed the feature/configurable-minimum-memory-limit branch 3 times, most recently from 1262fab to f30f8fc Compare April 12, 2024 16:02
--runtimes:container_min_memory

Signed-off-by: roman-kiselenko <roman.kiselenko.dev@gmail.com>
@roman-kiselenko
Copy link
Member Author

/retest

@kwilczynski
Copy link
Member

@cri-o/cri-o-maintainers, please have another look at this! Thank you!

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Apr 15, 2024
@kwilczynski
Copy link
Member

/approve
/lgtm

Copy link
Contributor

openshift-ci bot commented Apr 15, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: haircommander, kwilczynski, roman-kiselenko, saschagrunert

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [haircommander,saschagrunert]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kwilczynski
Copy link
Member

/unhold

@openshift-ci openshift-ci bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 15, 2024
@openshift-merge-bot openshift-merge-bot bot merged commit ace5c68 into cri-o:main Apr 15, 2024
63 checks passed
@roman-kiselenko roman-kiselenko deleted the feature/configurable-minimum-memory-limit branch April 15, 2024 12:37
@kwilczynski
Copy link
Member

/cherry-pick release-1.29

@openshift-cherrypick-robot

@kwilczynski: cannot checkout 1.29: error checking out "1.29": exit status 1 error: pathspec '1.29' did not match any file(s) known to git

In response to this:

/cherry-pick 1.29

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@openshift-cherrypick-robot

@kwilczynski: #7832 failed to apply on top of branch "release-1.29":

Applying: Implement configurable container minimum memory limit per OCI runtime.
Using index info to reconstruct a base tree...
M	completions/fish/crio.fish
M	docs/crio.8.md
M	docs/crio.conf.5.md
M	internal/config/cgmgr/cgmgr_linux.go
M	internal/config/cgmgr/cgmgr_test.go
M	internal/config/cgmgr/cgmgr_unsupported.go
M	internal/config/cgmgr/cgroupfs_linux.go
M	internal/config/cgmgr/systemd_linux.go
M	internal/criocli/criocli.go
M	internal/oci/oci.go
M	pkg/config/config.go
M	pkg/config/config_test.go
M	pkg/config/template.go
M	server/container_create_linux.go
M	server/nri-api.go
M	server/sandbox_run_linux.go
M	test/image.bats
Falling back to patching base and 3-way merge...
Auto-merging test/image.bats
CONFLICT (content): Merge conflict in test/image.bats
Auto-merging server/sandbox_run_linux.go
Auto-merging server/nri-api.go
Auto-merging server/container_create_linux.go
Auto-merging pkg/config/template.go
Auto-merging pkg/config/config_test.go
Auto-merging pkg/config/config.go
Auto-merging internal/oci/oci.go
CONFLICT (content): Merge conflict in internal/oci/oci.go
Auto-merging internal/criocli/criocli.go
Auto-merging internal/config/cgmgr/systemd_linux.go
Auto-merging internal/config/cgmgr/cgroupfs_linux.go
Auto-merging internal/config/cgmgr/cgmgr_unsupported.go
Auto-merging internal/config/cgmgr/cgmgr_test.go
Auto-merging internal/config/cgmgr/cgmgr_linux.go
CONFLICT (content): Merge conflict in internal/config/cgmgr/cgmgr_linux.go
Auto-merging docs/crio.conf.5.md
Auto-merging docs/crio.8.md
Auto-merging completions/fish/crio.fish
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 Implement configurable container minimum memory limit per OCI runtime.
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

In response to this:

/cherry-pick release-1.29

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@kwilczynski
Copy link
Member

kwilczynski commented Apr 15, 2024

OK. Requires manual cherry-pick.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. dco-signoff: yes Indicates the PR's author has DCO signed all their commits. kind/feature Categorizes issue or PR as related to a new feature. lgtm Indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note Denotes a PR that will be considered when it comes time to generate release notes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

configurable minimum memory limit
6 participants