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: Fix the bug of getting the number of windows cpu #97378

Merged
merged 1 commit into from Mar 16, 2021

Conversation

hwdef
Copy link
Member

@hwdef hwdef commented Dec 18, 2020

fix the bug that the number of cpu cannot be obtained normally under Windows

What type of PR is this?

/kind bug

What this PR does / why we need it:

In some cases, kubelet will return an error value when obtaining the number of CPUs, only half of the correct value will be returned.

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

I found the way to fix in https://github.com/microsoft/hcsshim/blob/master/internal/processorinfo/processor_count.go

same issue in moby: moby/moby#38935 (comment)

Does this PR introduce a user-facing change?:

kubelet: Fixed the bug of getting the number of cpu when the number of cpu logical processors is more than 64 in windows

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. kind/bug Categorizes issue or PR as related to a bug. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has 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. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Dec 18, 2020
@k8s-ci-robot k8s-ci-robot added 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 Dec 18, 2020
@hwdef
Copy link
Member Author

hwdef commented Dec 18, 2020

/sig windows

@k8s-ci-robot k8s-ci-robot added the sig/windows Categorizes an issue or PR as relevant to SIG Windows. label Dec 18, 2020
@hwdef
Copy link
Member Author

hwdef commented Dec 18, 2020

/assign @liggitt @thockin @mrunalp

@jayunit100
Copy link
Member

Is there a scheduling e2e or other test that we can have for this as a follow on PR? Seems like verifying this on windows nodes which already can have scheduling issues would be good for the windows conformance suites

@hwdef
Copy link
Member Author

hwdef commented Dec 19, 2020

@jayunit100 My colleagues are testing it, but there are no results yet. I will continue to add if I get the results

@hwdef
Copy link
Member Author

hwdef commented Dec 22, 2020

@jayunit100 we tested it on a server with 72 cores and 144 logical processors(There are a total of 4 cpus, each cpu has 18 cores).

image

Screenshot_20201222_1427131

@ehashman ehashman added this to Needs Reviewer in SIG Node PR Triage Jan 6, 2021
@ehashman
Copy link
Member

/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 Jan 25, 2021
@marosset marosset added this to In Review (v1.21) in SIG-Windows Feb 11, 2021
Copy link
Member

@ehashman ehashman left a comment

Choose a reason for hiding this comment

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

This looks reasonable to me but I'm not a Windows reviewer, leaving for SIG Windows :)

procGlobalMemoryStatusEx = modkernel32.NewProc("GlobalMemoryStatusEx")
modkernel32 = windows.NewLazySystemDLL("kernel32.dll")
procGlobalMemoryStatusEx = modkernel32.NewProc("GlobalMemoryStatusEx")
procGetActiveProcessorCount = modkernel32.NewProc("GetActiveProcessorCount")
Copy link
Member

Choose a reason for hiding this comment

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

@hwdef
Copy link
Member Author

hwdef commented Feb 18, 2021

@marosset
Could you give me some help?

// many of the Windows processor affinity functions will only return the information for a
// single Processor Group. Since a single group can only hold 64 logical processors, this
// means when there are more they will be divided into multiple groups.
// for the above reason, the following function is used to get the cpu number of the windows node.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// for the above reason, the following function is used to get the cpu number of the windows node.
// For the above reason, procGetActiveProcessorCount is used to get the cpu count for all processor groups of the windows node.

Copy link
Member Author

Choose a reason for hiding this comment

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

Already modified, thanks for your review.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for your contribution! if you need a reviewer from sig-windows in the future you can find us in the sig-windows slack

@mrunalp mrunalp moved this from Needs Approver to Waiting on Author in SIG Node PR Triage Mar 11, 2021
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Mar 12, 2021
@jsturtevant
Copy link
Contributor

/milestone v1.21
/priority important-soon
/lgtm

going to run our sig-windows tests for sanity:
/test pull-kubernetes-e2e-aks-engine-windows-containerd

@k8s-ci-robot k8s-ci-robot added the priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. label Mar 12, 2021
@k8s-ci-robot k8s-ci-robot added this to the v1.21 milestone Mar 12, 2021
@k8s-ci-robot k8s-ci-robot added lgtm "Looks good to me", indicates that a PR is ready to be merged. and removed needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Mar 12, 2021
@marosset
Copy link
Contributor

/lgtm

@marosset
Copy link
Contributor

I agree with the comments above about not being able to easily test this in e2e tests if it requires very large amounts of cores.

@marosset
Copy link
Contributor

@hwdef can you add a release note since this does fix a bug other users might run into at some point?

@marosset
Copy link
Contributor

/retest

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-none Denotes a PR that doesn't merit a release note. labels Mar 12, 2021
@hwdef
Copy link
Member Author

hwdef commented Mar 12, 2021

@marosset
Thanks for your reminder, I have added the release note.

@marosset
Copy link
Contributor

/assign @dchen1107 @mrunalp
For pkg\kubelet approval.

@ehashman ehashman moved this from Waiting on Author to Needs Approver in SIG Node PR Triage Mar 12, 2021
@mrunalp
Copy link
Contributor

mrunalp commented Mar 16, 2021

/approve

@mrunalp mrunalp moved this from Needs Approver to Done in SIG Node PR Triage Mar 16, 2021
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: hwdef, mrunalp

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:

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 the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 16, 2021
@k8s-ci-robot k8s-ci-robot merged commit c2ad998 into kubernetes:master Mar 16, 2021
SIG-Windows automation moved this from Reviewed - Needs Approval From Other SIGs to Done (v1.21) Mar 16, 2021
@singholt
Copy link

Is this going to be back-ported to 1.20 and below? Or is it available just on 1.21?

@hwdef
Copy link
Member Author

hwdef commented Aug 18, 2021

@singholt

just support on 1.21. Did not cherrypick to 1.20.

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. area/kubelet cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/node Categorizes an issue or PR as relevant to SIG Node. sig/windows Categorizes an issue or PR as relevant to SIG Windows. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
Development

Successfully merging this pull request may close these issues.

None yet