Skip to content

Commit

Permalink
Remove disk retries and timeouts
Browse files Browse the repository at this point in the history
  • Loading branch information
codefiles committed Dec 18, 2024
1 parent d2ef961 commit 0a6a5b4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 27 deletions.
31 changes: 6 additions & 25 deletions archinstall/lib/luks.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from .exceptions import DiskError, SysCallError
from .general import SysCommand, SysCommandWorker, generate_password
from .output import debug, info
from .storage import storage


@dataclass
Expand Down Expand Up @@ -100,30 +99,12 @@ def encrypt(

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'])

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}')
try:
result = SysCommand(cryptsetup_args).decode()
except SysCallError as err:
raise DiskError(f'Could not encrypt volume "{self.luks_dev_path}": {err}')

debug(f'cryptsetup luksFormat output: {result}')

self.key_file = key_file

Expand Down
2 changes: 0 additions & 2 deletions archinstall/lib/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
'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()
}

0 comments on commit 0a6a5b4

Please sign in to comment.