mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-20 18:31:15 +00:00
Merge pull request #102138 from damemi/balance-pods-parallel
(scheduler e2e) Create balanced pods in parallel
This commit is contained in:
commit
6bac142190
@ -21,6 +21,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
"math"
|
||||||
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/onsi/ginkgo"
|
"github.com/onsi/ginkgo"
|
||||||
@ -33,6 +34,7 @@ import (
|
|||||||
"k8s.io/apimachinery/pkg/api/resource"
|
"k8s.io/apimachinery/pkg/api/resource"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/labels"
|
"k8s.io/apimachinery/pkg/labels"
|
||||||
|
"k8s.io/apimachinery/pkg/util/errors"
|
||||||
"k8s.io/apimachinery/pkg/util/uuid"
|
"k8s.io/apimachinery/pkg/util/uuid"
|
||||||
"k8s.io/apimachinery/pkg/util/wait"
|
"k8s.io/apimachinery/pkg/util/wait"
|
||||||
clientset "k8s.io/client-go/kubernetes"
|
clientset "k8s.io/client-go/kubernetes"
|
||||||
@ -527,6 +529,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
|
// we need the max one to keep the same cpu/mem use rate
|
||||||
ratio = math.Max(maxCPUFraction, maxMemFraction)
|
ratio = math.Max(maxCPUFraction, maxMemFraction)
|
||||||
for _, node := range nodes {
|
for _, node := range nodes {
|
||||||
@ -566,13 +571,26 @@ func createBalancedPodForNodes(f *framework.Framework, cs clientset.Interface, n
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
wg.Add(1)
|
||||||
|
go func() {
|
||||||
|
defer wg.Done()
|
||||||
err := testutils.StartPods(cs, 1, ns, string(uuid.NewUUID()),
|
err := testutils.StartPods(cs, 1, ns, string(uuid.NewUUID()),
|
||||||
*initPausePod(f, *podConfig), true, framework.Logf)
|
*initPausePod(f, *podConfig), true, framework.Logf)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return cleanUp, err
|
errChan <- err
|
||||||
}
|
}
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
wg.Wait()
|
||||||
|
close(errChan)
|
||||||
|
var errs []error
|
||||||
|
for err := range errChan {
|
||||||
|
if err != nil {
|
||||||
|
errs = append(errs, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(errs) > 0 {
|
||||||
|
return cleanUp, errors.NewAggregate(errs)
|
||||||
}
|
}
|
||||||
|
|
||||||
nodeNameToPodList = podListForEachNode(cs)
|
nodeNameToPodList = podListForEachNode(cs)
|
||||||
|
Loading…
Reference in New Issue
Block a user