mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-03 19:58:17 +00:00 
			
		
		
		
	fix pod created failed when resource request is 0
This commit is contained in:
		@@ -300,6 +300,11 @@ func fitsRequest(podRequest *preFilterState, nodeInfo *framework.NodeInfo, ignor
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for rName, rQuant := range podRequest.ScalarResources {
 | 
						for rName, rQuant := range podRequest.ScalarResources {
 | 
				
			||||||
 | 
							// Skip in case request quantity is zero
 | 
				
			||||||
 | 
							if rQuant == 0 {
 | 
				
			||||||
 | 
								continue
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if v1helper.IsExtendedResourceName(rName) {
 | 
							if v1helper.IsExtendedResourceName(rName) {
 | 
				
			||||||
			// If this resource is one of the extended resources that should be ignored, we will skip checking it.
 | 
								// If this resource is one of the extended resources that should be ignored, we will skip checking it.
 | 
				
			||||||
			// rName is guaranteed to have a slash due to API validation.
 | 
								// rName is guaranteed to have a slash due to API validation.
 | 
				
			||||||
@@ -311,6 +316,7 @@ func fitsRequest(podRequest *preFilterState, nodeInfo *framework.NodeInfo, ignor
 | 
				
			|||||||
				continue
 | 
									continue
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if rQuant > (nodeInfo.Allocatable.ScalarResources[rName] - nodeInfo.Requested.ScalarResources[rName]) {
 | 
							if rQuant > (nodeInfo.Allocatable.ScalarResources[rName] - nodeInfo.Requested.ScalarResources[rName]) {
 | 
				
			||||||
			insufficientResources = append(insufficientResources, InsufficientResource{
 | 
								insufficientResources = append(insufficientResources, InsufficientResource{
 | 
				
			||||||
				ResourceName: rName,
 | 
									ResourceName: rName,
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -462,6 +462,19 @@ func TestEnoughRequests(t *testing.T) {
 | 
				
			|||||||
				},
 | 
									},
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								pod: newResourcePod(
 | 
				
			||||||
 | 
									framework.Resource{
 | 
				
			||||||
 | 
										MilliCPU: 1,
 | 
				
			||||||
 | 
										Memory:   1,
 | 
				
			||||||
 | 
										ScalarResources: map[v1.ResourceName]int64{
 | 
				
			||||||
 | 
											extendedResourceA: 0,
 | 
				
			||||||
 | 
										}}),
 | 
				
			||||||
 | 
								nodeInfo: framework.NewNodeInfo(newResourcePod(framework.Resource{
 | 
				
			||||||
 | 
									MilliCPU: 0, Memory: 0, ScalarResources: map[v1.ResourceName]int64{extendedResourceA: 6}})),
 | 
				
			||||||
 | 
								name:                      "skip checking extended resource request with quantity zero via resource groups",
 | 
				
			||||||
 | 
								wantInsufficientResources: []InsufficientResource{},
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for _, test := range enoughPodsTests {
 | 
						for _, test := range enoughPodsTests {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user