From 59c35df0676977c93ed7276237179c9af8d9c476 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Tue, 26 Apr 2022 17:13:47 +0200 Subject: Optimized a bunch of partprobe calls. (#1088) * 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 --- archinstall/lib/disk/filesystem.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'archinstall/lib/disk/filesystem.py') diff --git a/archinstall/lib/disk/filesystem.py b/archinstall/lib/disk/filesystem.py index 25e251c2..8a531de0 100644 --- a/archinstall/lib/disk/filesystem.py +++ b/archinstall/lib/disk/filesystem.py @@ -11,7 +11,7 @@ if TYPE_CHECKING: from .partition import Partition from .validators import valid_fs_type -from ..exceptions import DiskError +from ..exceptions import DiskError, SysCallError from ..general import SysCommand from ..output import log from ..storage import storage @@ -49,7 +49,7 @@ class Filesystem: def partuuid_to_index(self, uuid :str) -> Optional[int]: for i in range(storage['DISK_RETRY_ATTEMPTS']): self.partprobe() - time.sleep(5) + time.sleep(max(0.1, storage['DISK_TIMEOUTS'] * i)) # We'll use unreliable lbslk to grab children under the /dev/ output = json.loads(SysCommand(f"lsblk --json {self.blockdevice.device}").decode('UTF-8')) @@ -61,8 +61,6 @@ class Filesystem: if partition_uuid.lower() == uuid.lower(): return index - time.sleep(storage['DISK_TIMEOUTS']) - raise DiskError(f"Failed to convert PARTUUID {uuid} to a partition index number on blockdevice {self.blockdevice.device}") def load_layout(self, layout :Dict[str, Any]) -> None: @@ -162,11 +160,11 @@ class Filesystem: return partition def partprobe(self) -> bool: - result = SysCommand(f'partprobe {self.blockdevice.device}') - - if result.exit_code != 0: - log(f"Could not execute partprobe: {result!r}", level=logging.ERROR, fg="red") - raise DiskError(f"Could not run partprobe: {result!r}") + try: + SysCommand(f'partprobe {self.blockdevice.device}') + except SysCallError as error: + log(f"Could not execute partprobe: {error!r}", level=logging.ERROR, fg="red") + raise DiskError(f"Could not run partprobe on {self.blockdevice.device}: {error!r}") return True -- cgit v1.2.3-54-g00ecf