Merge pull request #3702 from towca/jtuznik/simulator-fix

Fix an out-of-bound array access in simulator.TestClear()
This commit is contained in:
Kubernetes Prow Robot 2020-11-17 06:04:04 -08:00 committed by GitHub
commit 1b6716c98c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View File

@ -53,6 +53,10 @@ func createTestPods(n int) []*apiv1.Pod {
}
func assignPodsToNodes(pods []*apiv1.Pod, nodes []*apiv1.Node) {
if len(nodes) == 0 {
return
}
j := 0
for i := 0; i < len(pods); i++ {
if j >= len(nodes) {

View File

@ -240,8 +240,8 @@ func TestClear(t *testing.T) {
// Run with -count=1 to avoid caching.
localRand := rand.New(rand.NewSource(time.Now().Unix()))
nodeCount := localRand.Intn(100)
podCount := localRand.Intn(1000)
nodeCount := localRand.Intn(99) + 1
podCount := localRand.Intn(999) + 1
extraNodeCount := localRand.Intn(100)
extraPodCount := localRand.Intn(1000)