@@ -731,7 +731,7 @@ func (pl *dynamicResources) isSchedulableAfterPodSchedulingContextChange(logger
731
731
// before moving DRA to beta.
732
732
if podScheduling .Spec .SelectedNode != "" {
733
733
for _ , claimStatus := range podScheduling .Status .ResourceClaims {
734
- if sliceContains (claimStatus .UnsuitableNodes , podScheduling .Spec .SelectedNode ) {
734
+ if slices . Contains (claimStatus .UnsuitableNodes , podScheduling .Spec .SelectedNode ) {
735
735
logger .V (5 ).Info ("PodSchedulingContext has unsuitable selected node, schedule immediately" , "pod" , klog .KObj (pod ), "selectedNode" , podScheduling .Spec .SelectedNode , "podResourceName" , claimStatus .Name )
736
736
return framework .Queue , nil
737
737
}
@@ -769,15 +769,6 @@ func podSchedulingHasClaimInfo(podScheduling *resourcev1alpha2.PodSchedulingCont
769
769
return false
770
770
}
771
771
772
- func sliceContains (hay []string , needle string ) bool {
773
- for _ , item := range hay {
774
- if item == needle {
775
- return true
776
- }
777
- }
778
- return false
779
- }
780
-
781
772
// podResourceClaims returns the ResourceClaims for all pod.Spec.PodResourceClaims.
782
773
func (pl * dynamicResources ) podResourceClaims (pod * v1.Pod ) ([]* resourcev1alpha2.ResourceClaim , error ) {
783
774
claims := make ([]* resourcev1alpha2.ResourceClaim , 0 , len (pod .Spec .ResourceClaims ))
@@ -1330,22 +1321,13 @@ func haveAllPotentialNodes(schedulingCtx *resourcev1alpha2.PodSchedulingContext,
1330
1321
return false
1331
1322
}
1332
1323
for _ , node := range nodes {
1333
- if ! haveNode (schedulingCtx .Spec .PotentialNodes , node .Node ().Name ) {
1324
+ if ! slices . Contains (schedulingCtx .Spec .PotentialNodes , node .Node ().Name ) {
1334
1325
return false
1335
1326
}
1336
1327
}
1337
1328
return true
1338
1329
}
1339
1330
1340
- func haveNode (nodeNames []string , nodeName string ) bool {
1341
- for _ , n := range nodeNames {
1342
- if n == nodeName {
1343
- return true
1344
- }
1345
- }
1346
- return false
1347
- }
1348
-
1349
1331
// Reserve reserves claims for the pod.
1350
1332
func (pl * dynamicResources ) Reserve (ctx context.Context , cs * framework.CycleState , pod * v1.Pod , nodeName string ) (status * framework.Status ) {
1351
1333
if ! pl .enabled {
@@ -1402,7 +1384,7 @@ func (pl *dynamicResources) Reserve(ctx context.Context, cs *framework.CycleStat
1402
1384
// scheduler will pick it forever even when it cannot satisfy
1403
1385
// the claim.
1404
1386
if state .podSchedulingState .schedulingCtx == nil ||
1405
- ! containsNode (state .podSchedulingState .schedulingCtx .Spec .PotentialNodes , nodeName ) {
1387
+ ! slices . Contains (state .podSchedulingState .schedulingCtx .Spec .PotentialNodes , nodeName ) {
1406
1388
potentialNodes := []string {nodeName }
1407
1389
state .podSchedulingState .potentialNodes = & potentialNodes
1408
1390
logger .V (5 ).Info ("asking for information about single potential node" , "pod" , klog .KObj (pod ), "node" , klog.ObjectRef {Name : nodeName })
@@ -1478,15 +1460,6 @@ func (pl *dynamicResources) Reserve(ctx context.Context, cs *framework.CycleStat
1478
1460
return statusPending (logger , "waiting for resource driver to provide information" , "pod" , klog .KObj (pod ))
1479
1461
}
1480
1462
1481
- func containsNode (hay []string , needle string ) bool {
1482
- for _ , node := range hay {
1483
- if node == needle {
1484
- return true
1485
- }
1486
- }
1487
- return false
1488
- }
1489
-
1490
1463
// Unreserve clears the ReservedFor field for all claims.
1491
1464
// It's idempotent, and does nothing if no state found for the given pod.
1492
1465
func (pl * dynamicResources ) Unreserve (ctx context.Context , cs * framework.CycleState , pod * v1.Pod , nodeName string ) {
0 commit comments