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

Skip CNV/ODF upgrade when Cluster is already upgraded #909

Merged
merged 1 commit into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
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
34 changes: 21 additions & 13 deletions benchmark_runner/common/clouds/BareMetal/bare_metal_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,24 +230,32 @@ def run_ocp_installer(self):
self._ssh.run(f"ssh -t provision \"{self._install_ocp_cmd()}\" ")
logger.info(f'OpenShift cluster {self._get_installation_version()} version is installed successfully, End time: {datetime.now().strftime(datetime_format)}')

@logger_time_stamp
def run_ocp_upgrade(self, oc: OC):
def is_ocp_already_upgraded(self, oc: OC):
"""
This method runs ocp upgrade
@param oc:
:return: True if installation success and raise exception if installation failed
This method checks if Openshift cluster is already upgraded
@return:
"""
if f'Cluster version is {self._upgrade_ocp_version}' == oc.get_cluster_status():
logger.info(f'Cluster is already upgraded to: {self._upgrade_ocp_version}')
return True
else:
logger.info(f'Starting OCP upgrade, Start time: {datetime.now().strftime(datetime_format)}')
logger.info(f'Stop OCP healthcheck')
oc.healthcheck(action='stop')
oc.upgrade_ocp(upgrade_ocp_version=self._upgrade_ocp_version)
self.verify_upgrade_complete(oc=oc)
logger.info(f'Resume OCP healthcheck')
oc.healthcheck(action='resume')
logger.info(f'Ending OCP upgrade, End time: {datetime.now().strftime(datetime_format)}')
return False

@logger_time_stamp
def run_ocp_upgrade(self, oc: OC):
"""
This method runs OpenShift upgrade
@param oc:
:return:
"""
logger.info(f'Starting OCP upgrade, Start time: {datetime.now().strftime(datetime_format)}')
logger.info(f'Stop OCP healthcheck')
oc.healthcheck(action='stop')
oc.upgrade_ocp(upgrade_ocp_version=self._upgrade_ocp_version)
self.verify_upgrade_complete(oc=oc)
logger.info(f'Resume OCP healthcheck')
oc.healthcheck(action='resume')
logger.info(f'Ending OCP upgrade, End time: {datetime.now().strftime(datetime_format)}')

@logger_time_stamp
def verify_install_complete(self):
Expand Down
9 changes: 5 additions & 4 deletions benchmark_runner/main/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,11 @@ def upgrade_ocp_bare_metal(step: str):
bare_metal_operations.connect_to_provisioner()
oc = bare_metal_operations.oc_login()
if step == 'run_bare_metal_ocp_upgrade':
bare_metal_operations.run_ocp_upgrade(oc)
# The LSO/ODF upgrade must be run manually after the OCP upgrade for the channel version; it won't upgrade automatically.
bare_metal_operations.install_ocp_resources(resources=['lso'], upgrade_version=lso_version)
bare_metal_operations.install_ocp_resources(resources=['odf'], upgrade_version=odf_version)
if not bare_metal_operations.is_ocp_already_upgraded(oc):
bare_metal_operations.run_ocp_upgrade()
# The LSO/ODF upgrade must be run manually after the OCP upgrade for the channel version; it won't upgrade automatically.
bare_metal_operations.install_ocp_resources(resources=['lso'], upgrade_version=lso_version)
bare_metal_operations.install_ocp_resources(resources=['odf'], upgrade_version=odf_version)
elif step == 'verify_bare_metal_upgrade_complete':
if bare_metal_operations.is_cluster_upgraded(oc, cnv_version=cnv_version, odf_version=odf_version, lso_version=lso_version):
bare_metal_operations.verify_cluster_is_up(oc)
Expand Down