Change:
<!-- Please only use this template for submitting reports about flaky tests or jobs (pass or fail with no underlying change in code) in Kubernetes CI --Which jobs are flaking: pull-kubernetes-bazel-test Which test(s) are flaking: pkg/scheduler/internal/queue Testgrid link: Reason for failure: Anything else we need to know: /sig scheduling /assign
I just sent a pr for it according to the error message, but I'm not very sure if it will make things all right.
/assign

Discussion:
func TestPriorityQueue_Update(t *testing.T) { q := createAndRunPriorityQueue(newDefaultFramework()) q.Update(nil, &highPriorityPod) <ins> q.lock.RLock() </ins> if _, exists, _ := q.activeQ.Get(newPodInfoNoTimestamp(&highPriorityPod)); !exists { t.Errorf("Expected %v to be added to activeQ.", highPriorityPod.Name) } <ins> q.lock.RUnlock() </ins> if len(q.nominatedPods.nominatedPods) != 0 { t.Errorf("Expected nomindatePods to be empty: %v", q.nominatedPods) } // Update highPriorityPod and add a nominatedNodeName to it. q.Update(&highPriorityPod, &highPriNominatedPod) <ins> q.lock.RLock() </ins> if q.activeQ.Len() != 1 { t.Error("Expected only one item in activeQ.") } <ins> q.lock.RUnlock() </ins> if len(q.nominatedPods.nominatedPods) != 1 { t.Errorf("Expected one item in nomindatePods map: %v", q.nominatedPods) } // Updating an unschedulable pod which is not in any of the two queues, should // add the pod to activeQ. q.Update(&unschedulablePod, &unschedulablePod) <ins> q.lock.RLock() </ins> if _, exists, _ := q.activeQ.Get(newPodInfoNoTimestamp(&unschedulablePod)); !exists { t.Errorf("Expected %v to be added to activeQ.", unschedulablePod.Name) } <ins> q.lock.RUnlock() </ins> // Updating a pod that is already in activeQ, should not change it. q.Update(&unschedulablePod, &unschedulablePod) if len(q.unschedulableQ.podInfoMap) != 0 { t.Error("Expected unschedulableQ to be empty.") } <ins> q.lock.RLock() </ins> if _, exists, _ := q.activeQ.Get(newPodInfoNoTimestamp(&unschedulablePod)); !exists { t.Errorf("Expected: %v to be added to activeQ.", unschedulablePod.Name) } <ins> q.lock.RUnlock() </ins> if p, err := q.Pop(); err != nil || p.Pod != &highPriNominatedPod { t.Errorf("Expected: %v after Pop, but got: %v", highPriorityPod.Name, p.Pod.Name) }

if err := q.Delete(&highPriNominatedPod); err != nil { t.Errorf("delete failed: %v", err) } <ins> q.lock.RLock() </ins> if _, exists, _ := q.activeQ.Get(newPodInfoNoTimestamp(&unschedulablePod)); !exists { t.Errorf("Expected %v to be in activeQ.", unschedulablePod.Name) } if _, exists, _ := q.activeQ.Get(newPodInfoNoTimestamp(&highPriNominatedPod)); exists { t.Errorf("Didn't expect %v to be in activeQ.", highPriorityPod.Name) } <ins> q.lock.RUnlock() </ins> if len(q.nominatedPods.nominatedPods) != 1 { t.Errorf("Expected nomindatePods to have only 'unschedulablePod': %v", q.nominatedPods.nominatedPods) }

q.AddUnschedulableIfNotPresent(q.newPodInfo(&unschedulablePod), q.SchedulingCycle()) q.AddUnschedulableIfNotPresent(q.newPodInfo(&highPriorityPod), q.SchedulingCycle()) q.MoveAllToActiveOrBackoffQueue("test") <ins> q.lock.RLock() defer q.lock.RUnlock() </ins> if q.activeQ.Len() != 1 { t.Error("Expected 1 item to be in activeQ") }

if getUnschedulablePod(q, affinityPod) != nil { t.Error("affinityPod is still in the unschedulableQ.") } <ins> q.lock.RLock() </ins> if _, exists, _ := q.activeQ.Get(newPodInfoNoTimestamp(affinityPod)); !exists { t.Error("affinityPod is not moved to activeQ.") } <ins> q.lock.RUnlock() </ins> // Check that the other pod is still in the unschedulableQ. if getUnschedulablePod(q, &unschedulablePod) == nil { t.Error("unschedulablePod is not in the unschedulableQ.")

op(queue, test.operands[i]) } <ins> queue.lock.Lock() </ins> for i := 0; i < len(test.expected); i++ { if pInfo, err := queue.activeQ.Pop(); err != nil { t.Errorf("Error while popping the head of the queue: %v", err)

podInfoList = append(podInfoList, pInfo.(*framework.PodInfo)) } } <ins> queue.lock.Unlock() </ins> if !reflect.DeepEqual(test.expected, podInfoList) { t.Errorf("Unexpected PodInfo list. Expected: %v, got: %v",

// An event happens. q.MoveAllToActiveOrBackoffQueue("deleted pod") <ins> q.lock.RLock() </ins> if _, ok, _ := q.podBackoffQ.Get(podInfo); !ok { t.Errorf("pod %v is not in the backoff queue", podID) } <ins> q.lock.RUnlock() </ins> // Check backoff duration. deadline := q.getBackoffTime(podInfo)

cl.Step(time.Millisecond) q.flushBackoffQCompleted() // Still in backoff queue after an early flush. <ins> q.lock.RLock() </ins> if _, ok, _ := q.podBackoffQ.Get(podInfo); !ok { t.Errorf("pod %v is not in the backoff queue", podID) } <ins> q.lock.RUnlock() </ins> // Moved out of the backoff queue after timeout. cl.Step(backoff) q.flushBackoffQCompleted() <ins> q.lock.RLock() </ins> if _, ok, _ := q.podBackoffQ.Get(podInfo); ok { t.Errorf("pod %v is still in the backoff queue", podID) } <ins> q.lock.RUnlock() </ins> }) } }