mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-05 19:21:37 +00:00
@@ -142,13 +142,13 @@ func (r *ResourceFit) PodFitsResources(pod *api.Pod, existingPods []*api.Pod, no
|
||||
return false, err
|
||||
}
|
||||
if podRequest.milliCPU == 0 && podRequest.memory == 0 {
|
||||
return int64(len(existingPods)) < info.Status.Capacity.MaxPods().Value(), nil
|
||||
return int64(len(existingPods)) < info.Status.Capacity.Pods().Value(), nil
|
||||
}
|
||||
pods := []*api.Pod{}
|
||||
copy(pods, existingPods)
|
||||
pods = append(existingPods, pod)
|
||||
_, exceeding := CheckPodsExceedingCapacity(pods, info.Status.Capacity)
|
||||
if len(exceeding) > 0 || int64(len(pods)) > info.Status.Capacity.MaxPods().Value() {
|
||||
if len(exceeding) > 0 || int64(len(pods)) > info.Status.Capacity.Pods().Value() {
|
||||
return false, nil
|
||||
}
|
||||
return true, nil
|
||||
|
@@ -44,12 +44,12 @@ func (nodes FakeNodeListInfo) GetNodeInfo(nodeName string) (*api.Node, error) {
|
||||
return nil, fmt.Errorf("Unable to find node: %s", nodeName)
|
||||
}
|
||||
|
||||
func makeResources(milliCPU int64, memory int64, maxPods int64) api.NodeResources {
|
||||
func makeResources(milliCPU int64, memory int64, pods int64) api.NodeResources {
|
||||
return api.NodeResources{
|
||||
Capacity: api.ResourceList{
|
||||
"cpu": *resource.NewMilliQuantity(milliCPU, resource.DecimalSI),
|
||||
"memory": *resource.NewQuantity(memory, resource.BinarySI),
|
||||
"maxpods": *resource.NewQuantity(maxPods, resource.DecimalSI),
|
||||
api.ResourceCPU: *resource.NewMilliQuantity(milliCPU, resource.DecimalSI),
|
||||
api.ResourceMemory: *resource.NewQuantity(memory, resource.BinarySI),
|
||||
api.ResourcePods: *resource.NewQuantity(pods, resource.DecimalSI),
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -60,8 +60,8 @@ func newResourcePod(usage ...resourceRequest) *api.Pod {
|
||||
containers = append(containers, api.Container{
|
||||
Resources: api.ResourceRequirements{
|
||||
Limits: api.ResourceList{
|
||||
"cpu": *resource.NewMilliQuantity(req.milliCPU, resource.DecimalSI),
|
||||
"memory": *resource.NewQuantity(req.memory, resource.BinarySI),
|
||||
api.ResourceCPU: *resource.NewMilliQuantity(req.milliCPU, resource.DecimalSI),
|
||||
api.ResourceMemory: *resource.NewQuantity(req.memory, resource.BinarySI),
|
||||
},
|
||||
},
|
||||
})
|
||||
|
Reference in New Issue
Block a user