Skip to content

[release-1.17] Fix logic bug while checking available LSSDs for RAIDing for Data Cache #1994

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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)
})

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