Skip to content

Commit

Permalink
add-hyperconverged-into-dependencies
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Osypenko <[email protected]>
  • Loading branch information
DanielOsypenko committed Feb 27, 2025
1 parent 9660e9d commit 2872d02
Show file tree
Hide file tree
Showing 13 changed files with 435 additions and 63 deletions.
5 changes: 4 additions & 1 deletion conf/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,10 @@ higher priority).
* `node_network_configuration_policy_destination_route` - The destination route of NodeNetworkConfigurationPolicy CR
* `hcp_version` - version of HCP client to be deployed on machine running the tests
* `metallb_version` - MetalLB operator version to install
* `install_hypershift_upstream` - Install hypershift from upstream or not (Default: false). Necessary for unreleased OCP/CNV versions
* `deploy_acm_hub_cluster` - Deploy ACM hub cluster or not (Default: false)
* `cnv_deployment` - Deploy CNV or not (Default: false) necessary for Converged clusters with hosted clients
* `mce_deployment` - Deploy MCE or not (Default: false)
* `deploy_hyperconverged` - Deploy hyperconverged operator or not (Default: false). Necessary for Converged clusters with hosted clients with unreleased OCP version
* `clusters` - section for hosted clusters
* `<cluster name>` - name of the cluster
* `hosted_cluster_path` - path to the cluster directory to store auth_path, credentials files or cluster related files
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ DEPLOYMENT:
metallb_operator: true
cnv_latest_stable: true
local_storage: true
mce_deployment: false # use when unreleased version on Clients is needed
deploy_hyperconverged: false # use when unreleased version on Clients is needed
ENV_DATA:
platform: "hci_baremetal"
cluster_type: "provider" # it is necessary to run the Hosted clusters deployment on the Provider cluster
Expand Down
123 changes: 70 additions & 53 deletions ocs_ci/deployment/hosted_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import time
from concurrent.futures import ThreadPoolExecutor
from ocs_ci.deployment.cnv import CNVInstaller
from ocs_ci.deployment.hyperconverged import HyperConverged
from ocs_ci.deployment.mce import MCEInstaller
from ocs_ci.deployment.deployment import Deployment
from ocs_ci.deployment.helpers.hypershift_base import (
Expand All @@ -22,6 +23,7 @@
CommandFailed,
TimeoutExpiredError,
ResourceWrongStatusException,
UnexpectedDeploymentConfiguration,
)
from ocs_ci.ocs.ocp import OCP
from ocs_ci.ocs.resources.catalog_source import CatalogSource
Expand All @@ -36,8 +38,6 @@
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
from ocs_ci.ocs.resources.storage_client import StorageClient
Expand Down Expand Up @@ -260,12 +260,50 @@ def deploy_hosted_ocp_clusters(self, cluster_names_list=None):
# operators and finish the rest preparation steps. For the rest of the clusters we will only deploy OCP
# with hcp command.
first_ocp_deployment = index == 0
cluster_name = hosted_ocp_cluster.deploy_ocp(
deploy_cnv=first_ocp_deployment,
deploy_acm_hub=first_ocp_deployment,

# Put logic on checking and deploying dependencies here
if first_ocp_deployment:
# ACM installation is a default for Provider/Converged deployments
deploy_acm_hub = config.ENV_DATA.get("deploy_acm_hub_cluster", True)
# CNV installation is a default for Provider/Converged deployments
deploy_cnv = config.DEPLOYMENT.get("cnv_deployment", True)
deploy_mce = config.DEPLOYMENT.get("mce_deployment", False)
deploy_hyperconverged = config.ENV_DATA.get(
"deploy_hyperconverged", False
)

# Validate conflicting deployments
if deploy_acm_hub and deploy_mce:
raise UnexpectedDeploymentConfiguration(
"Conflict: Both 'deploy_acm_hub_cluster' and 'mce_deployment' are enabled. Choose one."
)
if deploy_cnv and deploy_hyperconverged:
raise UnexpectedDeploymentConfiguration(
"Conflict: Both 'cnv_deployment' and 'deploy_hyperconverged' are enabled. Choose one."
)

else:
deploy_acm_hub = False
deploy_cnv = False
deploy_hyperconverged = False
deploy_mce = False

if not config.ENV_DATA["platform"].lower() in HCI_PROVIDER_CLIENT_PLATFORMS:
raise ProviderModeNotFoundException()

if not config.ENV_DATA.get("deploy_acm_hub_cluster", True):
deploy_acm_hub = False

hosted_ocp_cluster.deploy_dependencies(
deploy_acm_hub=deploy_acm_hub,
deploy_cnv=deploy_cnv,
deploy_metallb=first_ocp_deployment,
download_hcp_binary=first_ocp_deployment,
deploy_hyperconverged=deploy_hyperconverged,
deploy_mce=deploy_mce,
)

cluster_name = hosted_ocp_cluster.deploy_ocp()
if cluster_name:
cluster_names.append(cluster_name)

Expand Down Expand Up @@ -361,14 +399,20 @@ def deploy_multiple_odf_clients(self):


class HypershiftHostedOCP(
HyperShiftBase, MetalLBInstaller, CNVInstaller, Deployment, MCEInstaller
HyperShiftBase,
MetalLBInstaller,
CNVInstaller,
Deployment,
MCEInstaller,
HyperConverged,
):
def __init__(self, name):
Deployment.__init__(self)
HyperShiftBase.__init__(self)
MetalLBInstaller.__init__(self)
CNVInstaller.__init__(self)
MCEInstaller.__init__(self)
HyperConverged.__init__(self)
self.name = name
if config.ENV_DATA.get("clusters", {}).get(self.name):
cluster_path = (
Expand All @@ -384,36 +428,16 @@ def __init__(self, name):
f"Cluster path for desired cluster with name '{self.name}' was not found in ENV_DATA.clusters"
)

def deploy_ocp(
self,
deploy_cnv=True,
deploy_acm_hub=True,
deploy_metallb=True,
download_hcp_binary=True,
deploy_mce=True,
):
def deploy_ocp(self, **kwargs) -> str:
"""
Deploy hosted OCP cluster on provisioned Provider platform
Args:
deploy_cnv: (bool) Deploy CNV
deploy_acm_hub: (bool) Deploy ACM Hub
deploy_metallb: (bool) Deploy MetalLB
download_hcp_binary: (bool) Download HCP binary
**kwargs: Additional arguments for create_kubevirt_ocp_cluster (currently not in use)
Returns:
str: Name of the hosted cluster
"""
if not config.ENV_DATA["platform"].lower() in HCI_PROVIDER_CLIENT_PLATFORMS:
raise ProviderModeNotFoundException()

if not config.ENV_DATA.get("deploy_acm_hub_cluster", True):
deploy_acm_hub = False

self.deploy_dependencies(
deploy_acm_hub, deploy_cnv, deploy_metallb, download_hcp_binary, deploy_mce
)

ocp_version = str(config.ENV_DATA["clusters"][self.name].get("ocp_version"))
if ocp_version and len(ocp_version.split(".")) == 2:
# if ocp_version is provided in form x.y, we need to get the full form x.y.z
Expand Down Expand Up @@ -461,6 +485,7 @@ def deploy_dependencies(
deploy_metallb,
download_hcp_binary,
deploy_mce,
deploy_hyperconverged,
):
"""
Deploy dependencies for hosted OCP cluster
Expand All @@ -470,8 +495,17 @@ def deploy_dependencies(
deploy_metallb: bool Deploy MetalLB
download_hcp_binary: bool Download HCP binary
deploy_mce: bool Deploy mce
deploy_hyperconverged: bool Deploy Hyperconverged
"""

# log out all args in one log.info
logger.info(
f"Deploying dependencies for hosted OCP cluster '{self.name}': "
f"deploy_acm_hub={deploy_acm_hub}, deploy_cnv={deploy_cnv}, "
f"deploy_metallb={deploy_metallb}, download_hcp_binary={download_hcp_binary}, "
f"deploy_mce={deploy_mce}, deploy_hyperconverged={deploy_hyperconverged}"
)
initial_default_sc = helpers.get_default_storage_class()
logger.info(f"Initial default StorageClass: {initial_default_sc}")
if not initial_default_sc == constants.CEPHBLOCKPOOL_SC:
Expand All @@ -483,8 +517,15 @@ def deploy_dependencies(
except CommandFailed as e:
logger.error(f"Failed to change default StorageClass: {e}")

if deploy_cnv:
if deploy_cnv and not deploy_hyperconverged:
self.deploy_cnv(check_cnv_ready=True)
elif deploy_hyperconverged and not deploy_cnv:
self.deploy_hyperconverged()
elif deploy_cnv and deploy_hyperconverged:
raise UnexpectedDeploymentConfiguration(
"Both deploy_cnv and deploy_hyperconverged are set to True. "
"Please choose only one of them."
)
if deploy_acm_hub:
self.deploy_acm_hub()
if deploy_metallb:
Expand All @@ -495,30 +536,6 @@ def deploy_dependencies(
self.deploy_mce()
self.validate_mce_deployment()

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:
logger.info("running on unreleased OCP version")
if config.ENV_DATA.get("install_hypershift_upstream"):
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}"
)

# Enable central infrastructure management service for agent
if config.DEPLOYMENT.get("hosted_cluster_platform") == "agent":
provisioning_obj = OCP(**OCP(kind=constants.PROVISIONING).get()[0])
Expand Down
Loading

0 comments on commit 2872d02

Please sign in to comment.