Skip to content

Commit

Permalink
(scheduler e2e) Create balanced pods in parallel
Browse files Browse the repository at this point in the history
  • Loading branch information
damemi committed Jun 1, 2021
1 parent 5f6b1fa commit 91590cd
Showing 1 changed file with 24 additions and 5 deletions.
29 changes: 24 additions & 5 deletions test/e2e/scheduling/priorities.go
Original file line number Diff line number Diff line change
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 @@ -477,6 +479,10 @@ func createBalancedPodForNodes(f *framework.Framework, cs clientset.Interface, n
maxMemFraction = memFraction
}
}

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 @@ -516,14 +522,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 91590cd

Please sign in to comment.