[pve-devel] [PATCH storage] fix #2266: Diskmanage: get correct osd id
Dominik Csapak
d.csapak at proxmox.com
Mon Jul 8 15:48:14 CEST 2019
the osdid has not only a single digit
also add more regression tests for this
Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
PVE/Diskmanage.pm | 2 +-
test/disk_tests/usages/disklist | 2 ++
test/disk_tests/usages/disklist_expected.json | 31 +++++++++++++++++++
test/disk_tests/usages/lvs | 6 ++--
test/disk_tests/usages/pvs | 2 ++
test/disk_tests/usages/sdk/device/vendor | 1 +
test/disk_tests/usages/sdk/queue/rotational | 1 +
test/disk_tests/usages/sdk/size | 1 +
test/disk_tests/usages/sdk_udevadm | 12 +++++++
test/disk_tests/usages/sdl/device/vendor | 1 +
test/disk_tests/usages/sdl/queue/rotational | 1 +
test/disk_tests/usages/sdl/size | 1 +
test/disk_tests/usages/sdl_udevadm | 12 +++++++
13 files changed, 70 insertions(+), 3 deletions(-)
create mode 100644 test/disk_tests/usages/sdk/device/vendor
create mode 100644 test/disk_tests/usages/sdk/queue/rotational
create mode 100644 test/disk_tests/usages/sdk/size
create mode 100644 test/disk_tests/usages/sdk_udevadm
create mode 100644 test/disk_tests/usages/sdl/device/vendor
create mode 100644 test/disk_tests/usages/sdl/queue/rotational
create mode 100644 test/disk_tests/usages/sdl/size
create mode 100644 test/disk_tests/usages/sdl_udevadm
diff --git a/PVE/Diskmanage.pm b/PVE/Diskmanage.pm
index f446269..0deb1a6 100644
--- a/PVE/Diskmanage.pm
+++ b/PVE/Diskmanage.pm
@@ -258,7 +258,7 @@ sub get_ceph_volume_infos {
if ($fields->[1] =~ m|^osd-([^-]+)-|) {
my $type = $1;
# $result autovivification is wanted, to not creating empty hashes
- if (($type eq 'block' || $type eq 'data') && $fields->[2] =~ m/ceph.osd_id=([^,])/) {
+ if (($type eq 'block' || $type eq 'data') && $fields->[2] =~ m/ceph.osd_id=([^,]+)/) {
$result->{$dev}->{osdid} = $1;
$result->{$dev}->{bluestore} = ($type eq 'block');
} else {
diff --git a/test/disk_tests/usages/disklist b/test/disk_tests/usages/disklist
index 9092ce0..ef443ed 100644
--- a/test/disk_tests/usages/disklist
+++ b/test/disk_tests/usages/disklist
@@ -8,3 +8,5 @@ sdg
sdh
sdi
sdj
+sdk
+sdl
diff --git a/test/disk_tests/usages/disklist_expected.json b/test/disk_tests/usages/disklist_expected.json
index 9829339..610e80f 100644
--- a/test/disk_tests/usages/disklist_expected.json
+++ b/test/disk_tests/usages/disklist_expected.json
@@ -152,5 +152,36 @@
"bluestore": 0,
"type" : "hdd",
"osdid" : 0
+ },
+ "sdk" : {
+ "serial" : "SERIAL1",
+ "vendor" : "ATA",
+ "wwn" : "0x0000000000000000",
+ "devpath" : "/dev/sdk",
+ "model" : "MODEL1",
+ "used" : "LVM",
+ "wearout" : "N/A",
+ "health" : "UNKNOWN",
+ "gpt" : 1,
+ "size" : 1536000,
+ "rpm" : 0,
+ "bluestore": 0,
+ "type" : "hdd",
+ "osdid" : 230
+ },
+ "sdl" : {
+ "serial" : "SERIAL1",
+ "vendor" : "ATA",
+ "wwn" : "0x0000000000000000",
+ "devpath" : "/dev/sdl",
+ "model" : "MODEL1",
+ "used" : "LVM",
+ "wearout" : "N/A",
+ "health" : "UNKNOWN",
+ "gpt" : 1,
+ "size" : 1536000,
+ "rpm" : 0,
+ "type" : "hdd",
+ "osdid" : -1
}
}
diff --git a/test/disk_tests/usages/lvs b/test/disk_tests/usages/lvs
index 393dcd3..8d640e1 100644
--- a/test/disk_tests/usages/lvs
+++ b/test/disk_tests/usages/lvs
@@ -1,4 +1,6 @@
/dev/sdg(0);osd-block-01234;ceph.osd_id=1
/dev/sdh(0);osd-journal-01234;ceph.osd_id=1
-/dev/sdi(0);osd-db-01234;ceph.osd_id=1
-/dev/sdj(0);osd-data-01234;ceph.osd_id=0
+/dev/sdi(0);osd-db-01234;ceph.osd_id=1,dasdf
+/dev/sdj(0);osd-data-01234;ceph.osd_id=0,asfd
+/dev/sdk(0);osd-data-231231;ceph.osd_id=230,ceph.fsid=test
+/dev/sdl(0);osd-data-234132;ceph.osd_id=,bar
diff --git a/test/disk_tests/usages/pvs b/test/disk_tests/usages/pvs
index 0df5080..86ec3d4 100644
--- a/test/disk_tests/usages/pvs
+++ b/test/disk_tests/usages/pvs
@@ -3,3 +3,5 @@
/dev/sdh
/dev/sdi
/dev/sdj
+ /dev/sdk
+ /dev/sdl
diff --git a/test/disk_tests/usages/sdk/device/vendor b/test/disk_tests/usages/sdk/device/vendor
new file mode 100644
index 0000000..531030d
--- /dev/null
+++ b/test/disk_tests/usages/sdk/device/vendor
@@ -0,0 +1 @@
+ATA
diff --git a/test/disk_tests/usages/sdk/queue/rotational b/test/disk_tests/usages/sdk/queue/rotational
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/test/disk_tests/usages/sdk/queue/rotational
@@ -0,0 +1 @@
+1
diff --git a/test/disk_tests/usages/sdk/size b/test/disk_tests/usages/sdk/size
new file mode 100644
index 0000000..13de30f
--- /dev/null
+++ b/test/disk_tests/usages/sdk/size
@@ -0,0 +1 @@
+3000
diff --git a/test/disk_tests/usages/sdk_udevadm b/test/disk_tests/usages/sdk_udevadm
new file mode 100644
index 0000000..3baef2f
--- /dev/null
+++ b/test/disk_tests/usages/sdk_udevadm
@@ -0,0 +1,12 @@
+E: DEVNAME=/dev/sdk
+E: DEVTYPE=disk
+E: ID_ATA_ROTATION_RATE_RPM=0
+E: ID_BUS=ata
+E: ID_MODEL=MODEL1
+E: ID_PART_TABLE_TYPE=gpt
+E: ID_PART_TABLE_UUID=8417b93f-eff9-4e8f-8d84-dc2e77fc07a2
+E: ID_SERIAL=SERIAL1
+E: ID_SERIAL_SHORT=SERIAL1
+E: ID_TYPE=disk
+E: ID_WWN=0x0000000000000000
+E: ID_WWN_WITH_EXTENSION=0x0000000000000000
diff --git a/test/disk_tests/usages/sdl/device/vendor b/test/disk_tests/usages/sdl/device/vendor
new file mode 100644
index 0000000..531030d
--- /dev/null
+++ b/test/disk_tests/usages/sdl/device/vendor
@@ -0,0 +1 @@
+ATA
diff --git a/test/disk_tests/usages/sdl/queue/rotational b/test/disk_tests/usages/sdl/queue/rotational
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/test/disk_tests/usages/sdl/queue/rotational
@@ -0,0 +1 @@
+1
diff --git a/test/disk_tests/usages/sdl/size b/test/disk_tests/usages/sdl/size
new file mode 100644
index 0000000..13de30f
--- /dev/null
+++ b/test/disk_tests/usages/sdl/size
@@ -0,0 +1 @@
+3000
diff --git a/test/disk_tests/usages/sdl_udevadm b/test/disk_tests/usages/sdl_udevadm
new file mode 100644
index 0000000..ead0622
--- /dev/null
+++ b/test/disk_tests/usages/sdl_udevadm
@@ -0,0 +1,12 @@
+E: DEVNAME=/dev/sdl
+E: DEVTYPE=disk
+E: ID_ATA_ROTATION_RATE_RPM=0
+E: ID_BUS=ata
+E: ID_MODEL=MODEL1
+E: ID_PART_TABLE_TYPE=gpt
+E: ID_PART_TABLE_UUID=8417b93f-eff9-4e8f-8d84-dc2e77fc07a2
+E: ID_SERIAL=SERIAL1
+E: ID_SERIAL_SHORT=SERIAL1
+E: ID_TYPE=disk
+E: ID_WWN=0x0000000000000000
+E: ID_WWN_WITH_EXTENSION=0x0000000000000000
--
2.20.1
More information about the pve-devel
mailing list