mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-17 23:19:26 +00:00
Move the internal minion representation to match v1beta3
Moves to 'Spec' and 'Status' internally and removes duplicate fields. Moves Capacity into Spec and drops use of NodeResources
This commit is contained in:
@@ -122,8 +122,8 @@ func (r *ResourceFit) PodFitsResources(pod api.Pod, existingPods []api.Pod, node
|
||||
}
|
||||
|
||||
// TODO: convert to general purpose resource matching, when pods ask for resources
|
||||
totalMilliCPU := int(resources.GetFloatResource(info.NodeResources.Capacity, resources.CPU, 0) * 1000)
|
||||
totalMemory := resources.GetIntegerResource(info.NodeResources.Capacity, resources.Memory, 0)
|
||||
totalMilliCPU := int(resources.GetFloatResource(info.Spec.Capacity, resources.CPU, 0) * 1000)
|
||||
totalMemory := resources.GetIntegerResource(info.Spec.Capacity, resources.Memory, 0)
|
||||
|
||||
fitsCPU := totalMilliCPU == 0 || (totalMilliCPU-milliCPURequested) >= podRequest.milliCPU
|
||||
fitsMemory := totalMemory == 0 || (totalMemory-memoryRequested) >= podRequest.memory
|
||||
|
@@ -111,7 +111,7 @@ func TestPodFitsResources(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, test := range tests {
|
||||
node := api.Minion{NodeResources: makeResources(10, 20)}
|
||||
node := api.Minion{Spec: api.NodeSpec{Capacity: makeResources(10, 20).Capacity}}
|
||||
|
||||
fit := ResourceFit{FakeNodeInfo(node)}
|
||||
fits, err := fit.PodFitsResources(test.pod, test.existingPods, "machine")
|
||||
@@ -335,7 +335,7 @@ func TestPodFitsSelector(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, test := range tests {
|
||||
node := api.Minion{Labels: test.labels}
|
||||
node := api.Minion{ObjectMeta: api.ObjectMeta{Labels: test.labels}}
|
||||
|
||||
fit := NodeSelector{FakeNodeInfo(node)}
|
||||
fits, err := fit.PodSelectorMatches(test.pod, []api.Pod{}, "machine")
|
||||
|
@@ -41,8 +41,8 @@ func calculateOccupancy(node api.Minion, pods []api.Pod) HostPriority {
|
||||
}
|
||||
}
|
||||
|
||||
percentageCPU := calculatePercentage(totalCPU, resources.GetIntegerResource(node.NodeResources.Capacity, resources.CPU, 0))
|
||||
percentageMemory := calculatePercentage(totalMemory, resources.GetIntegerResource(node.NodeResources.Capacity, resources.Memory, 0))
|
||||
percentageCPU := calculatePercentage(totalCPU, resources.GetIntegerResource(node.Spec.Capacity, resources.CPU, 0))
|
||||
percentageMemory := calculatePercentage(totalMemory, resources.GetIntegerResource(node.Spec.Capacity, resources.Memory, 0))
|
||||
glog.V(4).Infof("Least Requested Priority, AbsoluteRequested: (%d, %d) Percentage:(%d\\%m, %d\\%)", totalCPU, totalMemory, percentageCPU, percentageMemory)
|
||||
|
||||
return HostPriority{
|
||||
|
@@ -28,7 +28,7 @@ import (
|
||||
func makeMinion(node string, cpu, memory int) api.Minion {
|
||||
return api.Minion{
|
||||
ObjectMeta: api.ObjectMeta{Name: node},
|
||||
NodeResources: api.NodeResources{
|
||||
Spec: api.NodeSpec{
|
||||
Capacity: api.ResourceList{
|
||||
resources.CPU: util.NewIntOrStringFromInt(cpu),
|
||||
resources.Memory: util.NewIntOrStringFromInt(memory),
|
||||
|
Reference in New Issue
Block a user