mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-12 13:31:52 +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
|
// EventsToRegister returns the possible events that may make a Pod
|
||||||
// failed by this plugin schedulable.
|
// failed by this plugin schedulable.
|
||||||
func (pl *DefaultPreemption) EventsToRegister(_ context.Context) ([]framework.ClusterEventWithHint, error) {
|
func (pl *DefaultPreemption) EventsToRegister(_ context.Context) ([]framework.ClusterEventWithHint, error) {
|
||||||
return []framework.ClusterEventWithHint{
|
// The plugin moves the preemptor Pod to acviteQ/backoffQ once the preemption API calls are all done,
|
||||||
// We don't need any QHint for the event
|
// and we don't need to move the Pod with any events.
|
||||||
// because the Pod rejected by the preemption plugin is the one that is running the preemption,
|
return nil, nil
|
||||||
// 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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// calculateNumCandidates returns the number of candidates the FindCandidates
|
// calculateNumCandidates returns the number of candidates the FindCandidates
|
||||||
|
@ -209,8 +209,7 @@ func (ev *Evaluator) IsPodRunningPreemption(podUID types.UID) bool {
|
|||||||
ev.mu.RLock()
|
ev.mu.RLock()
|
||||||
defer ev.mu.RUnlock()
|
defer ev.mu.RUnlock()
|
||||||
|
|
||||||
_, ok := ev.preempting[podUID]
|
return ev.preempting.Has(podUID)
|
||||||
return ok
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Preempt returns a PostFilterResult carrying suggested nominatedNodeName, along with a Status.
|
// 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.mu.Lock()
|
||||||
ev.preempting[pod.UID] = struct{}{}
|
ev.preempting.Insert(pod.UID)
|
||||||
ev.mu.Unlock()
|
ev.mu.Unlock()
|
||||||
|
|
||||||
logger := klog.FromContext(ctx)
|
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 metrics.PreemptionGoroutinesExecutionTotal.WithLabelValues(result).Inc()
|
||||||
defer func() {
|
defer func() {
|
||||||
ev.mu.Lock()
|
ev.mu.Lock()
|
||||||
delete(ev.preempting, pod.UID)
|
ev.preempting.Delete(pod.UID)
|
||||||
ev.mu.Unlock()
|
ev.mu.Unlock()
|
||||||
ev.Handler.Activate(logger, map[string]*v1.Pod{pod.Name: pod})
|
ev.Handler.Activate(logger, map[string]*v1.Pod{pod.Name: pod})
|
||||||
}()
|
}()
|
||||||
|
Loading…
Reference in New Issue
Block a user