mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-03 19:58:17 +00:00 
			
		
		
		
	Use Allocatable to replace Capacity
Use allocate instead in priorities
This commit is contained in:
		@@ -54,6 +54,14 @@ func makeResources(milliCPU int64, memory int64, pods int64) api.NodeResources {
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func makeAllocatableResources(milliCPU int64, memory int64, pods int64) api.ResourceList {
 | 
			
		||||
	return api.ResourceList{
 | 
			
		||||
		api.ResourceCPU:    *resource.NewMilliQuantity(milliCPU, resource.DecimalSI),
 | 
			
		||||
		api.ResourceMemory: *resource.NewQuantity(memory, resource.BinarySI),
 | 
			
		||||
		api.ResourcePods:   *resource.NewQuantity(pods, resource.DecimalSI),
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func newResourcePod(usage ...resourceRequest) *api.Pod {
 | 
			
		||||
	containers := []api.Container{}
 | 
			
		||||
	for _, req := range usage {
 | 
			
		||||
@@ -130,7 +138,7 @@ func TestPodFitsResources(t *testing.T) {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for _, test := range enoughPodsTests {
 | 
			
		||||
		node := api.Node{Status: api.NodeStatus{Capacity: makeResources(10, 20, 32).Capacity}}
 | 
			
		||||
		node := api.Node{Status: api.NodeStatus{Capacity: makeResources(10, 20, 32).Capacity, Allocatable: makeAllocatableResources(10, 20, 32)}}
 | 
			
		||||
 | 
			
		||||
		fit := ResourceFit{FakeNodeInfo(node)}
 | 
			
		||||
		fits, err := fit.PodFitsResources(test.pod, test.existingPods, "machine")
 | 
			
		||||
@@ -178,7 +186,7 @@ func TestPodFitsResources(t *testing.T) {
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	for _, test := range notEnoughPodsTests {
 | 
			
		||||
		node := api.Node{Status: api.NodeStatus{Capacity: makeResources(10, 20, 1).Capacity}}
 | 
			
		||||
		node := api.Node{Status: api.NodeStatus{Capacity: api.ResourceList{}, Allocatable: makeAllocatableResources(10, 20, 1)}}
 | 
			
		||||
 | 
			
		||||
		fit := ResourceFit{FakeNodeInfo(node)}
 | 
			
		||||
		fits, err := fit.PodFitsResources(test.pod, test.existingPods, "machine")
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user