-
Notifications
You must be signed in to change notification settings - Fork 2.2k
runc update: implement memory.checkBeforeUpdate #3579
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -174,7 +174,14 @@ func unifiedResToSystemdProps(cm *dbusConnManager, res map[string]string) (props | |
| return props, nil | ||
| } | ||
|
|
||
| func genV2ResourcesProperties(r *configs.Resources, cm *dbusConnManager) ([]systemdDbus.Property, error) { | ||
| func genV2ResourcesProperties(dirPath string, r *configs.Resources, cm *dbusConnManager) ([]systemdDbus.Property, error) { | ||
| // We need this check before setting systemd properties, otherwise | ||
| // the container is OOM-killed and the systemd unit is removed | ||
| // before we get to fsMgr.Set(). | ||
| if err := fs2.CheckMemoryUsage(dirPath, r); err != nil { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need this check before setting systemd properties, otherwise the container is OOM-killed and the systemd unit is removed before we get to |
||
| return nil, err | ||
| } | ||
|
|
||
| var properties []systemdDbus.Property | ||
|
|
||
| // NOTE: This is of questionable correctness because we insert our own | ||
|
|
@@ -437,7 +444,7 @@ func (m *UnifiedManager) Set(r *configs.Resources) error { | |
| if r == nil { | ||
| return nil | ||
| } | ||
| properties, err := genV2ResourcesProperties(r, m.dbus) | ||
| properties, err := genV2ResourcesProperties(m.fsMgr.Path(""), r, m.dbus) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -726,3 +726,43 @@ EOF | |
| runc resume test_update | ||
| [ "$status" -eq 0 ] | ||
| } | ||
|
|
||
| @test "update memory vs CheckBeforeUpdate" { | ||
| requires cgroups_v2 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What should happen on cgroups_v1 ?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This knob is for cgroup v2, it is ignored (not used) on v1. Since we're testing the knob here, and not the kernel cgroup behavior, the test requires cgroup v2. I don't know how to write a test to ensure the knob is ignored. In general, runc ignores all the parameters it's not aware of, and cgroup v1 code is not aware of CheckBeforeUpdate. |
||
| [ $EUID -ne 0 ] && requires rootless_cgroup | ||
|
|
||
| runc run -d --console-socket "$CONSOLE_SOCKET" test_update | ||
| [ "$status" -eq 0 ] | ||
|
|
||
| # Setting memory to low value with checkBeforeUpdate=true should fail. | ||
| runc update -r - test_update <<EOF | ||
| { | ||
| "memory": { | ||
| "limit": 1024, | ||
| "checkBeforeUpdate": true | ||
| } | ||
| } | ||
| EOF | ||
| [ "$status" -ne 0 ] | ||
| [[ "$output" == *"rejecting memory limit"* ]] | ||
| testcontainer test_update running | ||
|
|
||
| # Setting memory+swap to low value with checkBeforeUpdate=true should fail. | ||
| runc update -r - test_update <<EOF | ||
| { | ||
| "memory": { | ||
| "limit": 1024, | ||
| "swap": 2048, | ||
| "checkBeforeUpdate": true | ||
| } | ||
| } | ||
| EOF | ||
| [ "$status" -ne 0 ] | ||
| [[ "$output" == *"rejecting memory+swap limit"* ]] | ||
| testcontainer test_update running | ||
|
|
||
| # The container will be OOM killed, and runc might either succeed | ||
| # or fail depending on the timing, so we don't check its exit code. | ||
| runc update test_update --memory 1024 | ||
| testcontainer test_update stopped | ||
| } | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.