From 671c7b38545079136f804e0fb5b77e21f0dba44f Mon Sep 17 00:00:00 2001 From: Werner Llácer Date: Wed, 10 Nov 2021 11:20:38 +0100 Subject: Solves issue #689. Attribute Error.'None type' has no attribute 'format' ... It seems the system does not syncronus update its internal information after a partitioning. Two places are affected. Directly on filesystem.add_partition (the uuid of the new partition isn't available after the parted command) and blockdevice.get_partition, where the list of partitions for the iterator might not be available in the query. The patch places both sections under controlled loops, giving the system the chance to update the information. Should be more controlled via application parameters --- archinstall/lib/disk/blockdevice.py | 17 ++++++++++++++--- archinstall/lib/disk/filesystem.py | 26 +++++++++++++++----------- 2 files changed, 29 insertions(+), 14 deletions(-) (limited to 'archinstall/lib/disk') diff --git a/archinstall/lib/disk/blockdevice.py b/archinstall/lib/disk/blockdevice.py index 048e51f4..493e5383 100644 --- a/archinstall/lib/disk/blockdevice.py +++ b/archinstall/lib/disk/blockdevice.py @@ -1,9 +1,11 @@ import os import json import logging +import time from ..exceptions import DiskError from ..output import log from ..general import SysCommand +from ..storage import storage GIGA = 2 ** 30 @@ -213,6 +215,15 @@ class BlockDevice: self.part_cache = {} def get_partition(self, uuid): - for partition in self: - if partition.uuid == uuid: - return partition + count = 0 + while count < 5: + for partition in self: + if partition.uuid == uuid: + return partition + else: + log(f"uuid {uuid} not found. Waiting for {count +1} time",level=logging.DEBUG) + time.sleep(float(storage['arguments'].get('disk-sleep', 0.2))) + count +=1 + else: + log(f"Could not find {uuid} in disk after 5 retries",level=logging.INFO) + raise DiskError(f"New partition {uuid} never showed up after adding new partition on {self}") diff --git a/archinstall/lib/disk/filesystem.py b/archinstall/lib/disk/filesystem.py index 4d137163..0be1ec8b 100644 --- a/archinstall/lib/disk/filesystem.py +++ b/archinstall/lib/disk/filesystem.py @@ -167,17 +167,21 @@ class Filesystem: parted_string = f'{self.blockdevice.device} mkpart {partition_type} {start} {end}' if self.parted(parted_string): - start_wait = time.time() - - while previous_partition_uuids == {partition.uuid for partition in self.blockdevice.partitions.values()}: - if time.time() - start_wait > 10: - raise DiskError(f"New partition never showed up after adding new partition on {self} (timeout 10 seconds).") - time.sleep(0.025) - - # Todo: Find a better way to detect if the new UUID of the partition has showed up. - # But this will address (among other issues) - time.sleep(float(storage['arguments'].get('disk-sleep', 2.0))) # Let the kernel catch up with quick block devices (nvme for instance) - return self.blockdevice.get_partition(uuid=(previous_partition_uuids ^ {partition.uuid for partition in self.blockdevice.partitions.values()}).pop()) + count = 0 + while count < 10: + new_uuid = None + new_uuid_set = (previous_partition_uuids ^ {partition.uuid for partition in self.blockdevice.partitions.values()}) + if len(new_uuid_set) > 0: + new_uuid = new_uuid_set.pop() + if new_uuid: + return self.blockdevice.get_partition(new_uuid) + else: + count += 1 + log(f"Could not get uuid for partition. Waiting for the {count} time",level=logging.DEBUG) + time.sleep(float(storage['arguments'].get('disk-sleep', 0.2))) + else: + log("Add partition exiting due to excesive wait time",level=logging.INFO) + raise DiskError(f"New partition never showed up after adding new partition on {self}.") def set_name(self, partition: int, name: str): return self.parted(f'{self.blockdevice.device} name {partition + 1} "{name}"') == 0 -- cgit v1.2.3-54-g00ecf From faadc2b96831a2f55fa7430a3c4ae63c172cefa6 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Wed, 10 Nov 2021 11:40:47 +0000 Subject: Fixed linting issue --- archinstall/lib/disk/blockdevice.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'archinstall/lib/disk') diff --git a/archinstall/lib/disk/blockdevice.py b/archinstall/lib/disk/blockdevice.py index 493e5383..5204f09b 100644 --- a/archinstall/lib/disk/blockdevice.py +++ b/archinstall/lib/disk/blockdevice.py @@ -223,7 +223,7 @@ class BlockDevice: else: log(f"uuid {uuid} not found. Waiting for {count +1} time",level=logging.DEBUG) time.sleep(float(storage['arguments'].get('disk-sleep', 0.2))) - count +=1 + count += 1 else: log(f"Could not find {uuid} in disk after 5 retries",level=logging.INFO) raise DiskError(f"New partition {uuid} never showed up after adding new partition on {self}") -- cgit v1.2.3-54-g00ecf