Skip to content

Commit

Permalink
Merge pull request #10658 from clacroix12/fdf-deployment
Browse files Browse the repository at this point in the history
FDF Deployment support
  • Loading branch information
clacroix12 authored Oct 14, 2024
2 parents 8f8479d + aff9a54 commit 17cd6c8
Show file tree
Hide file tree
Showing 8 changed files with 389 additions and 12 deletions.
7 changes: 7 additions & 0 deletions conf/ocsci/fdf_deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
DEPLOYMENT:
fusion_deployment: True
fdf_deployment: True
channel: v2.0

ENV_DATA:
skip_ocs_deployment: true
22 changes: 10 additions & 12 deletions ocs_ci/deployment/deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,10 +542,7 @@ def do_deploy_fusion(self):
"""
Install IBM Fusion operator
"""
if (
config.DEPLOYMENT.get("fusion_deployment")
and not config.ENV_DATA["skip_ocs_deployment"]
):
if config.DEPLOYMENT.get("fusion_deployment"):
# create catalog source
create_fusion_catalog_source()

Expand Down Expand Up @@ -573,14 +570,14 @@ def do_deploy_fusion(self):
csv = CSV(resource_name=csv_name, namespace=fusion_namespace)
csv.wait_for_phase("Succeeded", timeout=300)

# delete catalog source of IBM
run_cmd(
f"oc delete catalogsource {defaults.FUSION_CATALOG_NAME} -n {constants.MARKETPLACE_NAMESPACE}"
)
logger.info(
f"Sleeping for 30 seconds after deleting catalogsource {defaults.FUSION_CATALOG_NAME}"
)
time.sleep(30)
def do_deploy_fdf(self):
"""
Install IBM Fusion Data Foundation
"""
if config.DEPLOYMENT.get("fdf_deployment"):
from ocs_ci.deployment.fusion_data_foundation import deploy_fdf

deploy_fdf()

def do_deploy_odf_provider_mode(self):
"""
Expand Down Expand Up @@ -700,6 +697,7 @@ def deploy_cluster(self, log_cli_level="DEBUG"):
self.do_deploy_ocs()
self.do_deploy_rdr()
self.do_deploy_fusion()
self.do_deploy_fdf()
self.do_deploy_odf_provider_mode()
self.do_deploy_cnv()
self.do_deploy_hosted_clusters()
Expand Down
139 changes: 139 additions & 0 deletions ocs_ci/deployment/fusion_data_foundation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
"""
This module contains functions needed to install IBM Fusion Data Foundation.
"""

import logging

from ocs_ci.ocs import constants
from ocs_ci.ocs.exceptions import CommandFailed
from ocs_ci.ocs.resources.ocs import OCP, OCS
from ocs_ci.utility.retry import retry
from ocs_ci.utility.utils import run_cmd


logger = logging.getLogger(__name__)


def deploy_fdf():
"""
Installs IBM Fusion Data Foundation.
"""
logger.info("Installing IBM Fusion Data Foundation")
create_image_tag_mirror_set()
create_image_digest_mirror_set()
create_spectrum_fusion_cr()
create_fdf_service_cr()
verify_fdf_installation()


def create_image_tag_mirror_set():
"""
Create ImageTagMirrorSet.
"""
logger.info("Creating FDF ImageTagMirrorSet")
run_cmd(f"oc create -f {constants.FDF_IMAGE_TAG_MIRROR_SET}")


def create_image_digest_mirror_set():
"""
Create ImageDigestMirrorSet.
"""
logger.info("Creating FDF ImageDigestMirrorSet")
run_cmd(f"oc create -f {constants.FDF_IMAGE_DIGEST_MIRROR_SET}")


def create_spectrum_fusion_cr():
"""
Create SpectrumFusion CR if it doesn't already exist.
"""
if spectrum_fusion_existstance_check():
spectrum_fusion_status_check()
logger.info("SpectrumFusion already exists and is Completed")
else:
logger.info("Creating SpectrumFusion")
run_cmd(f"oc create -f {constants.FDF_SPECTRUM_FUSION_CR}")
spectrum_fusion_status_check()


def create_fdf_service_cr():
"""
Create Fusion Data Foundation Service CR.
"""
logger.info("Creating FDF service CR")
run_cmd(f"oc create -f {constants.FDF_SERVICE_CR}")


def verify_fdf_installation():
"""
Verify the FDF installation was successful.
"""
logger.info("Verifying FDF installation")
fusion_service_instance_health_check()


def spectrum_fusion_existstance_check():
"""
Check for the existance of SpectrumFusion.
Returns:
bool: Existance of SpectrumFusion
"""
spectrumfusion = OCS(
kind="SpectrumFusion",
metadata={
"namespace": constants.FDF_NAMESPACE,
"name": "spectrumfusion",
},
)
try:
spectrumfusion.reload()
except CommandFailed as e:
error_msg = '"spectrumfusion" not found'
if error_msg in str(e):
return False
return True


@retry((AssertionError, KeyError), 10, 5)
def spectrum_fusion_status_check():
"""
Ensure SpectrumFusion is in the Completed state.
Raises:
AssertionError: If SpectrumFusion is not in a completed state.
KeyError: If the status isn't present in the SpectrumFusion data.
"""
spectrumfusion = OCS(
kind="SpectrumFusion",
metadata={
"namespace": constants.FDF_NAMESPACE,
"name": "spectrumfusion",
},
)
spectrumfusion.reload()
spectrumfusion_status = spectrumfusion.data["status"]["status"]
assert spectrumfusion_status == "Completed"


@retry((AssertionError, KeyError), 20, 30)
def fusion_service_instance_health_check():
"""
Ensure the FusionServiceInstance is in the Healthy state.
Raises:
AssertionError: If the FusionServiceInstance is not in a completed state.
KeyError: If the health status isn't present in the FusionServiceInstance data.
"""
instance = OCP(
resource_name="odfmanager",
kind="FusionServiceInstance",
namespace=constants.FDF_NAMESPACE,
)
instance_status = instance.data["status"]
service_health = instance_status["health"]
install_percent = instance_status["installStatus"]["progressPercentage"]
assert service_health == "Healthy"
assert install_percent == 100
10 changes: 10 additions & 0 deletions ocs_ci/ocs/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -3040,3 +3040,13 @@
MC_WORKAROUND_SSD = os.path.join(
TEMPLATE_DEPLOYMENT_DIR_OCP, "workaround-ssd-machine-config.yaml"
)

# Fusion Data Foundation
FDF_TEMPLATE_DIR = os.path.join(TEMPLATE_DIR, "fusion-data-foundation")
FDF_IMAGE_TAG_MIRROR_SET = os.path.join(FDF_TEMPLATE_DIR, "image-tag-mirror-set.yaml")
FDF_IMAGE_DIGEST_MIRROR_SET = os.path.join(
FDF_TEMPLATE_DIR, "image-digest-mirror-set.yaml"
)
FDF_SERVICE_CR = os.path.join(FDF_TEMPLATE_DIR, "data-foundation-instance.yaml")
FDF_SPECTRUM_FUSION_CR = os.path.join(FDF_TEMPLATE_DIR, "spectrum-fusion.yaml")
FDF_NAMESPACE = "ibm-spectrum-fusion-ns"
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
apiVersion: service.isf.ibm.com/v1
kind: FusionServiceInstance
metadata:
name: odfmanager
namespace: ibm-spectrum-fusion-ns
spec:
creator: User
doInstall: true
parameters:
- name: namespace
provided: false
value: openshift-storage
- name: creator
provided: false
value: Fusion
- name: backingStorageType
provided: true
value: Dynamic
- name: autoUpgrade
provided: false
value: "true"
serviceDefinition: data-foundation-service
triggerUpdate: false
Loading

0 comments on commit 17cd6c8

Please sign in to comment.