Skip to content
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

Finding drive vid in lsblk vendor #1094

Merged
merged 3 commits into from
Feb 24, 2024
Merged
Changes from 1 commit
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
7 changes: 1 addition & 6 deletions pkg/base/linuxutils/lsblk/lsblk.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,6 @@ func (l *LSBLK) GetBlockDevices(device string) ([]BlockDevice, error) {
// Receives an instance of drivecrd.Drive struct
Copy link
Collaborator

Choose a reason for hiding this comment

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

one general comments is to create an issue first and link the issue to the PR. and put [ISSUE-xxx] in PR title.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Addressed

// Returns drive's path based on provided drivecrd.Drive or error if something went wrong
func (l *LSBLK) SearchDrivePath(drive *api.Drive) (string, error) {
// device path might be already set by hwmgr
device := drive.Path
if device != "" {
return device, nil
}

// try to find it with lsblk
lsblkOut, err := l.GetBlockDevices("")
Expand All @@ -178,7 +173,7 @@ func (l *LSBLK) SearchDrivePath(drive *api.Drive) (string, error) {
vid := drive.VID
pid := drive.PID
for _, l := range lsblkOut {
if strings.EqualFold(l.Serial, sn) && strings.EqualFold(l.Vendor, vid) &&
if strings.EqualFold(l.Serial, sn) && strings.Contains(l.Vendor, vid) &&
Copy link
Collaborator

@libzhang libzhang Feb 24, 2024

Choose a reason for hiding this comment

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

how about the pid handling ? lsblk returned "HGST HUS728T8TALE6L0", but the drive CR value is from drivemgr, which is "HGST HUS728T8TAL".
and also is there possibility that Serialnumber need same handling with Vendor, as Serialnumber may also contain some trailing space.

Copy link
Collaborator Author

@prasant123 prasant123 Feb 24, 2024

Choose a reason for hiding this comment

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

We are observing failure only for the Vendo ID. Since the serial number reported by both HAL and lsblk are found the same, we should be good with the existing implementation. We need a quick resolution due to the time constraint, however I agree that we need to have a relook at this area of code in the next release cycle

Copy link
Collaborator

Choose a reason for hiding this comment

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

do you mean for the pid I mentioned above, for different length strings, strings.EqualFold will return true in the case ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should only ignore the trailing space in this JIRA. It is not safe to use "string.contains(A, B)" as it will also return TRUE for many other cases. For example: A = "testing " B="ing"

strings.EqualFold(l.Model, pid) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Need code change here to handle the PID.
In our test, for the same disk, the VID and PID format is different from lsblk and drive CR.

l.Vendor is "ATA " while vid (drive.VID) is “ATA”
l.Model is "HGST HUS728T8TALE6L0" while pid (drive.PID) is “HGST HUS728T8TAL”

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Agree!
Updated the changes, please take a look

device = l.Name
break
Expand Down