mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 22:46:12 +00:00
flake(scheduler): fix allWaitSchedulingPods data race failed
This commit is contained in:
parent
49bbe19460
commit
04b048dcec
@ -638,17 +638,22 @@ func TestSchedulerGuaranteeNonNilNodeInSchedulingCycle(t *testing.T) {
|
|||||||
for i := 0; i < waitSchedulingPodNumber; i++ {
|
for i := 0; i < waitSchedulingPodNumber; i++ {
|
||||||
allWaitSchedulingPods.Insert(fmt.Sprintf("pod%d", i))
|
allWaitSchedulingPods.Insert(fmt.Sprintf("pod%d", i))
|
||||||
}
|
}
|
||||||
var wg sync.WaitGroup
|
var (
|
||||||
|
wg sync.WaitGroup
|
||||||
|
mu sync.Mutex
|
||||||
|
)
|
||||||
wg.Add(waitSchedulingPodNumber)
|
wg.Add(waitSchedulingPodNumber)
|
||||||
stopFn, err := broadcaster.StartEventWatcher(func(obj runtime.Object) {
|
stopFn, err := broadcaster.StartEventWatcher(func(obj runtime.Object) {
|
||||||
e, ok := obj.(*eventsv1.Event)
|
e, ok := obj.(*eventsv1.Event)
|
||||||
if !ok || (e.Reason != "Scheduled" && e.Reason != "FailedScheduling") {
|
if !ok || (e.Reason != "Scheduled" && e.Reason != "FailedScheduling") {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
mu.Lock()
|
||||||
if allWaitSchedulingPods.Has(e.Regarding.Name) {
|
if allWaitSchedulingPods.Has(e.Regarding.Name) {
|
||||||
wg.Done()
|
wg.Done()
|
||||||
allWaitSchedulingPods.Delete(e.Regarding.Name)
|
allWaitSchedulingPods.Delete(e.Regarding.Name)
|
||||||
}
|
}
|
||||||
|
mu.Unlock()
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
|
Loading…
Reference in New Issue
Block a user