mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Use DesiredState.Host in scheduler predicate
This commit is contained in:
parent
695fbee343
commit
19c62d719c
@ -143,7 +143,7 @@ func MapPodsToMachines(lister PodLister) (map[string][]api.Pod, error) {
|
||||
return map[string][]api.Pod{}, err
|
||||
}
|
||||
for _, scheduledPod := range pods {
|
||||
host := scheduledPod.CurrentState.Host
|
||||
host := scheduledPod.DesiredState.Host
|
||||
machineToPods[host] = append(machineToPods[host], scheduledPod)
|
||||
}
|
||||
return machineToPods, nil
|
||||
|
@ -59,6 +59,7 @@ func TestLeastRequested(t *testing.T) {
|
||||
{CPU: 2000},
|
||||
},
|
||||
},
|
||||
Host: "machine1",
|
||||
}
|
||||
cpuAndMemory := api.PodState{
|
||||
Manifest: api.ContainerManifest{
|
||||
@ -67,6 +68,7 @@ func TestLeastRequested(t *testing.T) {
|
||||
{CPU: 2000, Memory: 3000},
|
||||
},
|
||||
},
|
||||
Host: "machine2",
|
||||
}
|
||||
tests := []struct {
|
||||
pod api.Pod
|
||||
@ -85,10 +87,10 @@ func TestLeastRequested(t *testing.T) {
|
||||
expectedList: []HostPriority{{"machine1", 0}, {"machine2", 0}},
|
||||
test: "no resources requested",
|
||||
pods: []api.Pod{
|
||||
{CurrentState: machine1State, Labels: labels2},
|
||||
{CurrentState: machine1State, Labels: labels1},
|
||||
{CurrentState: machine2State, Labels: labels1},
|
||||
{CurrentState: machine2State, Labels: labels1},
|
||||
{DesiredState: machine1State, Labels: labels2},
|
||||
{DesiredState: machine1State, Labels: labels1},
|
||||
{DesiredState: machine2State, Labels: labels1},
|
||||
{DesiredState: machine2State, Labels: labels1},
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -96,8 +98,8 @@ func TestLeastRequested(t *testing.T) {
|
||||
expectedList: []HostPriority{{"machine1", 37 /* int(75% / 2) */}, {"machine2", 62 /* int( 75% + 50% / 2) */}},
|
||||
test: "no resources requested",
|
||||
pods: []api.Pod{
|
||||
{DesiredState: cpuOnly, CurrentState: machine1State},
|
||||
{DesiredState: cpuAndMemory, CurrentState: machine2State},
|
||||
{DesiredState: cpuOnly},
|
||||
{DesiredState: cpuAndMemory},
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -105,8 +107,8 @@ func TestLeastRequested(t *testing.T) {
|
||||
expectedList: []HostPriority{{"machine1", 0}, {"machine2", 0}},
|
||||
test: "zero minion resources",
|
||||
pods: []api.Pod{
|
||||
{DesiredState: cpuOnly, CurrentState: machine1State},
|
||||
{DesiredState: cpuAndMemory, CurrentState: machine2State},
|
||||
{DesiredState: cpuOnly},
|
||||
{DesiredState: cpuAndMemory},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user