Skip to content

Commit a5ca728

Browse files
add-hyperconverged-into-dependencies
Signed-off-by: Daniel Osypenko <[email protected]>
1 parent f676b4b commit a5ca728

13 files changed

+435
-63
lines changed

conf/README.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,10 @@ higher priority).
336336
* `node_network_configuration_policy_destination_route` - The destination route of NodeNetworkConfigurationPolicy CR
337337
* `hcp_version` - version of HCP client to be deployed on machine running the tests
338338
* `metallb_version` - MetalLB operator version to install
339-
* `install_hypershift_upstream` - Install hypershift from upstream or not (Default: false). Necessary for unreleased OCP/CNV versions
339+
* `deploy_acm_hub_cluster` - Deploy ACM hub cluster or not (Default: false)
340+
* `cnv_deployment` - Deploy CNV or not (Default: false) necessary for Converged clusters with hosted clients
341+
* `mce_deployment` - Deploy MCE or not (Default: false)
342+
* `deploy_hyperconverged` - Deploy hyperconverged operator or not (Default: false). Necessary for Converged clusters with hosted clients with unreleased OCP version
340343
* `clusters` - section for hosted clusters
341344
* `<cluster name>` - name of the cluster
342345
* `hosted_cluster_path` - path to the cluster directory to store auth_path, credentials files or cluster related files

conf/examples/provider_mode_ibm_cloud_baremetal_kubevirt_clients.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ DEPLOYMENT:
1111
metallb_operator: true
1212
cnv_latest_stable: true
1313
local_storage: true
14+
mce_deployment: false # use when unreleased version on Clients is needed
15+
deploy_hyperconverged: false # use when unreleased version on Clients is needed
1416
ENV_DATA:
1517
platform: "hci_baremetal"
1618
cluster_type: "provider" # it is necessary to run the Hosted clusters deployment on the Provider cluster

ocs_ci/deployment/hosted_cluster.py

+70-53
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import time
66
from concurrent.futures import ThreadPoolExecutor
77
from ocs_ci.deployment.cnv import CNVInstaller
8+
from ocs_ci.deployment.hyperconverged import HyperConverged
89
from ocs_ci.deployment.mce import MCEInstaller
910
from ocs_ci.deployment.deployment import Deployment
1011
from ocs_ci.deployment.helpers.hypershift_base import (
@@ -22,6 +23,7 @@
2223
CommandFailed,
2324
TimeoutExpiredError,
2425
ResourceWrongStatusException,
26+
UnexpectedDeploymentConfiguration,
2527
)
2628
from ocs_ci.ocs.ocp import OCP
2729
from ocs_ci.ocs.resources.catalog_source import CatalogSource
@@ -36,8 +38,6 @@
3638
from ocs_ci.utility.utils import (
3739
exec_cmd,
3840
TimeoutSampler,
39-
get_ocp_version,
40-
get_latest_release_version,
4141
)
4242
from ocs_ci.utility.version import get_semantic_version
4343
from ocs_ci.ocs.resources.storage_client import StorageClient
@@ -260,12 +260,50 @@ def deploy_hosted_ocp_clusters(self, cluster_names_list=None):
260260
# operators and finish the rest preparation steps. For the rest of the clusters we will only deploy OCP
261261
# with hcp command.
262262
first_ocp_deployment = index == 0
263-
cluster_name = hosted_ocp_cluster.deploy_ocp(
264-
deploy_cnv=first_ocp_deployment,
265-
deploy_acm_hub=first_ocp_deployment,
263+
264+
# Put logic on checking and deploying dependencies here
265+
if first_ocp_deployment:
266+
# ACM installation is a default for Provider/Converged deployments
267+
deploy_acm_hub = config.ENV_DATA.get("deploy_acm_hub_cluster", True)
268+
# CNV installation is a default for Provider/Converged deployments
269+
deploy_cnv = config.DEPLOYMENT.get("cnv_deployment", True)
270+
deploy_mce = config.DEPLOYMENT.get("mce_deployment", False)
271+
deploy_hyperconverged = config.ENV_DATA.get(
272+
"deploy_hyperconverged", False
273+
)
274+
275+
# Validate conflicting deployments
276+
if deploy_acm_hub and deploy_mce:
277+
raise UnexpectedDeploymentConfiguration(
278+
"Conflict: Both 'deploy_acm_hub_cluster' and 'mce_deployment' are enabled. Choose one."
279+
)
280+
if deploy_cnv and deploy_hyperconverged:
281+
raise UnexpectedDeploymentConfiguration(
282+
"Conflict: Both 'cnv_deployment' and 'deploy_hyperconverged' are enabled. Choose one."
283+
)
284+
285+
else:
286+
deploy_acm_hub = False
287+
deploy_cnv = False
288+
deploy_hyperconverged = False
289+
deploy_mce = False
290+
291+
if not config.ENV_DATA["platform"].lower() in HCI_PROVIDER_CLIENT_PLATFORMS:
292+
raise ProviderModeNotFoundException()
293+
294+
if not config.ENV_DATA.get("deploy_acm_hub_cluster", True):
295+
deploy_acm_hub = False
296+
297+
hosted_ocp_cluster.deploy_dependencies(
298+
deploy_acm_hub=deploy_acm_hub,
299+
deploy_cnv=deploy_cnv,
266300
deploy_metallb=first_ocp_deployment,
267301
download_hcp_binary=first_ocp_deployment,
302+
deploy_hyperconverged=deploy_hyperconverged,
303+
deploy_mce=deploy_mce,
268304
)
305+
306+
cluster_name = hosted_ocp_cluster.deploy_ocp()
269307
if cluster_name:
270308
cluster_names.append(cluster_name)
271309

@@ -361,14 +399,20 @@ def deploy_multiple_odf_clients(self):
361399

362400

363401
class HypershiftHostedOCP(
364-
HyperShiftBase, MetalLBInstaller, CNVInstaller, Deployment, MCEInstaller
402+
HyperShiftBase,
403+
MetalLBInstaller,
404+
CNVInstaller,
405+
Deployment,
406+
MCEInstaller,
407+
HyperConverged,
365408
):
366409
def __init__(self, name):
367410
Deployment.__init__(self)
368411
HyperShiftBase.__init__(self)
369412
MetalLBInstaller.__init__(self)
370413
CNVInstaller.__init__(self)
371414
MCEInstaller.__init__(self)
415+
HyperConverged.__init__(self)
372416
self.name = name
373417
if config.ENV_DATA.get("clusters", {}).get(self.name):
374418
cluster_path = (
@@ -384,36 +428,16 @@ def __init__(self, name):
384428
f"Cluster path for desired cluster with name '{self.name}' was not found in ENV_DATA.clusters"
385429
)
386430

387-
def deploy_ocp(
388-
self,
389-
deploy_cnv=True,
390-
deploy_acm_hub=True,
391-
deploy_metallb=True,
392-
download_hcp_binary=True,
393-
deploy_mce=True,
394-
):
431+
def deploy_ocp(self, **kwargs) -> str:
395432
"""
396433
Deploy hosted OCP cluster on provisioned Provider platform
397434
398435
Args:
399-
deploy_cnv: (bool) Deploy CNV
400-
deploy_acm_hub: (bool) Deploy ACM Hub
401-
deploy_metallb: (bool) Deploy MetalLB
402-
download_hcp_binary: (bool) Download HCP binary
436+
**kwargs: Additional arguments for create_kubevirt_ocp_cluster (currently not in use)
403437
404438
Returns:
405439
str: Name of the hosted cluster
406440
"""
407-
if not config.ENV_DATA["platform"].lower() in HCI_PROVIDER_CLIENT_PLATFORMS:
408-
raise ProviderModeNotFoundException()
409-
410-
if not config.ENV_DATA.get("deploy_acm_hub_cluster", True):
411-
deploy_acm_hub = False
412-
413-
self.deploy_dependencies(
414-
deploy_acm_hub, deploy_cnv, deploy_metallb, download_hcp_binary, deploy_mce
415-
)
416-
417441
ocp_version = str(config.ENV_DATA["clusters"][self.name].get("ocp_version"))
418442
if ocp_version and len(ocp_version.split(".")) == 2:
419443
# if ocp_version is provided in form x.y, we need to get the full form x.y.z
@@ -461,6 +485,7 @@ def deploy_dependencies(
461485
deploy_metallb,
462486
download_hcp_binary,
463487
deploy_mce,
488+
deploy_hyperconverged,
464489
):
465490
"""
466491
Deploy dependencies for hosted OCP cluster
@@ -470,8 +495,17 @@ def deploy_dependencies(
470495
deploy_metallb: bool Deploy MetalLB
471496
download_hcp_binary: bool Download HCP binary
472497
deploy_mce: bool Deploy mce
498+
deploy_hyperconverged: bool Deploy Hyperconverged
473499
474500
"""
501+
502+
# log out all args in one log.info
503+
logger.info(
504+
f"Deploying dependencies for hosted OCP cluster '{self.name}': "
505+
f"deploy_acm_hub={deploy_acm_hub}, deploy_cnv={deploy_cnv}, "
506+
f"deploy_metallb={deploy_metallb}, download_hcp_binary={download_hcp_binary}, "
507+
f"deploy_mce={deploy_mce}, deploy_hyperconverged={deploy_hyperconverged}"
508+
)
475509
initial_default_sc = helpers.get_default_storage_class()
476510
logger.info(f"Initial default StorageClass: {initial_default_sc}")
477511
if not initial_default_sc == constants.CEPHBLOCKPOOL_SC:
@@ -483,8 +517,15 @@ def deploy_dependencies(
483517
except CommandFailed as e:
484518
logger.error(f"Failed to change default StorageClass: {e}")
485519

486-
if deploy_cnv:
520+
if deploy_cnv and not deploy_hyperconverged:
487521
self.deploy_cnv(check_cnv_ready=True)
522+
elif deploy_hyperconverged and not deploy_cnv:
523+
self.deploy_hyperconverged()
524+
elif deploy_cnv and deploy_hyperconverged:
525+
raise UnexpectedDeploymentConfiguration(
526+
"Both deploy_cnv and deploy_hyperconverged are set to True. "
527+
"Please choose only one of them."
528+
)
488529
if deploy_acm_hub:
489530
self.deploy_acm_hub()
490531
if deploy_metallb:
@@ -495,30 +536,6 @@ def deploy_dependencies(
495536
self.deploy_mce()
496537
self.validate_mce_deployment()
497538

498-
provider_ocp_version = str(
499-
get_semantic_version(get_ocp_version(), only_major_minor=True)
500-
)
501-
latest_released_ocp_version = str(
502-
get_semantic_version(get_latest_release_version(), only_major_minor=True)
503-
)
504-
505-
if provider_ocp_version > latest_released_ocp_version:
506-
logger.info("running on unreleased OCP version")
507-
if config.ENV_DATA.get("install_hypershift_upstream"):
508-
try:
509-
self.disable_multicluster_engine()
510-
# avoid timelapse error "
511-
# Error: [serviceaccounts "operator" is forbidden: unable to create new content"
512-
logger.info(
513-
"Sleeping for 5 minutes after disable_multicluster_engine()"
514-
)
515-
time.sleep(5 * 60)
516-
self.install_hypershift_upstream_on_cluster()
517-
except CommandFailed as e:
518-
raise AssertionError(
519-
f"Failed to install Hypershift on the cluster: {e}"
520-
)
521-
522539
# Enable central infrastructure management service for agent
523540
if config.DEPLOYMENT.get("hosted_cluster_platform") == "agent":
524541
provisioning_obj = OCP(**OCP(kind=constants.PROVISIONING).get()[0])

0 commit comments

Comments
 (0)