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

fix the localdisk.partitionInfo.path not display correctly #1199

Merged
merged 5 commits into from
Oct 26, 2023

Conversation

hikariwo
Copy link
Member

What this PR does / why we need it:

fix #1198

Special notes for your reviewer:

Does this PR introduce a user-facing change?


hikariwo and others added 4 commits October 16, 2023 10:24
…getStorageNodeMigrateOperations

Signed-off-by: lancerxiu <1377004871@qq.com>
…getStorageNodeMigrateOperations

Signed-off-by: lancerxiu <1377004871@qq.com>
@codecov-commenter
Copy link

Codecov Report

Merging #1199 (97724ac) into main (997ca1b) will decrease coverage by 2.32%.
The diff coverage is 83.33%.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

@@            Coverage Diff             @@
##             main    #1199      +/-   ##
==========================================
- Coverage   38.13%   35.81%   -2.32%     
==========================================
  Files          25       28       +3     
  Lines        1980     2178     +198     
==========================================
+ Hits          755      780      +25     
- Misses       1125     1295     +170     
- Partials      100      103       +3     
Files Coverage Δ
.../local-disk-manager/builder/localdisk/localdisk.go 64.38% <100.00%> (+0.49%) ⬆️
pkg/local-disk-manager/udev/device.go 36.66% <80.00%> (ø)

... and 2 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Member

@SSmallMonster SSmallMonster left a comment

Choose a reason for hiding this comment

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

overall lgtm, just some nits

"testing"
)

func TestDevice_ParseDeviceInfo_UnPartition(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

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

these 2 test cases may be merged into one TestFunc, that may be better.

Copy link
Member Author

Choose a reason for hiding this comment

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

ok, I try to modify it

@@ -29,4 +29,7 @@ type PartitionInfo struct {

// Filesystem
Filesystem string

// Path
Path string
Copy link
Member

Choose a reason for hiding this comment

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

does this path represent the partition-path like /dev/sda1,/dev/sda2?

i'm wondering if it's a mount-path, but I think the partition-path should be more meaningful.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes,its format turly like /dev/sda1. It comes from the field DEVNAME of udevadm info command.

Comment on lines 9 to 10
udevInfo_unPartition := "P: /devices/pci0000:00/0000:00:07.1/ata1/host1/target1:0:0/1:0:0:0/block/sdb\nN: sdb\nS: disk/by-id/ata-VMware_Virtual_IDE_Hard_Drive_00000000000000000001\nS: disk/by-id/wwn-0x5000c298825951d9\nS: disk/by-path/pci-0000:00:07.1-ata-1.0\nE: DEVLINKS=/dev/disk/by-id/ata-VMware_Virtual_IDE_Hard_Drive_00000000000000000001 /dev/disk/by-id/wwn-0x5000c298825951d9 /dev/disk/by-path/pci-0000:00:07.1-ata-1.0\nE: DEVNAME=/dev/sdb\nE: DEVPATH=/devices/pci0000:00/0000:00:07.1/ata1/host1/target1:0:0/1:0:0:0/block/sdb\nE: DEVTYPE=disk\nE: ID_ATA=1\nE: ID_ATA_FEATURE_SET_APM=1\nE: ID_ATA_FEATURE_SET_APM_ENABLED=0\nE: ID_ATA_FEATURE_SET_PM=1\nE: ID_ATA_FEATURE_SET_PM_ENABLED=1\nE: ID_BUS=ata\nE: ID_MODEL=VMware_Virtual_IDE_Hard_Drive\nE: ID_MODEL_ENC=VMware\\x20Virtual\\x20IDE\\x20Hard\\x20Drive\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\nE: ID_PART_TABLE_TYPE=dos\nE: ID_PATH=pci-0000:00:07.1-ata-1.0\nE: ID_PATH_TAG=pci-0000_00_07_1-ata-1_0\nE: ID_REVISION=00000001\nE: ID_SERIAL=VMware_Virtual_IDE_Hard_Drive_00000000000000000001\nE: ID_SERIAL_SHORT=00000000000000000001\nE: ID_TYPE=disk\nE: ID_WWN=0x5000c298825951d9\nE: ID_WWN_WITH_EXTENSION=0x5000c298825951d9\nE: MAJOR=8\nE: MINOR=16\nE: SUBSYSTEM=block\nE: TAGS=:systemd:\nE: USEC_INITIALIZED=645583\n"
udevInfo_partition := "P: /devices/pci0000:00/0000:00:07.1/ata1/host1/target1:0:0/1:0:0:0/block/sdb/sdb1\nN: sdb1\nS: disk/by-id/ata-VMware_Virtual_IDE_Hard_Drive_00000000000000000001-part1\nS: disk/by-id/lvm-pv-uuid-QKLBih-32Tt-0JP7-uQKr-GzjD-cx0C-I8Vnno\nS: disk/by-id/wwn-0x5000c298825951d9-part1\nS: disk/by-path/pci-0000:00:07.1-ata-1.0-part1\nE: DEVLINKS=/dev/disk/by-id/ata-VMware_Virtual_IDE_Hard_Drive_00000000000000000001-part1 /dev/disk/by-id/lvm-pv-uuid-QKLBih-32Tt-0JP7-uQKr-GzjD-cx0C-I8Vnno /dev/disk/by-id/wwn-0x5000c298825951d9-part1 /dev/disk/by-path/pci-0000:00:07.1-ata-1.0-part1\nE: DEVNAME=/dev/sdb1\nE: DEVPATH=/devices/pci0000:00/0000:00:07.1/ata1/host1/target1:0:0/1:0:0:0/block/sdb/sdb1\nE: DEVTYPE=partition\nE: ID_ATA=1\nE: ID_ATA_FEATURE_SET_APM=1\nE: ID_ATA_FEATURE_SET_APM_ENABLED=0\nE: ID_ATA_FEATURE_SET_PM=1\nE: ID_ATA_FEATURE_SET_PM_ENABLED=1\nE: ID_BUS=ata\nE: ID_FS_TYPE=LVM2_member\nE: ID_FS_USAGE=raid\nE: ID_FS_UUID=QKLBih-32Tt-0JP7-uQKr-GzjD-cx0C-I8Vnno\nE: ID_FS_UUID_ENC=QKLBih-32Tt-0JP7-uQKr-GzjD-cx0C-I8Vnno\nE: ID_FS_VERSION=LVM2 001\nE: ID_MODEL=VMware_Virtual_IDE_Hard_Drive\nE: ID_MODEL_ENC=VMware\\x20Virtual\\x20IDE\\x20Hard\\x20Drive\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\nE: ID_PART_ENTRY_DISK=8:16\nE: ID_PART_ENTRY_NUMBER=1\nE: ID_PART_ENTRY_OFFSET=2048\nE: ID_PART_ENTRY_SCHEME=dos\nE: ID_PART_ENTRY_SIZE=31455232\nE: ID_PART_ENTRY_TYPE=0x83\nE: ID_PART_TABLE_TYPE=dos\nE: ID_PATH=pci-0000:00:07.1-ata-1.0\nE: ID_PATH_TAG=pci-0000_00_07_1-ata-1_0\nE: ID_REVISION=00000001\nE: ID_SERIAL=VMware_Virtual_IDE_Hard_Drive_00000000000000000001\nE: ID_SERIAL_SHORT=00000000000000000001\nE: ID_TYPE=disk\nE: ID_WWN=0x5000c298825951d9\nE: ID_WWN_WITH_EXTENSION=0x5000c298825951d9\nE: MAJOR=8\nE: MINOR=17\nE: SUBSYSTEM=block\nE: SYSTEMD_ALIAS=/dev/block/8:17\nE: SYSTEMD_READY=1\nE: SYSTEMD_WANTS=lvm2-pvscan@8:17.service\nE: TAGS=:systemd:"
Copy link
Member

Choose a reason for hiding this comment

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

you can use a struct to represent all test cases like

info := parseUdevInfo(testCase.UdevInfo)
d := &Device{}
d.ParseDiskAttribute(info)
fmt.Printf("PartName: %v\n", d.PartName)
Copy link
Member

Choose a reason for hiding this comment

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

this print log is unnecessry here

Copy link
Member Author

Choose a reason for hiding this comment

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

ok,I remove it!

@SSmallMonster
Copy link
Member

@hikariwo lgtm, can you rebase the commit and repush

@hikariwo
Copy link
Member Author

I try to clean it!

@hikariwo lgtm, can you rebase the commit and repush

… the bug about device.PartName and PartitionInfo.Path not to be assigned a value

Signed-off-by: lancerxiu <1377004871@qq.com>

add udev_test file to test parsing the UdevInfo work properly and fix the bug about device.PartName and PartitionInfo.Path not to be assigned a value

Signed-off-by: lancerxiu <1377004871@qq.com>

combine two TestFunc into one TestFunc

Signed-off-by: lancerxiu <1377004871@qq.com>

modify test file

Signed-off-by: lancerxiu <1377004871@qq.com>

modify test file

Signed-off-by: lancerxiu <1377004871@qq.com>
@hikariwo
Copy link
Member Author

@SSmallMonster done, commit-tree has been cleaned!

@SSmallMonster SSmallMonster merged commit 80e8eba into hwameistor:main Oct 26, 2023
3 checks passed
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.

partitionInfo.Path doesn't have a correct value
3 participants