Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hot Fix: ODF disk count issue #914

Merged
merged 1 commit into from
Oct 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this usually won't be run interactively, but it isn't a bad idea to catch KeyboardInterrupt and BrokenPipe and exit.

Copy link
Collaborator Author

@ebattat ebattat Oct 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case of error I dont want to exit jenkin pipeline, I return '-1'

# 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