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

fix pod created failed when resource request is 0 #111544

Merged
merged 1 commit into from
Sep 2, 2022

Conversation

jlsong01
Copy link
Contributor

@jlsong01 jlsong01 commented Jul 29, 2022

What type of PR is this?

/kind bug
/sig node

What this PR does / why we need it:

Pod creation should not fail in case request resource is zero.

In terms of tolerating 0-requested req in scheduler, it's a good-to-have and not a root fix to this issue (#109191 (comment))

Which issue(s) this PR fixes:

Relevant to #109191

Special notes for your reviewer:

This PR mitigates (when req is 0) instead of fixing the original issue.

Does this PR introduce a user-facing change?

NONE

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

NONE

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. kind/bug Categorizes issue or PR as related to a bug. 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 Jul 29, 2022
@k8s-ci-robot k8s-ci-robot added sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Jul 29, 2022
@jlsong01
Copy link
Contributor Author

/retest

@jlsong01
Copy link
Contributor Author

/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 Jul 30, 2022
@yxxhero
Copy link
Member

yxxhero commented Jul 30, 2022

@jlsong01 Please add some unittest for this PR. Thanks very much.

@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Jul 30, 2022
@jlsong01
Copy link
Contributor Author

@jlsong01 Please add some unittest for this PR. Thanks very much.

@yxxhero thanks for your comments. unit test has been added.

@yxxhero
Copy link
Member

yxxhero commented Jul 31, 2022

@jlsong01 Is it more elegant to use switch? Thanks very much.

@kerthcet
Copy link
Member

kerthcet commented Aug 2, 2022

Add comment at #109191 (comment), I may treat this not fix the bug, but related, for request values are not right even with this patch.

if rQuant > (nodeInfo.Allocatable.ScalarResources[rName] - nodeInfo.Requested.ScalarResources[rName]) {

// Skip in case request quantity is zero
if rQuant == 0 {
Copy link
Member

Choose a reason for hiding this comment

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

let's add this to the head of the loop, it's more efficient.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

ScalarResources: map[v1.ResourceName]int64{
kubernetesIOResourceA: 0,
}}),
nodeInfo: framework.NewNodeInfo(newResourcePod(framework.Resource{MilliCPU: 0, Memory: 0})),
Copy link
Member

Choose a reason for hiding this comment

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

Can we cover this case with (nodeInfo.Allocatable.ScalarResources[rName] - nodeInfo.Requested.ScalarResources[rName]) < 0, which mocks the bug we met.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. updated the case as allocatable 5 and Requested 6 for extendedResourceA, which should hit the bug we met.

@jlsong01
Copy link
Contributor Author

jlsong01 commented Aug 2, 2022

@jlsong01 Is it more elegant to use switch? Thanks very much.

@yxxhero yeah, switch is more elegant. since the case has been moved to the head of the loop, we may not need it anymore. Anyway, thanks for the suggestion.

@jlsong01 jlsong01 requested a review from kerthcet August 3, 2022 01:32
@kerthcet
Copy link
Member

kerthcet commented Aug 3, 2022

Totally looks good to me, so I labelled with LGTM, but we may get some advices from sig-node expert. Although we changed codes in scheduler, but this is a common function shared by scheduler and kubelet. See

admissionResults := scheduler.AdmissionCheck(pod, nodeInfo, true)

cc @mrunalp
/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 3, 2022
@kerthcet
Copy link
Member

kerthcet commented Aug 3, 2022

Besides, we're code freeze now, we may merge this PR in the next release v1.26.

@jlsong01
Copy link
Contributor Author

jlsong01 commented Aug 6, 2022

/assign @Huang-Wei
for approval

@Huang-Wei
Copy link
Member

@jlsong01 could you revise the description section a bit - as commented in the original issue #109191 (comment): this PR mitigates (when req is 0) instead of fixing the original issue.

@jlsong01
Copy link
Contributor Author

jlsong01 commented Aug 29, 2022

@jlsong01 could you revise the description section a bit - as commented in the original issue #109191 (comment): this PR mitigates (when req is 0) instead of fixing the original issue.

@Huang-Wei The PR's description has been revised. If anything else needed, please let me know :-)

@Huang-Wei
Copy link
Member

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Huang-Wei, jlsong01

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 Sep 2, 2022
@k8s-ci-robot k8s-ci-robot merged commit f0fa987 into kubernetes:master Sep 2, 2022
@k8s-ci-robot k8s-ci-robot added this to the v1.26 milestone Sep 2, 2022
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. 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. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. release-note-none Denotes a PR that doesn't merit a release note. sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants