diff --git a/ocs_ci/deployment/helpers/hypershift_base.py b/ocs_ci/deployment/helpers/hypershift_base.py index ce2cab789974..3f1ba80694ec 100644 --- a/ocs_ci/deployment/helpers/hypershift_base.py +++ b/ocs_ci/deployment/helpers/hypershift_base.py @@ -593,6 +593,20 @@ def get_mce_version(self): logger.info(f"Multicluster engine version: {cmd_res.stdout.decode('utf-8')}") return cmd_res.stdout.decode("utf-8") + def hypershift_upstream_installed(self): + """ + Check if hypershift is installed on the cluster + Returns: + bool: True if hypershift is installed, False otherwise + """ + cmd = "oc get deployments -n hypershift | awk 'NR>1 {print \"true\"; exit}' " + cmd_res = exec_cmd(cmd, shell=True) + if cmd_res.returncode != 0: + logger.error(f"Failed to get hypershift operator version\n{cmd_res.stderr}") + return False + + return cmd_res.stdout.decode("utf-8").strip() == "true" + def install_hypershift_upstream_on_cluster(self): """ Install hypershift on the cluster diff --git a/ocs_ci/deployment/hosted_cluster.py b/ocs_ci/deployment/hosted_cluster.py index 5f8a6c16b9e5..9d6118c2861e 100644 --- a/ocs_ci/deployment/hosted_cluster.py +++ b/ocs_ci/deployment/hosted_cluster.py @@ -353,13 +353,20 @@ def deploy_dependencies( ) if provider_ocp_version > latest_released_ocp_version: - try: - self.disable_multicluster_engine() - self.install_hypershift_upstream_on_cluster() - except CommandFailed as e: - raise AssertionError( - f"Failed to install Hypershift on the cluster: {e}" - ) + if not self.hypershift_upstream_installed(): + try: + self.disable_multicluster_engine() + # avoid timelapse error " + # Error: [serviceaccounts "operator" is forbidden: unable to create new content" + logger.info( + "Sleeping for 5 minutes after disable_multicluster_engine()" + ) + time.sleep(5 * 60) + self.install_hypershift_upstream_on_cluster() + except CommandFailed as e: + raise AssertionError( + f"Failed to install Hypershift on the cluster: {e}" + ) class HostedODF(HypershiftHostedOCP):