From 96bc9ad34e3e04d62912ac82f40be4a70c8b6aa6 Mon Sep 17 00:00:00 2001 From: Bala Date: Thu, 7 Nov 2024 08:24:59 +0530 Subject: [PATCH] Allow default behavior for ARM64 machines and skip high-memory VMs (#3498) * Add sufficient sized data-disk in kdump test * Move print_additional_info just before panic * Use execute_async and remove kill_on_timeout parameter * Fix linter errors by moving the check into a new internal function * Remove whitespace * Use black format * Allow default behavior for ARM64 machines and skip high-memory VMs * Fix flake8 error * Fix linter error --- lisa/tools/free.py | 3 ++ lisa/tools/kdump.py | 57 +++++++++++++++--------- microsoft/testsuites/kdump/kdumpcrash.py | 25 ++++------- 3 files changed, 48 insertions(+), 37 deletions(-) diff --git a/lisa/tools/free.py b/lisa/tools/free.py index ff206a98c..1f34175ad 100644 --- a/lisa/tools/free.py +++ b/lisa/tools/free.py @@ -83,6 +83,9 @@ class Free(Tool): def get_free_memory_gb(self) -> int: return self._get_field_bytes_kib("Mem", "free") >> 20 + def get_total_memory_gb(self) -> int: + return self._get_field_bytes_kib("Mem", "total") >> 20 + def get_total_memory(self) -> str: """ Returns total memory in power of 1000 with unit diff --git a/lisa/tools/kdump.py b/lisa/tools/kdump.py index 01c257e0b..37ef599ea 100644 --- a/lisa/tools/kdump.py +++ b/lisa/tools/kdump.py @@ -18,7 +18,7 @@ from lisa.tools.lscpu import Lscpu from lisa.tools.make import Make from lisa.tools.sysctl import Sysctl from lisa.tools.tar import Tar -from lisa.util import LisaException, UnsupportedDistroException +from lisa.util import LisaException, SkippedException, UnsupportedDistroException from .kernel_config import KernelConfig @@ -608,26 +608,6 @@ class KdumpCBLMariner(KdumpBase): """ This method enables the kdump service. """ - kdump_conf = "/etc/kdump.conf" - sed = self.node.tools[Sed] - # Remove force_no_rebuild=1 if present - sed.substitute( - match_lines="^force_no_rebuild", - regexp="force_no_rebuild", - replacement="#force_no_rebuild", - file=kdump_conf, - sudo=True, - ) - # Set mariner_2_initrd_use_suffix. Otherwise it will replace - # the original initrd file which will cause a reboot-loop - sed.substitute( - match_lines="mariner_2_initrd_use_suffix", - regexp="#mariner_2_initrd_use_suffix", - replacement="mariner_2_initrd_use_suffix", - file=kdump_conf, - sudo=True, - ) - # Check for sufficient core numbers self.ensure_nr_cpus() @@ -668,7 +648,42 @@ class KdumpCBLMariner(KdumpBase): """ If the system memory size is bigger than 1T, the default size of /var/crash may not be enough to store the dump file, need to change the dump path + + path option is not supported by default initrd. Regenerated initrd will not + boot properly in ARM64. So, skip the test if it is ARM64 and Mariner-2.0 """ + if ( + self.node.os.information.version.major == 2 + and isinstance(self.node.os, Posix) + and self.node.os.get_kernel_information().hardware_platform == "aarch64" + ): + raise SkippedException( + "path option is not supported in Mariner-2.0 for ARM64. " + "kdump will not work well on high memory Mariner-2.0 systems" + ) + + # Update forc_rebuild before changing the dump path. Otherwise the default + # initrd will not honor the path + kdump_conf = "/etc/kdump.conf" + sed = self.node.tools[Sed] + # Remove force_no_rebuild=1 if present + sed.substitute( + match_lines="^force_no_rebuild", + regexp="force_no_rebuild", + replacement="#force_no_rebuild", + file=kdump_conf, + sudo=True, + ) + # Set mariner_2_initrd_use_suffix. Otherwise it will replace + # the original initrd file which will cause a reboot-loop + sed.substitute( + match_lines="mariner_2_initrd_use_suffix", + regexp="#mariner_2_initrd_use_suffix", + replacement="mariner_2_initrd_use_suffix", + file=kdump_conf, + sudo=True, + ) + self.node.execute( f"mkdir -p {dump_path}", expected_exit_code=0, diff --git a/microsoft/testsuites/kdump/kdumpcrash.py b/microsoft/testsuites/kdump/kdumpcrash.py index 10169169e..681352cba 100644 --- a/microsoft/testsuites/kdump/kdumpcrash.py +++ b/microsoft/testsuites/kdump/kdumpcrash.py @@ -25,7 +25,7 @@ from lisa import ( from lisa.features import Disk, SerialConsole from lisa.features.security_profile import CvmDisabled from lisa.operating_system import BSD, Redhat, Windows -from lisa.tools import Dmesg, Echo, KdumpBase, KernelConfig, Lscpu, Stat +from lisa.tools import Df, Dmesg, Echo, KdumpBase, KernelConfig, Lscpu, Stat from lisa.tools.free import Free from lisa.util.perf_timer import create_timer from lisa.util.shell import try_connect @@ -270,19 +270,12 @@ class KdumpCrash(TestSuite): def _is_system_with_more_memory(self, node: Node) -> bool: free = node.tools[Free] - total_memory = free.get_total_memory() - # Return true when system memory is 10 GiB higher than the OS disk size - if "T" in total_memory or ( - "G" in total_memory - and ( - node.capability.disk - and isinstance(node.capability.disk.os_disk_size, int) - and ( - float(total_memory.strip("G")) - > (node.capability.disk.os_disk_size - 10) - ) - ) - ): + total_memory_in_gb = free.get_total_memory_gb() + + df = node.tools[Df] + available_space_in_os_disk = df.get_filesystem_available_space("/", True) + + if total_memory_in_gb > available_space_in_os_disk: return True return False @@ -300,8 +293,8 @@ class KdumpCrash(TestSuite): self.crash_kernel = "auto" if self._is_system_with_more_memory(node): - # System memory is more os disk size, need to change the dump path - # and increase the timeout duration + # As system memory is more than free os disk size, need to + # change the dump path and increase the timeout duration kdump.config_resource_disk_dump_path( self._get_resource_disk_dump_path(node) )