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

Finding drive vid in lsblk vendor #1094

merged 3 commits into from
Feb 24, 2024

Conversation

prasant123
Copy link
Collaborator

@prasant123 prasant123 commented Feb 24, 2024

Purpose

Resolves #1095

PR checklist

  • Add link to the issue
  • Choose Project
  • Choose PR label
  • New unit tests added
  • Modified code has meaningful comments
  • All TODOs are linked with the issues
  • All comments are resolved

Testing

Provide test details

Copy link
Collaborator

@eddiepavkovic eddiepavkovic left a comment

Choose a reason for hiding this comment

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

I'm good with the change as it was discussed with @mishoyama

@@ -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"

@@ -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

@@ -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) &&
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

strings.EqualFold(l.Model, pid) {
lvid := strings.TrimSpace(l.Vendor)
if strings.EqualFold(l.Serial, sn) && strings.EqualFold(lvid, vid) &&
strings.HasPrefix(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.

basically, it is ok.
just noted that: if pid is null string(""), then strings.HasPrefix will also return true. but in our case, pid seems to not able to be null. we may need re-look at this code in later release as well.

@lordjun
Copy link
Collaborator

lordjun commented Feb 24, 2024

Please go ahead to merge the code, Prasant. Thanks.

@prasant123 prasant123 merged commit b201abe into rel/CY2310 Feb 24, 2024
1 check failed
@prasant123 prasant123 deleted the lsblk-fix branch February 24, 2024 12:03
Andrzej-Zukowski pushed a commit that referenced this pull request Feb 26, 2024
* Finding drive vid in lsblk vendor

* addressing review comments

* Initializing device

---------
Andrzej-Zukowski pushed a commit that referenced this pull request Feb 26, 2024
* Finding drive vid in lsblk vendor

* addressing review comments

* Initializing device

---------

Signed-off-by: Andrzej Zukowski <[email protected]>
Andrzej-Zukowski added a commit that referenced this pull request Feb 26, 2024
* [Issue-1084] Addjust scheduler extender algorithm

Signed-off-by: Andrzej Zukowski <[email protected]>

* [Issue-1084] Fixes after review

Signed-off-by: Andrzej Zukowski <[email protected]>

* [Issue-1091] 1.5.1 version (#1093)

Signed-off-by: Andrzej Zukowski <[email protected]>

* Finding drive vid in lsblk vendor (#1094)

* Finding drive vid in lsblk vendor

* addressing review comments

* Initializing device

---------

Signed-off-by: Andrzej Zukowski <[email protected]>

* [ISSUE-1096] Fix lint and unit test error for resolution to atl-22498 (#1098)

* [Issue #1096] - Fix lint error for bug atl-22498

Signed-off-by: Eddie Pavkovic <[email protected]>

* [Issue #1096] - Put code back that returned device if path set
- to fix unit test

Signed-off-by: Eddie Pavkovic <[email protected]>

* [ISSUE-1096] - Put back code from previous PR and removed invalid test case

Signed-off-by: Eddie Pavkovic <[email protected]>

---------

Signed-off-by: Eddie Pavkovic <[email protected]>
Signed-off-by: Andrzej Zukowski <[email protected]>

* [ISSUE-1096] Change component version to 1.6.0

Signed-off-by: Andrzej Zukowski <[email protected]>

---------

Signed-off-by: Andrzej Zukowski <[email protected]>
Signed-off-by: Eddie Pavkovic <[email protected]>
Co-authored-by: PrasantDell <[email protected]>
Co-authored-by: eddiepavkovic <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants