Enhance block device management - #498
Conversation
f101a3f to
ede9108
Compare
e0dd6d1 to
edb6dbf
Compare
edb6dbf to
36bfb8c
Compare
ede9108 to
483adb0
Compare
36bfb8c to
bc1eab6
Compare
483adb0 to
1960a93
Compare
bc1eab6 to
be2cd1f
Compare
8f39146 to
2710827
Compare
9f88dc5 to
7cc39d2
Compare
| self.block_devices_info = sorted(devices, key=lambda d: d.name) | ||
| logging.debug("blockdevs found: %s", [d.name for d in self.block_devices_info]) | ||
|
|
||
| def _disk_is_available_local(self, disk: str) -> bool: |
There was a problem hiding this comment.
Declare it before the method that uses it?
| ret = {host: list(_host_disks(host, cli_disks.get(host.hostname_or_ip))) | ||
| for host in pools_hosts_by_name_or_ip.values() | ||
| } | ||
| # Cross-host deduplication: a LUN in use on any host (same WWN) is unavailable on all hosts. |
There was a problem hiding this comment.
Comment about the commit message: I read it but it didn't explain what problem it solves. Only how it solves it.
3845b8f to
8b8e409
Compare
ce5225e to
e196d05
Compare
e196d05 to
291e27e
Compare
|
I've reworked the block device again to mark disks with unused partitions as available. |
1130de5 to
dc44617
Compare
vxgmichel
left a comment
There was a problem hiding this comment.
One suggestion, LGTM otherwise 👍
| dev: false | ||
| - name: Create a dummy data.py | ||
| run: cp data.py-dist data.py | ||
| - run: pytest tests/unit/*.py |
There was a problem hiding this comment.
Maybe follow the convention for python test discovery by renaming tests/unit/rescan_block_devices_info.py to tests/unit/test_rescan_block_devices_info.py?
| - run: pytest tests/unit/*.py | |
| - run: pytest tests/unit |
There was a problem hiding this comment.
I voluntarily kept them without the test_ prefix, so they are not run with the other tests, to not add more to the output in jenkins or in our terminal.
Do you think that's a problem?
There was a problem hiding this comment.
Alternatively, we could put then under /unit so that they're easier to run from CLI directly without having to think about the *.py stuff.
There was a problem hiding this comment.
Apparently passing a test directory explicitly takes priority over --ignore, so another possible approach would be add the following.
diff --git a/pytest.ini b/pytest.ini
index 3deaa2c..bf08f83 100644
--- a/pytest.ini
+++ b/pytest.ini
@@ -1,5 +1,5 @@
[pytest]
-addopts = -ra --maxfail=1 --ignore=contrib/
+addopts = -ra --maxfail=1 --ignore=contrib/ --ignore=tests/unit
markers =
# *** Markers that change test behaviour ***
default_vm: mark a test with a default VM in case no --vm parameter was given.This effectively disables the unit tests by default.
But @stormi suggestion of using a unit directory outside of tests is probably more explicit. It would require defining testpaths though:
diff --git a/pytest.ini b/pytest.ini
index 3deaa2c..a94601d 100644
--- a/pytest.ini
+++ b/pytest.ini
@@ -1,5 +1,6 @@
[pytest]
-addopts = -ra --maxfail=1 --ignore=contrib/
+testpaths = tests
+addopts = -ra --maxfail=1
markers =There was a problem hiding this comment.
Apparently passing a test directory explicitly takes priority over
--ignore
I did that. Running the unit tests is now done with just pytest tests/unit.
Replace the BlockDeviceInfo TypedDict with a typed dataclass that includes availability as a field, computed once at scan time from lsblk output (mountpoint and device type). Extend enumeration beyond local disks to also cover mdadm arrays and multipath devices, using a single lsblk call. Mark disk with unused partitions as available. Update all callers to use attribute access instead of dict subscript. Add a unit test suite and a CI workflow to run it. Signed-off-by: Gaëtan Lehmann <gaetan.lehmann@vates.tech>
zpool destroy removes the pool but leaves ZFS member signatures and the partition table on disk, causing the device to appear in use on the next test run. Signed-off-by: Gaëtan Lehmann <gaetan.lehmann@vates.tech>
Use WWNs in the disk fixture to: - Mark a LUN unavailable on all hosts if it is already in use on any host (cross-host deduplication for shared FC/iSCSI LUNs). - Deprioritize LUNs listed in LVMOHBA_DEVICE_CONFIG or LVMOISCSI_DEVICE_CONFIG so they are only selected when no other disk is available. Signed-off-by: Gaëtan Lehmann <gaetan.lehmann@vates.tech>
dc44617 to
2d3046e
Compare
Some block devices may be used to build other devices (mdadm, lvm) or be accessible on multiple hosts, but only usable on a single one at a time (fc, iscsi).
This PR is part of a tree containing 19 PRs:
mastermaster