From ae51af67a3c33bd2bff999acad0da616ab907eeb Mon Sep 17 00:00:00 2001 From: codefiles <11915375+codefiles@users.noreply.github.com> Date: Thu, 19 Dec 2024 01:49:44 -0500 Subject: [PATCH] Remove disk retries and timeouts (#3025) --- archinstall/lib/luks.py | 29 +++++------------------------ archinstall/lib/storage.py | 2 -- 2 files changed, 5 insertions(+), 26 deletions(-) diff --git a/archinstall/lib/luks.py b/archinstall/lib/luks.py index ad2ab91a..81de0d97 100644 --- a/archinstall/lib/luks.py +++ b/archinstall/lib/luks.py @@ -9,7 +9,6 @@ from . import disk from .exceptions import DiskError, SysCallError from .general import SysCommand, SysCommandWorker, generate_password from .output import debug, info -from .storage import storage @dataclass @@ -100,30 +99,12 @@ class Luks2: debug(f'cryptsetup format: {cryptsetup_args}') - # Retry formatting the volume because archinstall can some times be too quick - # which generates a "Device /dev/sdX does not exist or access denied." between - # setting up partitions and us trying to encrypt it. - for retry_attempt in range(storage['DISK_RETRY_ATTEMPTS'] + 1): - try: - result = SysCommand(cryptsetup_args).decode() - debug(f'cryptsetup luksFormat output: {result}') - break - except SysCallError as err: - time.sleep(storage['DISK_TIMEOUTS']) + try: + result = SysCommand(cryptsetup_args).decode() + except SysCallError as err: + raise DiskError(f'Could not encrypt volume "{self.luks_dev_path}": {err}') - if retry_attempt != storage['DISK_RETRY_ATTEMPTS']: - continue - - if err.exit_code == 1: - info(f'luks2 partition currently in use: {self.luks_dev_path}') - info('Attempting to unmount, crypt-close and trying encryption again') - - self.lock() - # Then try again to set up the crypt-device - result = SysCommand(cryptsetup_args).decode() - debug(f'cryptsetup luksFormat output: {result}') - else: - raise DiskError(f'Could not encrypt volume "{self.luks_dev_path}": {err}') + debug(f'cryptsetup luksFormat output: {result}') self.key_file = key_file diff --git a/archinstall/lib/storage.py b/archinstall/lib/storage.py index 10e716ad..372ebaeb 100644 --- a/archinstall/lib/storage.py +++ b/archinstall/lib/storage.py @@ -14,8 +14,6 @@ storage: dict[str, Any] = { 'LOG_FILE': Path('install.log'), 'MOUNT_POINT': Path('/mnt/archinstall'), 'ENC_IDENTIFIER': 'ainst', - 'DISK_TIMEOUTS': 1, # seconds - 'DISK_RETRY_ATTEMPTS': 5, # RETRY_ATTEMPTS * DISK_TIMEOUTS is used in disk operations 'CMD_LOCALE': {'LC_ALL': 'C'}, # default locale for execution commands. Can be overridden with set_cmd_locale() 'CMD_LOCALE_DEFAULT': {'LC_ALL': 'C'}, # should be the same as the former. Not be used except in reset_cmd_locale() }