Merge pull request #116408 from ChenLingPeng/fit

skip pod resource check when request is zero
This commit is contained in:
Kubernetes Prow Robot 2023-04-17 11:44:45 -07:00 committed by GitHub
commit 94a15929cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 3 deletions

View File

@ -307,7 +307,7 @@ func fitsRequest(podRequest *preFilterState, nodeInfo *framework.NodeInfo, ignor
return insufficientResources
}
if podRequest.MilliCPU > (nodeInfo.Allocatable.MilliCPU - nodeInfo.Requested.MilliCPU) {
if podRequest.MilliCPU > 0 && podRequest.MilliCPU > (nodeInfo.Allocatable.MilliCPU-nodeInfo.Requested.MilliCPU) {
insufficientResources = append(insufficientResources, InsufficientResource{
ResourceName: v1.ResourceCPU,
Reason: "Insufficient cpu",
@ -316,7 +316,7 @@ func fitsRequest(podRequest *preFilterState, nodeInfo *framework.NodeInfo, ignor
Capacity: nodeInfo.Allocatable.MilliCPU,
})
}
if podRequest.Memory > (nodeInfo.Allocatable.Memory - nodeInfo.Requested.Memory) {
if podRequest.Memory > 0 && podRequest.Memory > (nodeInfo.Allocatable.Memory-nodeInfo.Requested.Memory) {
insufficientResources = append(insufficientResources, InsufficientResource{
ResourceName: v1.ResourceMemory,
Reason: "Insufficient memory",
@ -325,7 +325,8 @@ func fitsRequest(podRequest *preFilterState, nodeInfo *framework.NodeInfo, ignor
Capacity: nodeInfo.Allocatable.Memory,
})
}
if podRequest.EphemeralStorage > (nodeInfo.Allocatable.EphemeralStorage - nodeInfo.Requested.EphemeralStorage) {
if podRequest.EphemeralStorage > 0 &&
podRequest.EphemeralStorage > (nodeInfo.Allocatable.EphemeralStorage-nodeInfo.Requested.EphemeralStorage) {
insufficientResources = append(insufficientResources, InsufficientResource{
ResourceName: v1.ResourceEphemeralStorage,
Reason: "Insufficient ephemeral-storage",

View File

@ -473,6 +473,17 @@ func TestEnoughRequests(t *testing.T) {
name: "skip checking extended resource request with quantity zero via resource groups",
wantInsufficientResources: []InsufficientResource{},
},
{
pod: newResourcePod(
framework.Resource{
ScalarResources: map[v1.ResourceName]int64{
extendedResourceA: 1,
}}),
nodeInfo: framework.NewNodeInfo(newResourcePod(framework.Resource{
MilliCPU: 20, Memory: 30, ScalarResources: map[v1.ResourceName]int64{extendedResourceA: 1}})),
name: "skip checking resource request with quantity zero",
wantInsufficientResources: []InsufficientResource{},
},
}
for _, test := range enoughPodsTests {