@@ -238,15 +238,8 @@ func (ev *Evaluator) findCandidates(ctx context.Context, allNodes []*framework.N
238
238
return nil , nil , err
239
239
}
240
240
241
- offset , numCandidates := ev .GetOffsetAndNumCandidates (int32 (len (potentialNodes )))
242
- if loggerV := logger .V (5 ); logger .Enabled () {
243
- var sample []string
244
- for i := offset ; i < offset + 10 && i < int32 (len (potentialNodes )); i ++ {
245
- sample = append (sample , potentialNodes [i ].Node ().Name )
246
- }
247
- loggerV .Info ("Selected candidates from a pool of nodes" , "potentialNodesCount" , len (potentialNodes ), "offset" , offset , "sampleLength" , len (sample ), "sample" , sample , "candidates" , numCandidates )
248
- }
249
- return ev .DryRunPreemption (ctx , pod , potentialNodes , pdbs , offset , numCandidates )
241
+ offset , candidatesNum := ev .GetOffsetAndNumCandidates (int32 (len (potentialNodes )))
242
+ return ev .DryRunPreemption (ctx , pod , potentialNodes , pdbs , offset , candidatesNum )
250
243
}
251
244
252
245
// callExtenders calls given <extenders> to select the list of feasible candidates.
@@ -546,18 +539,24 @@ func getLowerPriorityNominatedPods(logger klog.Logger, pn framework.PodNominator
546
539
// candidates, ones that do not violate PDB are preferred over ones that do.
547
540
// NOTE: This method is exported for easier testing in default preemption.
548
541
func (ev * Evaluator ) DryRunPreemption (ctx context.Context , pod * v1.Pod , potentialNodes []* framework.NodeInfo ,
549
- pdbs []* policy.PodDisruptionBudget , offset int32 , numCandidates int32 ) ([]Candidate , * framework.NodeToStatus , error ) {
542
+ pdbs []* policy.PodDisruptionBudget , offset int32 , candidatesNum int32 ) ([]Candidate , * framework.NodeToStatus , error ) {
550
543
551
544
fh := ev .Handler
552
- nonViolatingCandidates := newCandidateList (numCandidates )
553
- violatingCandidates := newCandidateList (numCandidates )
545
+ nonViolatingCandidates := newCandidateList (candidatesNum )
546
+ violatingCandidates := newCandidateList (candidatesNum )
554
547
ctx , cancel := context .WithCancel (ctx )
555
548
defer cancel ()
556
549
nodeStatuses := framework .NewDefaultNodeToStatus ()
550
+
551
+ logger := klog .FromContext (ctx )
552
+ logger .V (5 ).Info ("Dry run the preemption" , "potentialNodesNumber" , len (potentialNodes ), "pdbsNumber" , len (pdbs ), "offset" , offset , "candidatesNumber" , candidatesNum )
553
+
557
554
var statusesLock sync.Mutex
558
555
var errs []error
559
556
checkNode := func (i int ) {
560
557
nodeInfoCopy := potentialNodes [(int (offset )+ i )% len (potentialNodes )].Snapshot ()
558
+ logger .V (5 ).Info ("Check the potential node for preemption" , "node" , nodeInfoCopy .Node ().Name )
559
+
561
560
stateCopy := ev .State .Clone ()
562
561
pods , numPDBViolations , status := ev .SelectVictimsOnNode (ctx , stateCopy , pod , nodeInfoCopy , pdbs )
563
562
if status .IsSuccess () && len (pods ) != 0 {
@@ -575,7 +574,7 @@ func (ev *Evaluator) DryRunPreemption(ctx context.Context, pod *v1.Pod, potentia
575
574
violatingCandidates .add (c )
576
575
}
577
576
nvcSize , vcSize := nonViolatingCandidates .size (), violatingCandidates .size ()
578
- if nvcSize > 0 && nvcSize + vcSize >= numCandidates {
577
+ if nvcSize > 0 && nvcSize + vcSize >= candidatesNum {
579
578
cancel ()
580
579
}
581
580
return
0 commit comments