Skip to content

Commit 7b4069e

Browse files
authored
Merge pull request #7596 from towca/jtuznik/schedule-fix
CA: don't error out in HintingSimulator if a hinted Node is gone
2 parents e45c1d1 + 4e283e3 commit 7b4069e

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

cluster-autoscaler/simulator/scheduling/hinting_simulator.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ func (s *HintingSimulator) tryScheduleUsingHints(clusterSnapshot clustersnapshot
9191

9292
nodeInfo, err := clusterSnapshot.GetNodeInfo(hintedNode)
9393
if err != nil {
94-
return "", err
94+
// The hinted Node is no longer in the cluster. No need to error out, we can just look for another one.
95+
return "", nil
9596
}
9697
if !isNodeAcceptable(nodeInfo) {
9798
return "", nil

cluster-autoscaler/simulator/scheduling/hinting_simulator_test.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)