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

kubelet: consider real CPU topology when check Core/Socket free #124561

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mtawaken
Copy link

What type of PR is this?

/kind bug

What this PR does / why we need it:

For certain CPU Topolgy(HT enabled, Multi Socket etc. ) with some CPU offline, the CPUsPerSocket/CPUsPerCore fails to conclude the correct result, and further causes misjudgement in isCoreFree/isSocketFree.

The isCoreFree/isSocketFree function should consider real topology, just like what isNumaNodeFree does.

Which issue(s) this PR fixes:

Fixes #124066

Special notes for your reviewer:

Does this PR introduce a user-facing change?

None

@k8s-ci-robot
Copy link
Contributor

Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it.

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.

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. kind/bug Categorizes issue or PR as related to a bug. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Apr 26, 2024
Copy link

linux-foundation-easycla bot commented Apr 26, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

@k8s-ci-robot k8s-ci-robot added cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Apr 26, 2024
@k8s-ci-robot
Copy link
Contributor

Welcome @mtawaken!

It looks like this is your first PR to kubernetes/kubernetes 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes/kubernetes has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Apr 26, 2024
@k8s-ci-robot
Copy link
Contributor

Hi @mtawaken. Thanks for your PR.

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

@k8s-ci-robot k8s-ci-robot added needs-priority Indicates a PR lacks a `priority/foo` label and requires one. area/kubelet sig/node Categorizes an issue or PR as relevant to SIG Node. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Apr 26, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: mtawaken
Once this PR has been reviewed and has the lgtm label, please assign derekwaynecarr for approval. For more information see the Kubernetes Code Review Process.

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

Needs approval from an approver in each of these files:

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

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Apr 26, 2024
@ffromani
Copy link
Contributor

/ok-to-test

@k8s-ci-robot k8s-ci-robot 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 Apr 27, 2024
@ffromani
Copy link
Contributor

/cc
/triage accepted

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Apr 27, 2024
@bart0sh bart0sh added this to Triage in SIG Node PR Triage Apr 27, 2024
@bart0sh bart0sh moved this from Triage to Needs Reviewer in SIG Node PR Triage Apr 27, 2024
Copy link
Contributor

@ffromani ffromani left a comment

Choose a reason for hiding this comment

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

I agree this is an improvement, but also a partial fix. It seems to me a complete fix will be much more complex and perhaps would require changes even at cadvisor/cri level to expose a more detailed topology. The feasibility is uncertain.

I for myself I'd like to push this PR forward, but during the conversation inhttps://github.com//issues/124066 it seems more changes are needed to also fix full-pcpus-only.

@@ -251,13 +251,13 @@ func (a *cpuAccumulator) isNUMANodeFree(numaID int) bool {
// Returns true if the supplied socket is fully available in `a.details`.
// "fully available" means that all the CPUs in it are free.
func (a *cpuAccumulator) isSocketFree(socketID int) bool {
return a.details.CPUsInSockets(socketID).Size() == a.topo.CPUsPerSocket()
return a.details.CPUsInSockets(socketID).Size() == a.topo.CPUDetails.CPUsInSockets(socketID).Size()
Copy link
Contributor

Choose a reason for hiding this comment

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

if CPUsPerSocket is no longer used (it should be the case) let's delete it

Copy link
Author

Choose a reason for hiding this comment

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

done it

}

// Returns true if the supplied core is fully available in `a.details`.
// "fully available" means that all the CPUs in it are free.
func (a *cpuAccumulator) isCoreFree(coreID int) bool {
return a.details.CPUsInCores(coreID).Size() == a.topo.CPUsPerCore()
return a.details.CPUsInCores(coreID).Size() == a.topo.CPUDetails.CPUsInCores(coreID).Size()
Copy link
Contributor

Choose a reason for hiding this comment

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

considering the issue #124066 as example, with this change the offlined core (id=25) won't be used, right?

Copy link
Author

Choose a reason for hiding this comment

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

  1. Yes, the CPU(id=25) would not be used by container allocation because Core(id=25) has already allocated CPU(id=25) in previous Reserved Core allocation process. The buggy part is in acc.takeFullCores invoked by takeByTopologyNUMAPacked during container allocation. It thought Core(id=25) was free before this fix and used CPU(id=25),CPU(id=73) directly by refering raw Topo.
  2. the core containing offline CPU(id=95) is not id=25, but id=47. it just affects isCoreFree. the offlined CPU(id=95) is never used because it does not appears in Topo(discovered by advisor) anyway.

Copy link
Contributor

Choose a reason for hiding this comment

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

ok, thanks

@ffromani
Copy link
Contributor

/triage accepted
/priority important-longterm

@k8s-ci-robot k8s-ci-robot added priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. and removed needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Apr 29, 2024
@ffromani
Copy link
Contributor

/release-note none

@swatisehgal
Copy link
Contributor

/cc

@mtawaken
Copy link
Author

mtawaken commented Apr 30, 2024

I agree this is an improvement, but also a partial fix. It seems to me a complete fix will be much more complex and perhaps would require changes even at cadvisor/cri level to expose a more detailed topology. The feasibility is uncertain.

I for myself I'd like to push this PR forward, but during the conversation inhttps://github.com//issues/124066 it seems more changes are needed to also fix full-pcpus-only.

The only reference of CPUsPerCore is with full-pcpus-only. I try to correct the behavior by changing it to MaxCPUsPerCore to approximate what we expect. It works for both old and the offline scenarios.

About the takeByTopologyNUMADistributed method

  1. it works only with cpuGroupSize parameter, no NumCores stuff involved, so CPU offline seems not affect its logic.
  2. a little beyond this issue, since it only cares about CPU num and make takeByTopologyNUMAPacked do the Core aware stuffs, the full-pcpus-only requirement actually cannot hold all the time, i provides a testcase in TestTakeByTopologyNUMADistributed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/kubelet cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. kind/bug Categorizes issue or PR as related to a bug. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. sig/node Categorizes an issue or PR as relevant to SIG Node. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
SIG Node PR Triage
Needs Reviewer
Development

Successfully merging this pull request may close these issues.

kubelet fails to restart with CPUManager policy static when node's some CPU is offline
4 participants