Skip to content

Commit 1b6716c

Browse files
authored
Merge pull request kubernetes#3702 from towca/jtuznik/simulator-fix
Fix an out-of-bound array access in simulator.TestClear()
2 parents f18b65a + 6821ab8 commit 1b6716c

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

cluster-autoscaler/simulator/cluster_snapshot_benchmark_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ func createTestPods(n int) []*apiv1.Pod {
5353
}
5454

5555
func assignPodsToNodes(pods []*apiv1.Pod, nodes []*apiv1.Node) {
56+
if len(nodes) == 0 {
57+
return
58+
}
59+
5660
j := 0
5761
for i := 0; i < len(pods); i++ {
5862
if j >= len(nodes) {

cluster-autoscaler/simulator/cluster_snapshot_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,8 @@ func TestClear(t *testing.T) {
240240
// Run with -count=1 to avoid caching.
241241
localRand := rand.New(rand.NewSource(time.Now().Unix()))
242242

243-
nodeCount := localRand.Intn(100)
244-
podCount := localRand.Intn(1000)
243+
nodeCount := localRand.Intn(99) + 1
244+
podCount := localRand.Intn(999) + 1
245245
extraNodeCount := localRand.Intn(100)
246246
extraPodCount := localRand.Intn(1000)
247247

0 commit comments

Comments
 (0)