Skip to content

Commit 9c0a67c

Browse files
add deploy_hyperconverged to main deploy function
Signed-off-by: Daniel Osypenko <[email protected]>
1 parent d08b50e commit 9c0a67c

10 files changed

+110
-24
lines changed

conf/README.md

-1
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,6 @@ higher priority).
338338
* `metallb_version` - MetalLB operator version to install
339339
* `deploy_acm_hub_cluster` - Deploy ACM hub cluster or not (Default: false)
340340
* `cnv_deployment` - Deploy CNV or not (Default: false) necessary for Converged clusters with hosted clients
341-
* `mce_deployment` - Deploy MCE or not (Default: false)
342341
* `deploy_hyperconverged` - Deploy hyperconverged operator or not (Default: false). Necessary for Converged clusters with hosted clients with unreleased OCP version
343342
* `clusters` - section for hosted clusters
344343
* `<cluster name>` - name of the cluster

conf/examples/provider_mode_ibm_cloud_baremetal_kubevirt_clients.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ 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
1514
deploy_hyperconverged: false # use when unreleased version on Clients is needed
1615
ENV_DATA:
1716
platform: "hci_baremetal"
@@ -21,6 +20,7 @@ ENV_DATA:
2120
acm_hub_channel: "release-2.10" # this is an example, please provide the desired version
2221
hcp_version: "4.16" # this is an example, please provide the desired version
2322
metallb_version: "4.16" # this is an example, please provide the desired version
23+
deploy_mce: false # second option to enable multicluster setup; used instead of ACM
2424
clusters: # the list of the Hosted clusters and their configuration. If field does not exist HostedClsuter installation will be skipped
2525
hcp415-bm3-e: # the field name is the name of the Hosted cluster
2626
hosted_cluster_path: "~/clusters/hcp416-bm3-e/openshift-cluster-dir" # path to store auth_path dir or cluster related files

ocs_ci/deployment/deployment.py

+22-3
Original file line numberDiff line numberDiff line change
@@ -459,11 +459,14 @@ def do_deploy_ocs(self):
459459
def do_deploy_mce(self):
460460
"""
461461
Deploy Multicluster Engine
462+
Shall run on OCP deployment phase
462463
463464
"""
464-
if config.DEPLOYMENT.get("deploy_mce"):
465-
mce_installer = MCEInstaller()
466-
mce_installer.deploy_mce()
465+
if config.ENV_DATA["skip_ocs_deployment"]:
466+
467+
if config.DEPLOYMENT.get("deploy_mce"):
468+
mce_installer = MCEInstaller()
469+
mce_installer.deploy_mce()
467470

468471
def do_deploy_oadp(self):
469472
"""
@@ -641,6 +644,21 @@ def do_deploy_cnv(self):
641644
check_cnv_ready = True
642645
CNVInstaller().deploy_cnv(check_cnv_deployed, check_cnv_ready)
643646

647+
def do_deploy_hyperconverged(self):
648+
"""
649+
Deploy HyperConverged Operator and resources that works instead of CNV operator.
650+
Should run on OCP deployment phase
651+
"""
652+
if config.ENV_DATA["skip_ocs_deployment"]:
653+
654+
if config.ENV_DATA.get(
655+
"deploy_hyperconverged"
656+
) and not config.DEPLOYMENT.get("cnv_deployment"):
657+
from ocs_ci.deployment.hyperconverged import HyperConverged
658+
659+
hyperconverged = HyperConverged()
660+
hyperconverged.deploy_hyperconverged()
661+
644662
def do_deploy_metallb(self):
645663
"""
646664
Deploy MetalLB
@@ -739,6 +757,7 @@ def deploy_cluster(self, log_cli_level="DEBUG"):
739757
self.do_deploy_odf_provider_mode()
740758
self.do_deploy_mce()
741759
self.do_deploy_cnv()
760+
self.do_deploy_hyperconverged()
742761
self.do_deploy_metallb()
743762
self.do_deploy_hosted_clusters()
744763

ocs_ci/deployment/helpers/hypershift_base.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -260,9 +260,12 @@ def install_hcp_and_hypershift_from_git(self):
260260
f"hypershift binary download failed to path:{self.hypershift_binary_path}"
261261
)
262262

263-
def download_hcp_binary_with_podman(self):
263+
def _download_hcp_binary_with_podman(self):
264264
"""
265265
Download hcp binary to bin_dir
266+
267+
!!! This method is not used in the code, but it is kept for reference !!!
268+
Use install_hcp_and_hypershift_from_git instead
266269
"""
267270
if self.hcp_binary_exists():
268271
logger.info(

ocs_ci/deployment/hosted_cluster.py

+15-11
Original file line numberDiff line numberDiff line change
@@ -264,18 +264,18 @@ def deploy_hosted_ocp_clusters(self, cluster_names_list=None):
264264
# Put logic on checking and deploying dependencies here
265265
if first_ocp_deployment:
266266
# ACM installation is a default for Provider/Converged deployments
267-
deploy_acm_hub = config.ENV_DATA.get("deploy_acm_hub_cluster", True)
267+
deploy_acm_hub = config.ENV_DATA.get("deploy_acm_hub_cluster", False)
268268
# 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)
269+
deploy_cnv = config.DEPLOYMENT.get("cnv_deployment", False)
270+
deploy_mce = config.DEPLOYMENT.get("deploy_mce", False)
271271
deploy_hyperconverged = config.ENV_DATA.get(
272272
"deploy_hyperconverged", False
273273
)
274274

275275
# Validate conflicting deployments
276276
if deploy_acm_hub and deploy_mce:
277277
raise UnexpectedDeploymentConfiguration(
278-
"Conflict: Both 'deploy_acm_hub_cluster' and 'mce_deployment' are enabled. Choose one."
278+
"Conflict: Both 'deploy_acm_hub_cluster' and 'deploy_mce' are enabled. Choose one."
279279
)
280280
if deploy_cnv and deploy_hyperconverged:
281281
raise UnexpectedDeploymentConfiguration(
@@ -291,9 +291,6 @@ def deploy_hosted_ocp_clusters(self, cluster_names_list=None):
291291
if not config.ENV_DATA["platform"].lower() in HCI_PROVIDER_CLIENT_PLATFORMS:
292292
raise ProviderModeNotFoundException()
293293

294-
if not config.ENV_DATA.get("deploy_acm_hub_cluster", True):
295-
deploy_acm_hub = False
296-
297294
hosted_ocp_cluster.deploy_dependencies(
298295
deploy_acm_hub=deploy_acm_hub,
299296
deploy_cnv=deploy_cnv,
@@ -356,7 +353,7 @@ def download_hosted_clusters_kubeconfig_files(self):
356353
"""
357354

358355
if not (self.hcp_binary_exists() and self.hypershift_binary_exists()):
359-
self.download_hcp_binary_with_podman()
356+
self.update_hcp_binary()
360357

361358
for name in config.ENV_DATA.get("clusters").keys():
362359
path = config.ENV_DATA.get("clusters").get(name).get("hosted_cluster_path")
@@ -526,14 +523,21 @@ def deploy_dependencies(
526523
"Both deploy_cnv and deploy_hyperconverged are set to True. "
527524
"Please choose only one of them."
528525
)
529-
if deploy_acm_hub:
526+
527+
if deploy_acm_hub and not deploy_mce:
530528
self.deploy_acm_hub()
529+
elif deploy_mce and not deploy_acm_hub:
530+
self.deploy_mce()
531+
elif deploy_acm_hub and deploy_mce:
532+
raise UnexpectedDeploymentConfiguration(
533+
"Both deploy_acm_hub and deploy_mce are set to True. "
534+
"Please choose only one of them."
535+
)
536+
531537
if deploy_metallb:
532538
self.deploy_lb()
533539
if download_hcp_binary:
534540
self.update_hcp_binary()
535-
if deploy_mce and not deploy_acm_hub:
536-
self.deploy_mce()
537541

538542
# Enable central infrastructure management service for agent
539543
if config.DEPLOYMENT.get("hosted_cluster_platform") == "agent":

ocs_ci/deployment/hyperconverged.py

+18-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import logging
22
import semantic_version
33

4+
from ocs_ci.ocs.exceptions import HyperConvergedNotDeployedException
45
from ocs_ci.ocs.ocp import OCP
56
from ocs_ci.ocs import constants
67
from ocs_ci.ocs.resources.deployment import Deployment
@@ -10,6 +11,7 @@
1011
from ocs_ci.ocs.version import get_ocp_version
1112
from ocs_ci.utility import templating
1213
from ocs_ci.ocs.resources.catalog_source import CatalogSource
14+
from ocs_ci.utility.utils import wait_custom_resource_defenition_available
1315

1416
logger = logging.getLogger(__name__)
1517

@@ -150,7 +152,7 @@ def create_hyperconverged_instance(self):
150152
should_exist=True, resource_name=constants.HYPERCONVERGED_NAME
151153
)
152154
# wait for pods to be up and running
153-
deployments = ["virt-api", "virt-controller", "virt-exporterproxy"]
155+
deployments = ["virt-operator", "virt-api", "virt-controller"]
154156

155157
for resource_name in deployments:
156158
depl_ocp_obj = OCP(
@@ -172,6 +174,10 @@ def deploy_hyperconverged(self):
172174
HyperConverged.create_operator_group(self)
173175
HyperConverged.create_catalog_source(self)
174176
HyperConverged.create_subscription(self)
177+
if not wait_custom_resource_defenition_available(constants.HYPERCONVERGED_CRD):
178+
raise HyperConvergedNotDeployedException(
179+
f"crd {constants.HYPERCONVERGED_CRD} is unavailable"
180+
)
175181
HyperConverged.create_hyperconverged_instance(self)
176182

177183

@@ -184,13 +190,14 @@ def get_hyperconverged_corresponding_version(ocp_version: str) -> str:
184190
- Hyperconverged Minor = OCP Minor - 4
185191
186192
Args:
187-
ocp_version: OCP version as a string (e.g., "4.18")
193+
ocp_version: OCP version as a string (e.g., "4.18" or "4.18.3")
188194
Returns:
189195
Corresponding Hyperconverged version as a string (e.g., "1.14")
190196
"""
191-
ocp_semver = semantic_version.Version(
192-
ocp_version + ".0"
193-
) # Ensure valid semantic versioning
197+
if not semantic_version.validate(ocp_version):
198+
ocp_version += ".0" # Ensure valid semantic versioning if patch is missing
199+
200+
ocp_semver = semantic_version.Version(ocp_version)
194201
hyperconverged_major = ocp_semver.major - 3
195202
hyperconverged_minor = ocp_semver.minor - 4
196203

@@ -210,7 +217,12 @@ def get_ocp_corresponding_version(hyperconverged_version: str) -> str:
210217
Returns:
211218
Corresponding OCP version as a string (e.g., "4.18")
212219
"""
213-
hyperconverged_semver = semantic_version.Version(hyperconverged_version + ".0")
220+
if not semantic_version.validate(hyperconverged_version):
221+
hyperconverged_version += (
222+
".0" # Ensure valid semantic versioning if patch is missing
223+
)
224+
225+
hyperconverged_semver = semantic_version.Version(hyperconverged_version)
214226
ocp_major = hyperconverged_semver.major + 3
215227
ocp_minor = hyperconverged_semver.minor + 4
216228

ocs_ci/deployment/mce.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,16 @@
1515
from ocs_ci.utility.utils import (
1616
run_cmd,
1717
exec_cmd,
18+
wait_custom_resource_defenition_available,
1819
)
1920
from ocs_ci.ocs.resources.catalog_source import CatalogSource
2021
from ocs_ci.ocs.resources.deployment import Deployment
2122
from ocs_ci.utility.utils import get_running_ocp_version
22-
from ocs_ci.ocs.exceptions import CommandFailed, UnavailableResourceException
23+
from ocs_ci.ocs.exceptions import (
24+
CommandFailed,
25+
UnavailableResourceException,
26+
MultiClusterEngineNotDeployedException,
27+
)
2328

2429
logger = logging.getLogger(__name__)
2530

@@ -235,6 +240,12 @@ def deploy_mce(self):
235240
qe_app_registry.catalog_source()
236241
self.create_mce_namespace()
237242
self.create_mce_subscription()
243+
if not wait_custom_resource_defenition_available(
244+
constants.MULTICLUSTER_ENGINE_CRD
245+
):
246+
raise MultiClusterEngineNotDeployedException(
247+
f"crd {constants.MULTICLUSTER_ENGINE_CRD} is unavailable"
248+
)
238249
self.create_multiclusterengine_operatorgroup()
239250

240251
# check whether mce instance is created, if it is installed but mce don't pass validation we can not heal it in

ocs_ci/ocs/constants.py

+3
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@
249249
ENCRYPTIONKEYROTATIONCRONJOB = "encryptionkeyrotationcronjobs.csiaddons.openshift.io"
250250
ENCRYPTIONKEYROTATIONJOB = "encryptionkeyrotationjobs.csiaddons.openshift.io"
251251
DEFAULT_CEPH_DEVICECLASS = "defaultCephDeviceClass"
252+
CRD_KIND = "CustomResourceDefinition"
252253

253254
# Provisioners
254255
AWS_EFS_PROVISIONER = "openshift.org/aws-efs"
@@ -532,6 +533,7 @@
532533
HYPERCONVERGED_YAML = os.path.join(
533534
TEMPLATE_DEPLOYMENT_DIR_HYPERCONVERGED, "hyperconverged.yaml"
534535
)
536+
HYPERCONVERGED_CRD = "hyperconvergeds.hco.kubevirt.io"
535537

536538

537539
# CNV deployment constants
@@ -2811,6 +2813,7 @@
28112813
MCE_OPERATOR_GROUP_YAML = os.path.join(
28122814
TEMPLATE_DEPLOYMENT_DIR_MCE, "mce_operatorgroup.yaml"
28132815
)
2816+
MULTICLUSTER_ENGINE_CRD = "multiclusterengines.multicluster.openshift.io"
28142817
HYPERSHIFT_NAMESPACE = "hypershift"
28152818
SUPPORTED_VERSIONS_CONFIGMAP = "supported-versions"
28162819
IMAGE_OVERRIDE_JSON = os.path.join(TEMPLATE_DEPLOYMENT_DIR_MCE, "image-override.json")

ocs_ci/ocs/exceptions.py

+8
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,14 @@ class HyperConvergedHealthException(Exception):
687687
pass
688688

689689

690+
class HyperConvergedNotDeployedException(Exception):
691+
pass
692+
693+
694+
class MultiClusterEngineNotDeployedException(Exception):
695+
pass
696+
697+
690698
class OpenShiftAPIResponseException(Exception):
691699
def __init__(self, response):
692700
self.response = response

ocs_ci/utility/utils.py

+27
Original file line numberDiff line numberDiff line change
@@ -5389,3 +5389,30 @@ def create_config_ini_file(params):
53895389
log.info(f"config.ini file for cluster is located at {config_ini_file.name}")
53905390

53915391
return config_ini_file.name
5392+
5393+
5394+
def wait_custom_resource_defenition_available(crd_name, timeout=600):
5395+
"""
5396+
Wait for the custom resource definition to be available
5397+
5398+
Args:
5399+
crd_name (str): Name of the custom resource definition
5400+
timeout (int): Time in seconds to wait for the CRD to be available
5401+
Returns:
5402+
bool: True if CRD is available, False otherwise
5403+
5404+
"""
5405+
from ocs_ci.ocs.ocp import OCP
5406+
5407+
wait = 10
5408+
retry_num = timeout // wait
5409+
crd_obj = OCP(kind=constants.CRD_KIND)
5410+
return bool(
5411+
crd_obj.get(
5412+
resource_name=crd_name,
5413+
out_yaml_format=False,
5414+
retry=retry_num,
5415+
wait=wait,
5416+
dont_raise=True,
5417+
)
5418+
)

0 commit comments

Comments
 (0)