Skip to content

Commit

Permalink
Fix wwid checks to handle comparisions without extensions
Browse files Browse the repository at this point in the history
WWID of few drives may show up without extension

example :-
   probed wwid = 0x6002248032bf1752a69bdaee7b0ceb33
   wwid in drive CRD = naa.6002248032bf1752a69bdaee7b0ceb33
  • Loading branch information
Praveenrajmani authored and wlan0 committed Apr 20, 2022
1 parent 166bb00 commit 07d04fd
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
17 changes: 16 additions & 1 deletion pkg/uevent/match.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
package uevent

import (
"strings"

directcsi "github.com/minio/directpv/pkg/apis/direct.csi.min.io/v1beta4"
"github.com/minio/directpv/pkg/sys"
"github.com/minio/directpv/pkg/utils"
Expand Down Expand Up @@ -201,7 +203,20 @@ func ueventSerialNumberMatcher(device *sys.Device, drive *directcsi.DirectCSIDri
}

func wwidMatcher(device *sys.Device, drive *directcsi.DirectCSIDrive) (bool, bool, error) {
return immutablePropertyMatcher(device.WWID, drive.Status.WWID)
match, consider, err := immutablePropertyMatcher(device.WWID, drive.Status.WWID)
if err != nil {
return match, consider, err
}
// WWID of few drives may show up without extension
// eg, probed wwid = 0x6002248032bf1752a69bdaee7b0ceb33
// wwid in drive CRD = naa.6002248032bf1752a69bdaee7b0ceb33
if !match && !consider {
match, consider, err = immutablePropertyMatcher(
strings.TrimPrefix(device.WWID, "0x"),
wwidWithoutExtension(drive.Status.WWID),
)
}
return match, consider, err
}

func modelNumberMatcher(device *sys.Device, drive *directcsi.DirectCSIDrive) (bool, bool, error) {
Expand Down
10 changes: 9 additions & 1 deletion pkg/uevent/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func ValidateUDevInfo(device *sys.Device, directCSIDrive *directcsi.DirectCSIDri
klog.V(3).Infof("[%s] partitionnum mismatch: %v -> %v", device.Name, directCSIDrive.Status.PartitionNum, device.Partition)
return false
}
if directCSIDrive.Status.WWID != device.WWID {
if directCSIDrive.Status.WWID != device.WWID && wwidWithoutExtension(directCSIDrive.Status.WWID) != strings.TrimPrefix(device.WWID, "0x") {
klog.V(3).Infof("[%s] wwid msmatch: %v -> %v", device.Name, directCSIDrive.Status.WWID, device.WWID)
return false
}
Expand Down Expand Up @@ -200,3 +200,11 @@ func isFormatRequested(directCSIDrive *directcsi.DirectCSIDrive) bool {
directCSIDrive.Spec.RequestedFormat != nil &&
directCSIDrive.Status.DriveStatus == directcsi.DriveStatusAvailable
}

func wwidWithoutExtension(wwid string) string {
ls := strings.SplitN(wwid, ".", 2)
if len(ls) == 2 {
return ls[1]
}
return wwid
}

0 comments on commit 07d04fd

Please sign in to comment.