mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-19 00:31:00 +00:00
skip pod resource check when request is zero
Signed-off-by: forrestchen <forrestchen@tencent.com>
This commit is contained in:
parent
f5ddaa152e
commit
bbf2b968c8
@ -276,7 +276,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",
|
||||
@ -285,7 +285,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",
|
||||
@ -294,7 +294,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",
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user