-
Notifications
You must be signed in to change notification settings - Fork 516
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
containerd: resource-limit settings for oci default #3206
containerd: resource-limit settings for oci default #3206
Conversation
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.
Looks like it's doing what's expected. I ran:
apiclient apply <<EOF
[settings.oci-defaults.resource-limits.max-address-space]
hard-limit = 2000000000
soft-limit = 1000000000
[settings.oci-defaults.resource-limits.max-core-file-size]
hard-limit = 2000000000
soft-limit = 1000000000
[settings.oci-defaults.resource-limits.max-cpu-time]
hard-limit = 10000
soft-limit = 1000
[settings.oci-defaults.resource-limits.max-data-size]
hard-limit = 1000000000
soft-limit = 100000000
[settings.oci-defaults.resource-limits.max-file-locks]
hard-limit = 2048
soft-limit = 1024
[settings.oci-defaults.resource-limits.max-file-size]
hard-limit = 204800
soft-limit = 102400
[settings.oci-defaults.resource-limits.max-locked-memory]
hard-limit = 1000000000
soft-limit = 100000000
[settings.oci-defaults.resource-limits.max-msgqueue-size]
hard-limit = 1000000001
soft-limit = 1000000000
[settings.oci-defaults.resource-limits.max-nice-priority]
hard-limit = 7
soft-limit = 6
[settings.oci-defaults.resource-limits.max-open-files]
hard-limit = 1048576
soft-limit = 65536
[settings.oci-defaults.resource-limits.max-pending-signals]
hard-limit = 1000
soft-limit = 500
[settings.oci-defaults.resource-limits.max-processes]
hard-limit = 10000
soft-limit = 9999
[settings.oci-defaults.resource-limits.max-realtime-priority]
hard-limit = 1000000000
soft-limit = 100000000
[settings.oci-defaults.resource-limits.max-realtime-timeout]
hard-limit = 1000000000
soft-limit = 100000000
[settings.oci-defaults.resource-limits.max-resident-set]
hard-limit = 1000000000
soft-limit = 100000000
[settings.oci-defaults.resource-limits.max-stack-size]
hard-limit = 1000000000
soft-limit = 100000000
EOF
Which results in /etc/containerd/cri-base.json
containing:
"rlimits": [{ "type": "RLIMIT_SIGPENDING", "hard": 1000, "soft": 500 },
{ "type": "RLIMIT_RTPRIO", "hard": 1000000000, "soft": 100000000 },
{ "type": "RLIMIT_RSS", "hard": 1000000000, "soft": 100000000 },
{ "type": "RLIMIT_NICE", "hard": 7, "soft": 6 },
{ "type": "RLIMIT_CORE", "hard": 2000000000, "soft": 1000000000 },
{ "type": "RLIMIT_NPROC", "hard": 10000, "soft": 9999 },
{ "type": "RLIMIT_AS", "hard": 2000000000, "soft": 1000000000 },
{ "type": "RLIMIT_RTTIME", "hard": 1000000000, "soft": 100000000 },
{ "type": "RLIMIT_NOFILE", "hard": 1048576, "soft": 65536 },
{ "type": "RLIMIT_STACK", "hard": 1000000000, "soft": 100000000 },
{ "type": "RLIMIT_CPU", "hard": 10000, "soft": 1000 },
{ "type": "RLIMIT_MEMLOCK", "hard": 1000000000, "soft": 100000000 },
{ "type": "RLIMIT_FSIZE", "hard": 204800, "soft": 102400 },
{ "type": "RLIMIT_MSGQUEUE", "hard": 1000000001, "soft": 1000000000 },
{ "type": "RLIMIT_LOCKS", "hard": 2048, "soft": 1024 },
{ "type": "RLIMIT_DATA", "hard": 1000000000, "soft": 100000000 }]
I do think you will need an AddPrefixesMigration
migration though since these values didn't exist before. Might be good to confirm that with someone else that has a stronger grasp of our migration/datastore handling though.
That's correct. Consider the following workflow:
An |
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.
nice! 🚀
sources/api/migration/migrations/v1.15.0/oci-defaults-resource-setting/src/main.rs
Outdated
Show resolved
Hide resolved
This can now be rebased on the latest |
42a8442
to
716aeb3
Compare
66ae8f0
to
5f0ce28
Compare
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.
This looks good. I do wonder if we do any validation on these values. For example, setting a soft limit above the hard limit is not possible or setting a value for nice outside of -20 - 19. I'm not sure what we would do in those cases, but its worth considering if there is anything we would like to do there.
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.
It'd be nice to confirm that -1
(for "infinity" / "unlimited") is accepted everywhere, or else to document what the right value to use is in order to get that behavior:
[settings.oci-defaults.resource-limits.max-address-space]
hard-limit = -1
soft-limit = -1
I'm not confident that -1
will deserialize into u32::MAX
, and I could see someone wanting to raise or remove a limit at runtime that they specified at launch time. That could be a problem since we don't allow settings to be deleted.
sources/api/migration/migrations/v1.15.0/oci-defaults-resource-setting/src/main.rs
Outdated
Show resolved
Hide resolved
83f7609
to
38cc70d
Compare
29cf6c5
to
9069667
Compare
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.
Code LGTM. One nit on the doc table, and I still have that open question about how to specify "unlimited" via settings, and making sure that works.
cbcd50a
to
491034b
Compare
Now we can use "unlimited" string to set any rlimit as unlimited. |
c006f7a
to
5a6ae24
Compare
cb3e8b9
to
2da9108
Compare
Allow range of 0- i64::Max as limit and -1 and "unlimited" string to mark any limit as unlimited. |
660c0c8
to
53ae3aa
Compare
sources/api/migration/migrations/v1.15.0/oci-defaults-max-open-files/src/main.rs
Outdated
Show resolved
Hide resolved
sources/api/migration/migrations/v1.15.0/oci-defaults-max-open-files/src/main.rs
Show resolved
Hide resolved
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.
Very nice. Some of the documentation and code can be tightened up to convey the essential information and avoid repetition, but the logic looks solid.
sources/api/migration/migrations/v1.15.0/oci-defaults-max-open-files/src/main.rs
Outdated
Show resolved
Hide resolved
53ae3aa
to
cf092d7
Compare
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.
LGTM with a few nits.
sources/api/migration/migrations/v1.15.0/oci-defaults-max-open-files/src/main.rs
Outdated
Show resolved
Hide resolved
cf092d7
to
664b49e
Compare
Add following rlimits settings for k8s variants, to enable updating these from api client. MaxAddressSpace, MaxCoreFileSize, MaxCpuTime, MaxDataSize, MaxFileLocks, MaxFileSize, MaxLockedMemory, MaxMsgqueueSize, MaxNicePriority, MaxPendingSignals, MaxProcesses, MaxRealtimePriority, MaxRealtimeTimeout, MaxResidentSet, MaxStackSize
This migration will handle the added resource limits settings added for k8s variants. The migration oci-defaults-max-open-files handles the limit values on upgrade and downgrade. If RLIMIT_NOFILE is unlimited or more than u32::Max, then it will changed to max possible value in version lesser than 1.15.0.
664b49e
to
04e2201
Compare
I have tested this change again with all the migrations. The change is working as expected. |
Issue number:
Closes #2814 #2862
Description of changes:
Enable the capability to set the values for following resource limits
MaxAddressSpace,
MaxCoreFileSize,
MaxCpuTime,
MaxDataSize,
MaxFileLocks,
MaxFileSize,
MaxLockedMemory,
MaxMsgqueueSize,
MaxNicePriority,
MaxPendingSignals,
MaxProcesses,
MaxRealtimePriority,
MaxRealtimeTimeout,
MaxResidentSet,
MaxStackSize
Testing done:
- Create a sample nginx workload container launched via kubernetes and check /proc/self/limits - This has default value for Max locked memory as 65536.
- Change Max locked memory setting using api client to 6536.
- Create another container that runs the nginx image and check the /proc/self/limits - This has default value for Max locked memory as 6536.
- Create an ami with 1.14.3 version and create instance using that.
- Try to set the max-locked-memory setting- 1.14.3 will not allow to do this setting.
- Upgrade to 1.15.0 with the image in your custom TUF repo.
- Try to set the max-locked-memory setting- 1.15.0 will allow to do memlock setting and add this in etc/containerd/cri_base.json.
- Downgrade back to the older version 1.14.3.
- Try to set the max-locked-memory setting- 1.14.3 will not allow to do this setting.
Terms of contribution:
By submitting this pull request, I agree that this contribution is dual-licensed under the terms of both the Apache License, version 2.0, and the MIT license.