Skip to content

Add ctr support for CPUMax and CPUShares#6809

Merged
estesp merged 1 commit intocontainerd:mainfrom
jterry75:main
Apr 29, 2022
Merged

Add ctr support for CPUMax and CPUShares#6809
estesp merged 1 commit intocontainerd:mainfrom
jterry75:main

Conversation

@jterry75
Copy link
Copy Markdown
Contributor

Adds CPU.Maximum and CPU.Shares support to the ctr
cmdline for testing

Signed-off-by: Justin Terry [email protected]

@k8s-ci-robot
Copy link
Copy Markdown

Hi @jterry75. Thanks for your PR.

I'm waiting for a containerd 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.

Details

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.

@samuelkarp
Copy link
Copy Markdown
Member

spec.Linux.Resources.CPU section should not be set on GOOS=windows

Looks like the unit tests need to be updated too.

@jterry75
Copy link
Copy Markdown
Contributor Author

Well its kinda a lame test because it doesnt make sense to call WithWindowsCPU* when its LCOW, but either way those methods dont touch Linux so they shouldnt create that resource. I have broken apart setCPU and setResources to have a Windows variant. Lets see if I broke any other tests :)

@theopenlab-ci
Copy link
Copy Markdown

theopenlab-ci Bot commented Apr 15, 2022

Build succeeded.

Copy link
Copy Markdown
Member

@estesp estesp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Copy Markdown
Member

@samuelkarp samuelkarp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jterry75
Copy link
Copy Markdown
Contributor Author

@kevpar - Mind taking a look when you get some time. Thanks! Just a testing change really but it could be used by consumers of the oci package later. Works like a champ though

Comment thread cmd/ctr/commands/commands_windows.go Outdated
Copy link
Copy Markdown
Member

@dcantah dcantah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, small suggestion

Comment thread cmd/ctr/commands/commands_windows.go Outdated
},
cli.Uint64Flag{
Name: "cpu-max",
Usage: "The number of processor cycles threads in a container can use per 10,000 cycles. Set to a percentage times 100. Between 0 and 10,000",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this actually has to be at least 1. Under the hood this translates to setting via JOBOBJECT_CPU_RATE_CONTROL_INFORMATION, and the CpuRate member can't be 0.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! Thanks Kevin

Copy link
Copy Markdown
Member

@kevpar kevpar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comment but LGTM. Thanks Justin!

Adds CPU.Maximum and CPU.Shares support to the ctr
cmdline for testing

Signed-off-by: Justin Terry <[email protected]>
@estesp estesp merged commit 65627f5 into containerd:main Apr 29, 2022
@jterry75 jterry75 deleted the main branch April 29, 2022 16:35
@jterry75 jterry75 restored the main branch April 29, 2022 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants