Skip to content

Commit

Permalink
hypershift upstream Fix 0.1
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Osypenko <[email protected]>
  • Loading branch information
DanielOsypenko committed Apr 10, 2024
1 parent 3d4d57d commit 2f2f5a6
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 38 deletions.
24 changes: 23 additions & 1 deletion ocs_ci/deployment/cnv.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@
)
from ocs_ci.utility import templating
from ocs_ci.ocs import constants
from ocs_ci.utility.utils import run_cmd
from ocs_ci.utility.utils import (
run_cmd,
exec_cmd,
)
from ocs_ci.ocs import exceptions
from ocs_ci.ocs.resources.catalog_source import CatalogSource
from ocs_ci.ocs.resources.install_plan import wait_for_install_plan_and_approve
Expand Down Expand Up @@ -612,3 +615,22 @@ def deploy_cnv(self, check_cnv_deployed=False, check_cnv_ready=False):
self.enable_software_emulation()
# Download and extract the virtctl binary to bin_dir
self.download_and_extract_virtctl_binary()

def disable_multicluster_engine(self):
"""
Disable multicluster engine on cluster
"""
logger.info("Disabling multicluster engine")
cmd = (
"oc patch mce multiclusterengine "
'-p \'{"spec":{"overrides":{"components":['
'{"enabled":false, "name":"hypershift"},'
'{"enabled":false, "name":"hypershift-local-hosting"}, '
'{"enabled":false, "name":"local-cluster"}'
"]}}}' --type=merge"
)
cmd_res = exec_cmd(cmd, shell=True)
if cmd_res.returncode != 0:
logger.error(f"Failed to disable multicluster engine\n{cmd_res.stderr}")
return
logger.info(cmd_res.stdout.decode("utf-8").splitlines())
19 changes: 0 additions & 19 deletions ocs_ci/deployment/helpers/hypershift_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -593,25 +593,6 @@ 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 disable_multicluster_engine(self):
"""
Disable multicluster engine on cluster
"""
logger.info("Disabling multicluster engine")
cmd = (
"oc patch mce multiclusterengine "
'-p \'{"spec":{"overrides":{"components":['
'{"enabled":false, "name":"hypershift"},'
'{"enabled":false, "name":"hypershift-local-hosting"}, '
'{"enabled":false, "name":"local-cluster"}'
"]}}}' --type=merge"
)
cmd_res = exec_cmd(cmd, shell=True)
if cmd_res.returncode != 0:
logger.error(f"Failed to disable multicluster engine\n{cmd_res.stderr}")
return
logger.info(cmd_res.stdout.decode("utf-8").splitlines())

def install_hypershift_upstream_on_cluster(self):
"""
Install hypershift on the cluster
Expand Down
40 changes: 22 additions & 18 deletions ocs_ci/deployment/hosted_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,15 @@
from ocs_ci.ocs.resources.pod import (
wait_for_pods_to_be_in_statuses_concurrently,
)
from ocs_ci.ocs.version import get_ocp_version
from ocs_ci.utility import templating
from ocs_ci.utility.managedservice import generate_onboarding_token
from ocs_ci.utility.retry import retry
from ocs_ci.utility.utils import exec_cmd, TimeoutSampler, get_latest_release_version
from ocs_ci.utility.utils import (
exec_cmd,
TimeoutSampler,
get_ocp_version,
get_latest_release_version,
)
from ocs_ci.utility.version import get_semantic_version

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -75,22 +79,6 @@ def do_deploy(self):
due to n-1 logic we are assuming that desired CNV version <= OCP version
"""

provider_ocp_version = str(
get_semantic_version(get_ocp_version(), only_major_minor=True)
)
latest_released_ocp_version = str(
get_semantic_version(get_latest_release_version(), only_major_minor=True)
)

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}"
)

# stage 1 deploy multiple hosted OCP clusters
cluster_names = self.deploy_hosted_ocp_clusters()

Expand Down Expand Up @@ -357,6 +345,22 @@ def deploy_dependencies(
if download_hcp_binary:
self.update_hcp_binary()

provider_ocp_version = str(
get_semantic_version(get_ocp_version(), only_major_minor=True)
)
latest_released_ocp_version = str(
get_semantic_version(get_latest_release_version(), only_major_minor=True)
)

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}"
)


class HostedODF(HypershiftHostedOCP):
def __init__(self, name: str):
Expand Down

0 comments on commit 2f2f5a6

Please sign in to comment.