Skip to content

Commit

Permalink
Fix ODF disk count (#914)
Browse files Browse the repository at this point in the history
  • Loading branch information
ebattat authored Oct 8, 2024
1 parent 31c3720 commit 6d3ee45
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions benchmark_runner/common/oc/oc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down

0 comments on commit 6d3ee45

Please sign in to comment.