mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-12 05:21:58 +00:00
fix: use set methods
This commit is contained in:
parent
623b2a20d2
commit
d4d91d4ace
@ -116,13 +116,9 @@ func (pl *DefaultPreemption) PreEnqueue(ctx context.Context, p *v1.Pod) *framewo
|
||||
// EventsToRegister returns the possible events that may make a Pod
|
||||
// failed by this plugin schedulable.
|
||||
func (pl *DefaultPreemption) EventsToRegister(_ context.Context) ([]framework.ClusterEventWithHint, error) {
|
||||
return []framework.ClusterEventWithHint{
|
||||
// We don't need any QHint for the event
|
||||
// because the Pod rejected by the preemption plugin is the one that is running the preemption,
|
||||
// and the Pod won't be requeued until all the preemption API calls are completed
|
||||
// (we block the Pod from being requeued at PreEnqueue).
|
||||
{Event: framework.ClusterEvent{Resource: framework.Pod, ActionType: framework.Delete}},
|
||||
}, nil
|
||||
// The plugin moves the preemptor Pod to acviteQ/backoffQ once the preemption API calls are all done,
|
||||
// and we don't need to move the Pod with any events.
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// calculateNumCandidates returns the number of candidates the FindCandidates
|
||||
|
@ -209,8 +209,7 @@ func (ev *Evaluator) IsPodRunningPreemption(podUID types.UID) bool {
|
||||
ev.mu.RLock()
|
||||
defer ev.mu.RUnlock()
|
||||
|
||||
_, ok := ev.preempting[podUID]
|
||||
return ok
|
||||
return ev.preempting.Has(podUID)
|
||||
}
|
||||
|
||||
// Preempt returns a PostFilterResult carrying suggested nominatedNodeName, along with a Status.
|
||||
@ -483,7 +482,7 @@ func (ev *Evaluator) prepareCandidateAsync(c Candidate, pod *v1.Pod, pluginName
|
||||
}
|
||||
|
||||
ev.mu.Lock()
|
||||
ev.preempting[pod.UID] = struct{}{}
|
||||
ev.preempting.Insert(pod.UID)
|
||||
ev.mu.Unlock()
|
||||
|
||||
logger := klog.FromContext(ctx)
|
||||
@ -494,7 +493,7 @@ func (ev *Evaluator) prepareCandidateAsync(c Candidate, pod *v1.Pod, pluginName
|
||||
defer metrics.PreemptionGoroutinesExecutionTotal.WithLabelValues(result).Inc()
|
||||
defer func() {
|
||||
ev.mu.Lock()
|
||||
delete(ev.preempting, pod.UID)
|
||||
ev.preempting.Delete(pod.UID)
|
||||
ev.mu.Unlock()
|
||||
ev.Handler.Activate(logger, map[string]*v1.Pod{pod.Name: pod})
|
||||
}()
|
||||
|
Loading…
Reference in New Issue
Block a user