@@ -368,24 +368,14 @@ func fetchLssdsForRaiding(lssdCount int) ([]string, error) {
368368 return nil , fmt .Errorf ("Error listing RAIDed LSSDs %v" , err )
369369 }
370370
371- unRaidedLssds := []string {}
372- for _ , l := range allLssds {
373- if ! slices .Contains (raidedLssds , l ) {
374- unRaidedLssds = append (unRaidedLssds , l )
375- }
376- if len (unRaidedLssds ) == lssdCount {
377- break
378- }
379- }
380-
381371 LSSDsWithEmptyMountPoint , err := driver .FetchLSSDsWihtEmptyMountPoint ()
382372 if err != nil {
383373 return nil , fmt .Errorf ("Error listing LSSDs with empty mountpoint: %v" , err )
384374 }
385375
386376 // We need to ensure the disks to be used for Data Cache are both unRAIDed & not containing mountpoints for ephemeral storage already
387- availableLssds := slices .Filter (nil , unRaidedLssds , func (e string ) bool {
388- return slices .Contains (LSSDsWithEmptyMountPoint , e )
377+ availableLssds := slices .Filter (nil , allLssds , func (e string ) bool {
378+ return slices .Contains (LSSDsWithEmptyMountPoint , e ) && ! slices . Contains ( raidedLssds , e )
389379 })
390380
391381 if len (availableLssds ) == 0 {
@@ -395,7 +385,8 @@ func fetchLssdsForRaiding(lssdCount int) ([]string, error) {
395385 if len (availableLssds ) < lssdCount {
396386 return nil , fmt .Errorf ("Not enough LSSDs available to set up caching. Available LSSDs: %v, wanted LSSDs: %v" , len (availableLssds ), lssdCount )
397387 }
398- return availableLssds , nil
388+
389+ return availableLssds [:lssdCount ], nil
399390}
400391
401392func setupDataCache (ctx context.Context , nodeName string , nodeId string ) error {
0 commit comments