Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 4 additions & 13 deletions cmd/gce-pd-csi-driver/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,24 +368,14 @@ func fetchLssdsForRaiding(lssdCount int) ([]string, error) {
return nil, fmt.Errorf("Error listing RAIDed LSSDs %v", err)
}

unRaidedLssds := []string{}
for _, l := range allLssds {
if !slices.Contains(raidedLssds, l) {
unRaidedLssds = append(unRaidedLssds, l)
}
if len(unRaidedLssds) == lssdCount {
break
}
}

LSSDsWithEmptyMountPoint, err := driver.FetchLSSDsWihtEmptyMountPoint()
if err != nil {
return nil, fmt.Errorf("Error listing LSSDs with empty mountpoint: %v", err)
}

// We need to ensure the disks to be used for Data Cache are both unRAIDed & not containing mountpoints for ephemeral storage already
availableLssds := slices.Filter(nil, unRaidedLssds, func(e string) bool {
return slices.Contains(LSSDsWithEmptyMountPoint, e)
availableLssds := slices.Filter(nil, allLssds, func(e string) bool {
return slices.Contains(LSSDsWithEmptyMountPoint, e) && !slices.Contains(raidedLssds, e)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a comment on what we are filtering and what cases will that cater to

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought there's already a comment in the original version?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For long term, we need some unit test coverage for these steps. :/

})

if len(availableLssds) == 0 {
Expand All @@ -395,7 +385,8 @@ func fetchLssdsForRaiding(lssdCount int) ([]string, error) {
if len(availableLssds) < lssdCount {
return nil, fmt.Errorf("Not enough LSSDs available to set up caching. Available LSSDs: %v, wanted LSSDs: %v", len(availableLssds), lssdCount)
}
return availableLssds, nil

return availableLssds[:lssdCount], nil
}

func setupDataCache(ctx context.Context, nodeName string, nodeId string) error {
Expand Down