From 19c62d719c6a2eca41873e1912175bfbd4bc44f3 Mon Sep 17 00:00:00 2001 From: Deyuan Deng Date: Sun, 12 Oct 2014 16:39:48 -0400 Subject: [PATCH] Use DesiredState.Host in scheduler predicate --- pkg/scheduler/predicates.go | 2 +- pkg/scheduler/priorities_test.go | 18 ++++++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/pkg/scheduler/predicates.go b/pkg/scheduler/predicates.go index 74628af4b84..54042389c70 100644 --- a/pkg/scheduler/predicates.go +++ b/pkg/scheduler/predicates.go @@ -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 diff --git a/pkg/scheduler/priorities_test.go b/pkg/scheduler/priorities_test.go index fbc55944e24..49bc1dcfab6 100644 --- a/pkg/scheduler/priorities_test.go +++ b/pkg/scheduler/priorities_test.go @@ -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}, }, }, }