From a63e8ae7f99ac41673536cfcf8fcc5c4d724a2ee Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Tue, 26 Apr 2022 21:57:33 +0200 Subject: Torxed issue 1083 (#1090) * Optimized a bunch of partprobe calls. Namely fixed sleep calls, added optional path to the general archinstall.partprobe() call. And fixed some error handling in a few places which should tell us where #1083 might be going wrong. * Fixed some flake8 complaints * Fixed sleep having a min() of 0.1 or given value. * Fixed sleep having a correct range variable. * Fixed sleep logic to use max() instead of min() as it will never use the higer sleep values otheride * Added error handling to Partition().partprobe() as it would cause certain issues with USB disks. Also made Partition()._safe_uuid more safe by eliminating exceptions being raised. --- archinstall/lib/disk/partition.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/archinstall/lib/disk/partition.py b/archinstall/lib/disk/partition.py index a44efa26..e7568258 100644 --- a/archinstall/lib/disk/partition.py +++ b/archinstall/lib/disk/partition.py @@ -192,7 +192,9 @@ class Partition: For bind mounts all the subvolumes share the same uuid """ for i in range(storage['DISK_RETRY_ATTEMPTS']): - self.partprobe() + if not self.partprobe(): + raise DiskError(f"Could not perform partprobe on {self.device_path}") + time.sleep(max(0.1, storage['DISK_TIMEOUTS'] * i)) partuuid = self._safe_uuid @@ -208,13 +210,11 @@ class Partition: This function should only be used where uuid is not crucial. For instance when you want to get a __repr__ of the class. """ - try: - self.partprobe() - except SysCallError as partprobe_error: + if not self.partprobe(): if self.block_device.info.get('TYPE') == 'iso9660': return None - raise DiskError(f"Could not get PARTUUID of partition {self} due to partprobe error: {partprobe_error}") + log(f"Could not reliably refresh PARTUUID of partition {self.device_path} due to partprobe error.", level=logging.DEBUG) try: return SysCommand(f'blkid -s PARTUUID -o value {self.device_path}').decode('UTF-8').strip() @@ -223,7 +223,7 @@ class Partition: # Parent device is a Optical Disk (.iso dd'ed onto a device for instance) return None - raise DiskError(f"Could not get PARTUUID of partition {self}: {error}") + log(f"Could not get PARTUUID of partition using 'blkid -s PARTUUID -o value {self.device_path}': {error}") @property def encrypted(self) -> Union[bool, None]: @@ -267,8 +267,12 @@ class Partition: yield result def partprobe(self) -> bool: - if self.block_device and SysCommand(f'partprobe {self.block_device.device}').exit_code == 0: - return True + try: + if self.block_device: + return 0 == SysCommand(f'partprobe {self.block_device.device}').exit_code + except SysCallError as error: + log(f"Unreliable results might be given for {self.path} due to partprobe error: {error}", level=logging.DEBUG) + return False def detect_inner_filesystem(self, password :str) -> Optional[str]: -- cgit v1.2.3-54-g00ecf