Skip to content

Commit

Permalink
Merge pull request kubernetes#102487 from damemi/1.21-balance-pods-pa…
Browse files Browse the repository at this point in the history
…rallel

(scheduler e2e) Create balanced pods in parallel
  • Loading branch information
k8s-ci-robot committed Jun 8, 2021
2 parents 37fb31d + ae40fd7 commit e6e5ee4
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions test/e2e/scheduling/priorities.go
Expand Up @@ -21,6 +21,7 @@ import (
"encoding/json"
"fmt"
"math"
"sync"
"time"

"github.com/onsi/ginkgo"
Expand All @@ -33,6 +34,7 @@ import (
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/util/errors"
"k8s.io/apimachinery/pkg/util/uuid"
"k8s.io/apimachinery/pkg/util/wait"
clientset "k8s.io/client-go/kubernetes"
Expand Down Expand Up @@ -524,6 +526,9 @@ func createBalancedPodForNodes(f *framework.Framework, cs clientset.Interface, n
}
}

errChan := make(chan error, len(nodes))
var wg sync.WaitGroup

// we need the max one to keep the same cpu/mem use rate
ratio = math.Max(maxCPUFraction, maxMemFraction)
for _, node := range nodes {
Expand Down Expand Up @@ -563,14 +568,27 @@ func createBalancedPodForNodes(f *framework.Framework, cs clientset.Interface, n
},
},
}

err := testutils.StartPods(cs, 1, ns, string(uuid.NewUUID()),
*initPausePod(f, *podConfig), true, framework.Logf)

wg.Add(1)
go func() {
defer wg.Done()
err := testutils.StartPods(cs, 1, ns, string(uuid.NewUUID()),
*initPausePod(f, *podConfig), true, framework.Logf)
if err != nil {
errChan <- err
}
}()
}
wg.Wait()
close(errChan)
var errs []error
for err := range errChan {
if err != nil {
return cleanUp, err
errs = append(errs, err)
}
}
if len(errs) > 0 {
return cleanUp, errors.NewAggregate(errs)
}

nodeNameToPodList = podListForEachNode(cs)
for _, node := range nodes {
Expand Down

0 comments on commit e6e5ee4

Please sign in to comment.