Skip to content

Commit

Permalink
Skip CNV/ODF upgrade when Cluster is already upgraded (#909)
Browse files Browse the repository at this point in the history
  • Loading branch information
ebattat authored Oct 11, 2024
1 parent 7a812ed commit 26be7c3
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 17 deletions.
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

0 comments on commit 26be7c3

Please sign in to comment.