Remove disk retries and timeouts (#3025)
This commit is contained in:
parent
d2ef961b32
commit
ae51af67a3
|
|
@ -9,7 +9,6 @@ from . import disk
|
||||||
from .exceptions import DiskError, SysCallError
|
from .exceptions import DiskError, SysCallError
|
||||||
from .general import SysCommand, SysCommandWorker, generate_password
|
from .general import SysCommand, SysCommandWorker, generate_password
|
||||||
from .output import debug, info
|
from .output import debug, info
|
||||||
from .storage import storage
|
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
|
|
@ -100,30 +99,12 @@ class Luks2:
|
||||||
|
|
||||||
debug(f'cryptsetup format: {cryptsetup_args}')
|
debug(f'cryptsetup format: {cryptsetup_args}')
|
||||||
|
|
||||||
# Retry formatting the volume because archinstall can some times be too quick
|
try:
|
||||||
# which generates a "Device /dev/sdX does not exist or access denied." between
|
result = SysCommand(cryptsetup_args).decode()
|
||||||
# setting up partitions and us trying to encrypt it.
|
except SysCallError as err:
|
||||||
for retry_attempt in range(storage['DISK_RETRY_ATTEMPTS'] + 1):
|
raise DiskError(f'Could not encrypt volume "{self.luks_dev_path}": {err}')
|
||||||
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']:
|
debug(f'cryptsetup luksFormat output: {result}')
|
||||||
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}')
|
|
||||||
|
|
||||||
self.key_file = key_file
|
self.key_file = key_file
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,6 @@ storage: dict[str, Any] = {
|
||||||
'LOG_FILE': Path('install.log'),
|
'LOG_FILE': Path('install.log'),
|
||||||
'MOUNT_POINT': Path('/mnt/archinstall'),
|
'MOUNT_POINT': Path('/mnt/archinstall'),
|
||||||
'ENC_IDENTIFIER': 'ainst',
|
'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': {'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()
|
'CMD_LOCALE_DEFAULT': {'LC_ALL': 'C'}, # should be the same as the former. Not be used except in reset_cmd_locale()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue