@@ -20,7 +20,7 @@ import (
20
20
"context"
21
21
"errors"
22
22
"fmt"
23
- "sort "
23
+ "slices "
24
24
"strconv"
25
25
"strings"
26
26
"sync"
@@ -340,7 +340,7 @@ func (vm *volumeManager) GetExtraSupplementalGroupsForPod(pod *v1.Pod) []int64 {
340
340
}
341
341
342
342
result := make ([]int64 , 0 , supplementalGroups .Len ())
343
- for _ , group := range sets . List ( supplementalGroups ) {
343
+ for _ , group := range supplementalGroups . UnsortedList ( ) {
344
344
iGroup , extra := getExtraSupplementalGid (group , pod )
345
345
if ! extra {
346
346
continue
@@ -359,29 +359,21 @@ func (vm *volumeManager) GetVolumesInUse() []v1.UniqueVolumeName {
359
359
desiredVolumes := vm .desiredStateOfWorld .GetVolumesToMount ()
360
360
allAttachedVolumes := vm .actualStateOfWorld .GetAttachedVolumes ()
361
361
volumesToReportInUse := make ([]v1.UniqueVolumeName , 0 , len (desiredVolumes )+ len (allAttachedVolumes ))
362
- desiredVolumesMap := make (map [v1.UniqueVolumeName ]bool , len (desiredVolumes )+ len (allAttachedVolumes ))
363
362
364
363
for _ , volume := range desiredVolumes {
365
364
if volume .PluginIsAttachable {
366
- if _ , exists := desiredVolumesMap [volume .VolumeName ]; ! exists {
367
- desiredVolumesMap [volume .VolumeName ] = true
368
- volumesToReportInUse = append (volumesToReportInUse , volume .VolumeName )
369
- }
365
+ volumesToReportInUse = append (volumesToReportInUse , volume .VolumeName )
370
366
}
371
367
}
372
368
373
369
for _ , volume := range allAttachedVolumes {
374
370
if volume .PluginIsAttachable {
375
- if _ , exists := desiredVolumesMap [volume .VolumeName ]; ! exists {
376
- volumesToReportInUse = append (volumesToReportInUse , volume .VolumeName )
377
- }
371
+ volumesToReportInUse = append (volumesToReportInUse , volume .VolumeName )
378
372
}
379
373
}
380
374
381
- sort .Slice (volumesToReportInUse , func (i , j int ) bool {
382
- return string (volumesToReportInUse [i ]) < string (volumesToReportInUse [j ])
383
- })
384
- return volumesToReportInUse
375
+ slices .Sort (volumesToReportInUse )
376
+ return slices .Compact (volumesToReportInUse )
385
377
}
386
378
387
379
func (vm * volumeManager ) ReconcilerStatesHasBeenSynced () bool {
@@ -471,12 +463,11 @@ func (vm *volumeManager) WaitForUnmount(ctx context.Context, pod *v1.Pod) error
471
463
for _ , v := range vm .actualStateOfWorld .GetMountedVolumesForPod (uniquePodName ) {
472
464
mountedVolumes = append (mountedVolumes , v .OuterVolumeSpecName )
473
465
}
474
- sort .Strings (mountedVolumes )
475
-
476
466
if len (mountedVolumes ) == 0 {
477
467
return nil
478
468
}
479
469
470
+ slices .Sort (mountedVolumes )
480
471
return fmt .Errorf (
481
472
"mounted volumes=%v: %w" ,
482
473
mountedVolumes ,
@@ -506,7 +497,7 @@ func (vm *volumeManager) WaitForAllPodsUnmount(ctx context.Context, pods []*v1.P
506
497
}
507
498
508
499
func (vm * volumeManager ) getVolumesNotInDSW (uniquePodName types.UniquePodName , expectedVolumes []string ) []string {
509
- volumesNotInDSW := sets .New [ string ] (expectedVolumes ... )
500
+ volumesNotInDSW := sets .New (expectedVolumes ... )
510
501
511
502
for _ , volumeToMount := range vm .desiredStateOfWorld .GetVolumesToMount () {
512
503
if volumeToMount .PodName == uniquePodName {
@@ -528,7 +519,7 @@ func (vm *volumeManager) getUnattachedVolumes(uniquePodName types.UniquePodName)
528
519
unattachedVolumes = append (unattachedVolumes , volumeToMount .OuterVolumeSpecName )
529
520
}
530
521
}
531
- sort . Strings (unattachedVolumes )
522
+ slices . Sort (unattachedVolumes )
532
523
533
524
return unattachedVolumes
534
525
}
@@ -582,7 +573,7 @@ func filterUnmountedVolumes(mountedVolumes sets.Set[string], expectedVolumes []s
582
573
unmountedVolumes = append (unmountedVolumes , expectedVolume )
583
574
}
584
575
}
585
- sort . Strings (unmountedVolumes )
576
+ slices . Sort (unmountedVolumes )
586
577
587
578
return unmountedVolumes
588
579
}
0 commit comments