mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 14:37:00 +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++ {
|
||||
allWaitSchedulingPods.Insert(fmt.Sprintf("pod%d", i))
|
||||
}
|
||||
var wg sync.WaitGroup
|
||||
var (
|
||||
wg sync.WaitGroup
|
||||
mu sync.Mutex
|
||||
)
|
||||
wg.Add(waitSchedulingPodNumber)
|
||||
stopFn, err := broadcaster.StartEventWatcher(func(obj runtime.Object) {
|
||||
e, ok := obj.(*eventsv1.Event)
|
||||
if !ok || (e.Reason != "Scheduled" && e.Reason != "FailedScheduling") {
|
||||
return
|
||||
}
|
||||
mu.Lock()
|
||||
if allWaitSchedulingPods.Has(e.Regarding.Name) {
|
||||
wg.Done()
|
||||
allWaitSchedulingPods.Delete(e.Regarding.Name)
|
||||
}
|
||||
mu.Unlock()
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
Loading…
Reference in New Issue
Block a user