From 6d3ee45443174e08bdea75b83577edf00a6d1403 Mon Sep 17 00:00:00 2001 From: Elib <73884315+ebattat@users.noreply.github.com> Date: Tue, 8 Oct 2024 08:48:18 +0300 Subject: [PATCH] Fix ODF disk count (#914) --- benchmark_runner/common/oc/oc.py | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/benchmark_runner/common/oc/oc.py b/benchmark_runner/common/oc/oc.py index 85540f9d..a3655667 100644 --- a/benchmark_runner/common/oc/oc.py +++ b/benchmark_runner/common/oc/oc.py @@ -411,11 +411,28 @@ def verify_odf_installation(self, namespace: str = 'openshift-storage'): def get_odf_disk_count(self): """ - This method returns odf disk count - :return: + This method returns the ODF disk count. + :return: ODF disk count or -1 if the count cannot be retrieved """ if self.is_odf_installed(): - return int(self.run(f"{self.__cli} get --no-headers pod -n openshift-storage | grep osd | grep -cv prepare")) + try: + # Run the command to get ODF disk count + disk_count_str = self.run( + f"{self.__cli} get --no-headers pod -n openshift-storage | grep osd | grep -cv prepare") + disk_count = int(disk_count_str) + return disk_count + except ValueError as e: + # Log the error and return -1 as a fallback + logger.error(f"Error converting ODF disk count to integer: {e}") + return -1 + except Exception as e: + # Handle any other unexpected errors + logger.error(f"Unexpected error while getting ODF disk count: {e}") + return -1 + else: + # If ODF is not installed, return -1 + logger.info("ODF is not installed.") + return -1 def is_kata_installed(self): """