@@ -35,6 +35,7 @@ func TestTrySchedulePods(t *testing.T) {
3535 nodes []* apiv1.Node
3636 pods []* apiv1.Pod
3737 newPods []* apiv1.Pod
38+ hints map [* apiv1.Pod ]string
3839 acceptableNodes func (* framework.NodeInfo ) bool
3940 wantStatuses []Status
4041 wantErr bool
@@ -58,6 +59,27 @@ func TestTrySchedulePods(t *testing.T) {
5859 {Pod : BuildTestPod ("p3" , 500 , 500000 ), NodeName : "n1" },
5960 },
6061 },
62+
63+ {
64+ desc : "hinted Node no longer in the cluster doesn't cause an error" ,
65+ nodes : []* apiv1.Node {
66+ buildReadyNode ("n1" , 1000 , 2000000 ),
67+ buildReadyNode ("n2" , 1000 , 2000000 ),
68+ },
69+ pods : []* apiv1.Pod {
70+ buildScheduledPod ("p1" , 300 , 500000 , "n1" ),
71+ },
72+ newPods : []* apiv1.Pod {
73+ BuildTestPod ("p2" , 800 , 500000 ),
74+ BuildTestPod ("p3" , 500 , 500000 ),
75+ },
76+ hints : map [* apiv1.Pod ]string {BuildTestPod ("p2" , 800 , 500000 ): "non-existing-node" },
77+ acceptableNodes : ScheduleAnywhere ,
78+ wantStatuses : []Status {
79+ {Pod : BuildTestPod ("p2" , 800 , 500000 ), NodeName : "n2" },
80+ {Pod : BuildTestPod ("p3" , 500 , 500000 ), NodeName : "n1" },
81+ },
82+ },
6183 {
6284 desc : "three new pods, two nodes, no fit" ,
6385 nodes : []* apiv1.Node {
@@ -136,6 +158,11 @@ func TestTrySchedulePods(t *testing.T) {
136158 clusterSnapshot := testsnapshot .NewTestSnapshotOrDie (t )
137159 clustersnapshot .InitializeClusterSnapshotOrDie (t , clusterSnapshot , tc .nodes , tc .pods )
138160 s := NewHintingSimulator ()
161+
162+ for pod , nodeName := range tc .hints {
163+ s .hints .Set (HintKeyFromPod (pod ), nodeName )
164+ }
165+
139166 statuses , _ , err := s .TrySchedulePods (clusterSnapshot , tc .newPods , tc .acceptableNodes , false )
140167 if tc .wantErr {
141168 assert .Error (t , err )
0 commit comments