From 519263b35619029ffdaf91bfe02a2e079cc7607d Mon Sep 17 00:00:00 2001 From: SrikanthMyakam Date: Fri, 20 Dec 2024 16:36:25 +0530 Subject: [PATCH] Reduce latencies caused by frequent calls to"get_os_disk_controller_type" VM's OS disk controller type doesn't change. --- lisa/features/disks.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lisa/features/disks.py b/lisa/features/disks.py index 13638ed138..4c1d6f8773 100644 --- a/lisa/features/disks.py +++ b/lisa/features/disks.py @@ -68,6 +68,7 @@ def remove_data_disk(self, names: Optional[List[str]] = None) -> None: def _initialize(self, *args: Any, **kwargs: Any) -> None: self.disks: List[str] = [] + self._os_disk_controller_type: Optional[schema.DiskControllerType] = None def get_resource_disk_mount_point(self) -> str: raise NotImplementedError @@ -136,10 +137,13 @@ def get_disk_type(self, disk: str) -> schema.StorageInterfaceType: # Get disk controller type from the VM by checking the boot partition def get_os_disk_controller_type(self) -> schema.DiskControllerType: - boot_partition = self.get_os_boot_partition() - assert boot_partition, "'boot_partition' must not be 'None'" - os_disk_controller_type = self.get_disk_type(boot_partition.disk) - return schema.DiskControllerType(os_disk_controller_type) + if self._os_disk_controller_type is None: + boot_partition = self.get_os_boot_partition() + assert boot_partition, "'boot_partition' must not be 'None'" + self._os_disk_controller_type = schema.DiskControllerType( + self.get_disk_type(boot_partition.disk) + ) + return self._os_disk_controller_type DiskEphemeral = partial(