From 3106ab238d8c55938399ea35ec9f4e4ca3c9fa54 Mon Sep 17 00:00:00 2001 From: oviner Date: Mon, 17 Jun 2024 15:00:34 +0300 Subject: [PATCH 1/7] Version details for all DR components Signed-off-by: oviner --- ocs_ci/framework/__init__.py | 27 ++++++++ ocs_ci/ocs/constants.py | 1 + ocs_ci/ocs/resources/ocs.py | 46 +++++++++++++- ocs_ci/ocs/utils.py | 11 ++++ ocs_ci/utility/utils.py | 6 +- ocs_ci/utility/version.py | 119 +++++++++++++++++++++++++++++++++++ tests/conftest.py | 54 ++++++++++++++++ 7 files changed, 260 insertions(+), 4 deletions(-) diff --git a/ocs_ci/framework/__init__.py b/ocs_ci/framework/__init__.py index 18e73ffbf34..4e61f85c14f 100644 --- a/ocs_ci/framework/__init__.py +++ b/ocs_ci/framework/__init__.py @@ -451,6 +451,33 @@ def switch_to_cluster_by_cluster_type(self, cluster_type, num_of_cluster=0): self.get_cluster_type_indices_list(cluster_type)[num_of_cluster] ) + class RunWithConfigContext(object): + def __init__(self, config_index): + self.original_config_index = config.cur_index + self.config_index = config_index + + def __enter__(self): + config.switch_ctx(self.config_index) + return self + + def __exit__(self, exc_type, exc_value, exc_traceback): + config.switch_ctx(self.original_config_index) + + class RunWithAcmConfigContext(RunWithConfigContext): + def __init__(self): + from ocs_ci.ocs.utils import get_all_acm_indexes + + acm_index = get_all_acm_indexes()[0] + super().__init__(acm_index) + + class RunWithPrimaryConfigContext(RunWithConfigContext): + def __init__(self): + from ocs_ci.ocs.utils import get_primary_cluster_config + + primary_config = get_primary_cluster_config() + primary_index = primary_config.MULTICLUSTER.get("multicluster_index") + super().__init__(primary_index) + config = MultiClusterConfig() diff --git a/ocs_ci/ocs/constants.py b/ocs_ci/ocs/constants.py index ed110225f83..35904779fc1 100644 --- a/ocs_ci/ocs/constants.py +++ b/ocs_ci/ocs/constants.py @@ -249,6 +249,7 @@ TEST_FILES_BUCKET = "ocsci-test-files" ROOK_REPOSITORY = "https://github.com/rook/rook.git" OPENSHIFT_STORAGE_NAMESPACE = "openshift-storage" +OPENSHIFT_NAMESPACE = "openshift" OPENSHIFT_STORAGE_CLIENT_NAMESPACE = "openshift-storage-client" OPENSHIFT_STORAGE_EXTENDED_NAMESPACE = "openshift-storage-extended" OPENSHIFT_STORAGE_CLIENT_NAMESPACE = "openshift-storage-client" diff --git a/ocs_ci/ocs/resources/ocs.py b/ocs_ci/ocs/resources/ocs.py index aff3600ce5e..ef60fb26caf 100644 --- a/ocs_ci/ocs/resources/ocs.py +++ b/ocs_ci/ocs/resources/ocs.py @@ -17,7 +17,15 @@ from ocs_ci.ocs.exceptions import CSVNotFound from ocs_ci.utility import templating, utils from ocs_ci.utility.version import get_semantic_ocs_version_from_config, VERSION_4_9 - +from ocs_ci.utility.version import ( + get_dr_hub_operator_version, + get_ocp_dr_cluster_operator_version, + get_odf_multicluster_orchestrator_version, + get_ocp_gitops_operator_version, + get_submariner_operator_version, + get_volsync_operator_version, +) +from ocs_ci.utility.utils import get_oadp_version, get_acm_version log = logging.getLogger(__name__) @@ -205,6 +213,42 @@ def get_version_info(namespace=None): csv_name = package_manifest.get_current_csv(channel) csv_pre = CSV(resource_name=csv_name, namespace=namespace) info = get_images(csv_pre.get()) + from ocs_ci.ocs.utils import is_dr_scenario + + if is_dr_scenario(): + with config.RunWithAcmConfigContext(): + acm_operator_version = get_acm_version() + if acm_operator_version: + info["acm_version"] = acm_operator_version + ocp_dr_hub_operator_version = get_dr_hub_operator_version() + if ocp_dr_hub_operator_version: + info["dr_hub_version"] = ocp_dr_hub_operator_version + odf_multicluster_orchestrator_version = ( + get_odf_multicluster_orchestrator_version() + ) + if odf_multicluster_orchestrator_version: + info[ + "odf_multicluster_orchestrator_version" + ] = odf_multicluster_orchestrator_version + gitops_operator_version = get_ocp_gitops_operator_version() + if gitops_operator_version: + info["gitops_version"] = gitops_operator_version + with config.RunWithPrimaryConfigContext(): + oadp_operator_version = get_oadp_version() + if oadp_operator_version: + info["oadp_version"] = oadp_operator_version + ocp_dr_cluster_operator_version = get_ocp_dr_cluster_operator_version() + if ocp_dr_cluster_operator_version: + info["ocp_dr_cluster_version"] = ocp_dr_cluster_operator_version + gitops_operator_version = get_ocp_gitops_operator_version() + if gitops_operator_version: + info["gitops_version"] = gitops_operator_version + volsync_operator_version = get_volsync_operator_version() + if volsync_operator_version: + info["volsync_version"] = volsync_operator_version + submariner_operator_version = get_submariner_operator_version() + if submariner_operator_version: + info["submariner_version"] = submariner_operator_version return info diff --git a/ocs_ci/ocs/utils.py b/ocs_ci/ocs/utils.py index 3aa380d64a5..8ae455ae545 100644 --- a/ocs_ci/ocs/utils.py +++ b/ocs_ci/ocs/utils.py @@ -1681,3 +1681,14 @@ def collect_pod_container_rpm_package(dir_name): go_log_file_name = f"{package_log_dir_path}/{pod_obj.name}-{container_name}-go-version.log" with open(go_log_file_name, "w") as f: f.write(go_output) + + +def is_dr_scenario(): + """ + Check if it is RDR or MDR setup + + Returns: + bool: return True if it is rdr or mdr setup otherwise False + + """ + return ocsci_config.MULTICLUSTER["multicluster_mode"] in ("metro-dr", "regional-dr") diff --git a/ocs_ci/utility/utils.py b/ocs_ci/utility/utils.py index 605f9e2feb9..bfd5a473208 100644 --- a/ocs_ci/utility/utils.py +++ b/ocs_ci/utility/utils.py @@ -4824,7 +4824,7 @@ def add_time_report_to_email(session, soup): summary_tag.insert_after(time_div) -def get_oadp_version(namespace=constants.ACM_HUB_BACKUP_NAMESPACE): +def get_oadp_version(namespace=constants.OADP_NAMESPACE): """ Returns: str: returns version string @@ -4839,7 +4839,7 @@ def get_oadp_version(namespace=constants.ACM_HUB_BACKUP_NAMESPACE): return csv["spec"]["version"] -def get_acm_version(): +def get_acm_version(namespace=constants.ACM_HUB_NAMESPACE): """ Get ACM version from CSV @@ -4850,7 +4850,7 @@ def get_acm_version(): from ocs_ci.ocs.resources.csv import get_csvs_start_with_prefix csv_list = get_csvs_start_with_prefix( - "advanced-cluster-management", namespace=constants.ACM_HUB_NAMESPACE + "advanced-cluster-management", namespace=namespace ) for csv in csv_list: if "advanced-cluster-management" in csv["metadata"]["name"]: diff --git a/ocs_ci/utility/version.py b/ocs_ci/utility/version.py index 93093504a49..d48f783a02d 100644 --- a/ocs_ci/utility/version.py +++ b/ocs_ci/utility/version.py @@ -9,6 +9,7 @@ from ocs_ci.framework import config from ocs_ci.ocs import defaults from ocs_ci.ocs.exceptions import WrongVersionExpression +from ocs_ci.ocs import constants def get_semantic_version( @@ -172,3 +173,121 @@ def get_previous_version(version, count=1): new_minor = version.minor - count previous_version = f"{version.major}.{new_minor}" return previous_version + + +def get_dr_hub_operator_version(namespace=constants.OPENSHIFT_NAMESPACE): + """ + Get DR Hub Operator Version + + Returns: + str: returns version string + + """ + # Importing here to avoid circular dependency + from ocs_ci.ocs.resources.csv import get_csvs_start_with_prefix + + csv_list = get_csvs_start_with_prefix( + constants.ACM_ODR_HUB_OPERATOR_RESOURCE, namespace=namespace + ) + for csv in csv_list: + if constants.ACM_ODR_HUB_OPERATOR_RESOURCE in csv["metadata"]["name"]: + # extract version string + return csv["spec"]["version"] + + +def get_ocp_dr_cluster_operator_version(namespace=constants.OPENSHIFT_NAMESPACE): + """ + Get DR Hub Operator Version + + Returns: + str: returns version string + + """ + # Importing here to avoid circular dependency + from ocs_ci.ocs.resources.csv import get_csvs_start_with_prefix + + csv_list = get_csvs_start_with_prefix("odr-cluster-operator", namespace=namespace) + for csv in csv_list: + if "odr-cluster-operator" in csv["metadata"]["name"]: + # extract version string + return csv["spec"]["version"] + + +def get_odf_multicluster_orchestrator_version(namespace=constants.ACM_HUB_NAMESPACE): + """ + Get ODF Multicluster Orchestrator Version + + Returns: + str: returns version string + + """ + # Importing here to avoid circular dependency + from ocs_ci.ocs.resources.csv import get_csvs_start_with_prefix + + csv_list = get_csvs_start_with_prefix( + constants.ACM_ODF_MULTICLUSTER_ORCHESTRATOR_RESOURCE, + namespace=namespace, + ) + for csv in csv_list: + if ( + constants.ACM_ODF_MULTICLUSTER_ORCHESTRATOR_RESOURCE + in csv["metadata"]["name"] + ): + # extract version string + return csv["spec"]["version"] + + +def get_ocp_gitops_operator_version(namespace=constants.OPENSHIFT_NAMESPACE): + """ + Get OCP Gitops Operator Version + + Returns: + str: returns version string + + """ + # Importing here to avoid circular dependency + from ocs_ci.ocs.resources.csv import get_csvs_start_with_prefix + + csv_list = get_csvs_start_with_prefix( + "openshift-gitops-operator", namespace=namespace + ) + for csv in csv_list: + if "openshift-gitops-operator" in csv["metadata"]["name"]: + # extract version string + return csv["spec"]["version"] + + +def get_submariner_operator_version(namespace=constants.SUBMARINER_OPERATOR_NAMESPACE): + """ + Get Submariner Operator Version + + Returns: + str: returns version string + + """ + # Importing here to avoid circular dependency + from ocs_ci.ocs.resources.csv import get_csvs_start_with_prefix + + csv_list = get_csvs_start_with_prefix("submariner", namespace=namespace) + for csv in csv_list: + if "submariner" in csv["metadata"]["name"]: + # extract version string + return csv["spec"]["version"] + + +def get_volsync_operator_version(namespace=constants.SUBMARINER_OPERATOR_NAMESPACE): + """ + Get VolSync Operator Version + + Returns: + str: returns version string + + """ + # Importing here to avoid circular dependency + from ocs_ci.ocs.resources.csv import get_csvs_start_with_prefix + + csv_list = get_csvs_start_with_prefix("volsync", namespace=namespace) + for csv in csv_list: + if "volsync" in csv["metadata"]["name"]: + # extract version string + return csv["spec"]["version"] diff --git a/tests/conftest.py b/tests/conftest.py index ce8cbf64a7d..6540b5ffca6 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -65,6 +65,7 @@ setup_ceph_toolbox, collect_ocs_logs, collect_pod_container_rpm_package, + is_dr_scenario, ) from ocs_ci.ocs.resources.deployment import Deployment from ocs_ci.ocs.resources.job import get_job_obj @@ -146,6 +147,8 @@ skipif_ui_not_support, run_cmd, ceph_health_check_multi_storagecluster_external, + get_oadp_version, + get_acm_version, ) from ocs_ci.helpers import helpers, dr_helpers from ocs_ci.helpers.helpers import ( @@ -171,6 +174,14 @@ ) from ocs_ci.ocs.longevity import start_app_workload from ocs_ci.utility.decorators import switch_to_default_cluster_index_at_last +from ocs_ci.utility.version import ( + get_dr_hub_operator_version, + get_ocp_dr_cluster_operator_version, + get_odf_multicluster_orchestrator_version, + get_ocp_gitops_operator_version, + get_submariner_operator_version, + get_volsync_operator_version, +) log = logging.getLogger(__name__) @@ -1592,6 +1603,49 @@ def additional_testsuite_properties(record_testsuite_property, pytestconfig): # add markers as separated property markers = ocsci_config.RUN["cli_params"].get("-m", "").replace(" ", "-") record_testsuite_property("rp_markers", markers) + if is_dr_scenario(): + with ocsci_config.RunWithAcmConfigContext(): + acm_operator_version = get_acm_version() + if acm_operator_version: + record_testsuite_property("rp_acm_version", acm_operator_version) + ocp_dr_hub_operator_version = get_dr_hub_operator_version() + if ocp_dr_hub_operator_version: + record_testsuite_property( + "rp_dr_hub_version", ocp_dr_hub_operator_version + ) + odf_multicluster_orchestrator_version = ( + get_odf_multicluster_orchestrator_version() + ) + if odf_multicluster_orchestrator_version: + record_testsuite_property( + "rp_odf_multicluster_orchestrator_version", + odf_multicluster_orchestrator_version, + ) + gitops_operator_version = get_ocp_gitops_operator_version() + if gitops_operator_version: + record_testsuite_property("rp_gitops_version", gitops_operator_version) + with ocsci_config.RunWithPrimaryConfigContext(): + oadp_operator_version = get_oadp_version() + if oadp_operator_version: + record_testsuite_property("rp_oadp_version", oadp_operator_version) + ocp_dr_cluster_operator_version = get_ocp_dr_cluster_operator_version() + if ocp_dr_cluster_operator_version: + record_testsuite_property( + "rp_ocp_dr_cluster_version", ocp_dr_cluster_operator_version + ) + gitops_operator_version = get_ocp_gitops_operator_version() + if gitops_operator_version: + record_testsuite_property("rp_gitops_version", gitops_operator_version) + volsync_operator_version = get_volsync_operator_version() + if volsync_operator_version: + record_testsuite_property( + "rp_volsync_version", volsync_operator_version + ) + submariner_operator_version = get_submariner_operator_version() + if submariner_operator_version: + record_testsuite_property( + "rp_submariner_version", submariner_operator_version + ) @pytest.fixture(scope="session") From 2e6778142620dc048e3994a664255f0b73f2d1c1 Mon Sep 17 00:00:00 2001 From: oviner Date: Wed, 24 Jul 2024 00:14:35 +0300 Subject: [PATCH 2/7] get_dr_operator_versions function Signed-off-by: oviner --- ocs_ci/ocs/resources/ocs.py | 52 ++++------------------------ ocs_ci/ocs/utils.py | 67 +++++++++++++++++++++++++++++++++++-- tests/conftest.py | 59 +++----------------------------- 3 files changed, 76 insertions(+), 102 deletions(-) diff --git a/ocs_ci/ocs/resources/ocs.py b/ocs_ci/ocs/resources/ocs.py index ef60fb26caf..168e5592eac 100644 --- a/ocs_ci/ocs/resources/ocs.py +++ b/ocs_ci/ocs/resources/ocs.py @@ -17,15 +17,7 @@ from ocs_ci.ocs.exceptions import CSVNotFound from ocs_ci.utility import templating, utils from ocs_ci.utility.version import get_semantic_ocs_version_from_config, VERSION_4_9 -from ocs_ci.utility.version import ( - get_dr_hub_operator_version, - get_ocp_dr_cluster_operator_version, - get_odf_multicluster_orchestrator_version, - get_ocp_gitops_operator_version, - get_submariner_operator_version, - get_volsync_operator_version, -) -from ocs_ci.utility.utils import get_oadp_version, get_acm_version + log = logging.getLogger(__name__) @@ -213,43 +205,11 @@ def get_version_info(namespace=None): csv_name = package_manifest.get_current_csv(channel) csv_pre = CSV(resource_name=csv_name, namespace=namespace) info = get_images(csv_pre.get()) - from ocs_ci.ocs.utils import is_dr_scenario - - if is_dr_scenario(): - with config.RunWithAcmConfigContext(): - acm_operator_version = get_acm_version() - if acm_operator_version: - info["acm_version"] = acm_operator_version - ocp_dr_hub_operator_version = get_dr_hub_operator_version() - if ocp_dr_hub_operator_version: - info["dr_hub_version"] = ocp_dr_hub_operator_version - odf_multicluster_orchestrator_version = ( - get_odf_multicluster_orchestrator_version() - ) - if odf_multicluster_orchestrator_version: - info[ - "odf_multicluster_orchestrator_version" - ] = odf_multicluster_orchestrator_version - gitops_operator_version = get_ocp_gitops_operator_version() - if gitops_operator_version: - info["gitops_version"] = gitops_operator_version - with config.RunWithPrimaryConfigContext(): - oadp_operator_version = get_oadp_version() - if oadp_operator_version: - info["oadp_version"] = oadp_operator_version - ocp_dr_cluster_operator_version = get_ocp_dr_cluster_operator_version() - if ocp_dr_cluster_operator_version: - info["ocp_dr_cluster_version"] = ocp_dr_cluster_operator_version - gitops_operator_version = get_ocp_gitops_operator_version() - if gitops_operator_version: - info["gitops_version"] = gitops_operator_version - volsync_operator_version = get_volsync_operator_version() - if volsync_operator_version: - info["volsync_version"] = volsync_operator_version - submariner_operator_version = get_submariner_operator_version() - if submariner_operator_version: - info["submariner_version"] = submariner_operator_version - return info + from ocs_ci.ocs.utils import get_dr_operator_versions + + dr_operator_versions = get_dr_operator_versions() + versions = {**info, **dr_operator_versions} + return versions def get_ocs_csv(): diff --git a/ocs_ci/ocs/utils.py b/ocs_ci/ocs/utils.py index 8ae455ae545..c8ff18022ed 100644 --- a/ocs_ci/ocs/utils.py +++ b/ocs_ci/ocs/utils.py @@ -31,7 +31,21 @@ from ocs_ci.utility import templating, version from ocs_ci.utility.prometheus import PrometheusAPI from ocs_ci.utility.retry import retry -from ocs_ci.utility.utils import create_directory_path, mirror_image, run_cmd +from ocs_ci.utility.utils import ( + create_directory_path, + mirror_image, + run_cmd, + get_oadp_version, + get_acm_version, +) +from ocs_ci.utility.version import ( + get_dr_hub_operator_version, + get_ocp_dr_cluster_operator_version, + get_odf_multicluster_orchestrator_version, + get_ocp_gitops_operator_version, + get_submariner_operator_version, + get_volsync_operator_version, +) log = logging.getLogger(__name__) @@ -1691,4 +1705,53 @@ def is_dr_scenario(): bool: return True if it is rdr or mdr setup otherwise False """ - return ocsci_config.MULTICLUSTER["multicluster_mode"] in ("metro-dr", "regional-dr") + return ocsci_config.MULTICLUSTER.get("multicluster_mode") in ( + "metro-dr", + "regional-dr", + ) + + +def get_dr_operator_versions(): + """ + Get all DR operator versions on hub and primary clusters + + Returns: + dict: return operator name as key and version as value + + """ + versions_dic = dict() + if is_dr_scenario(): + with ocsci_config.RunWithAcmConfigContext(): + acm_operator_version = get_acm_version() + if acm_operator_version: + versions_dic["acm_version"] = acm_operator_version + ocp_dr_hub_operator_version = get_dr_hub_operator_version() + if ocp_dr_hub_operator_version: + versions_dic["dr_hub_version"] = ocp_dr_hub_operator_version + odf_multicluster_orchestrator_version = ( + get_odf_multicluster_orchestrator_version() + ) + if odf_multicluster_orchestrator_version: + versions_dic[ + "odf_multicluster_orchestrator_version" + ] = odf_multicluster_orchestrator_version + gitops_operator_version = get_ocp_gitops_operator_version() + if gitops_operator_version: + versions_dic["gitops_version"] = gitops_operator_version + with ocsci_config.RunWithPrimaryConfigContext(): + oadp_operator_version = get_oadp_version() + if oadp_operator_version: + versions_dic["oadp_version"] = oadp_operator_version + ocp_dr_cluster_operator_version = get_ocp_dr_cluster_operator_version() + if ocp_dr_cluster_operator_version: + versions_dic["ocp_dr_cluster_version"] = ocp_dr_cluster_operator_version + gitops_operator_version = get_ocp_gitops_operator_version() + if gitops_operator_version: + versions_dic["gitops_version"] = gitops_operator_version + volsync_operator_version = get_volsync_operator_version() + if volsync_operator_version: + versions_dic["volsync_version"] = volsync_operator_version + submariner_operator_version = get_submariner_operator_version() + if submariner_operator_version: + versions_dic["submariner_version"] = submariner_operator_version + return versions_dic diff --git a/tests/conftest.py b/tests/conftest.py index 6540b5ffca6..fc60f2ecd2d 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -65,7 +65,7 @@ setup_ceph_toolbox, collect_ocs_logs, collect_pod_container_rpm_package, - is_dr_scenario, + get_dr_operator_versions, ) from ocs_ci.ocs.resources.deployment import Deployment from ocs_ci.ocs.resources.job import get_job_obj @@ -147,8 +147,6 @@ skipif_ui_not_support, run_cmd, ceph_health_check_multi_storagecluster_external, - get_oadp_version, - get_acm_version, ) from ocs_ci.helpers import helpers, dr_helpers from ocs_ci.helpers.helpers import ( @@ -174,14 +172,7 @@ ) from ocs_ci.ocs.longevity import start_app_workload from ocs_ci.utility.decorators import switch_to_default_cluster_index_at_last -from ocs_ci.utility.version import ( - get_dr_hub_operator_version, - get_ocp_dr_cluster_operator_version, - get_odf_multicluster_orchestrator_version, - get_ocp_gitops_operator_version, - get_submariner_operator_version, - get_volsync_operator_version, -) + log = logging.getLogger(__name__) @@ -1603,49 +1594,9 @@ def additional_testsuite_properties(record_testsuite_property, pytestconfig): # add markers as separated property markers = ocsci_config.RUN["cli_params"].get("-m", "").replace(" ", "-") record_testsuite_property("rp_markers", markers) - if is_dr_scenario(): - with ocsci_config.RunWithAcmConfigContext(): - acm_operator_version = get_acm_version() - if acm_operator_version: - record_testsuite_property("rp_acm_version", acm_operator_version) - ocp_dr_hub_operator_version = get_dr_hub_operator_version() - if ocp_dr_hub_operator_version: - record_testsuite_property( - "rp_dr_hub_version", ocp_dr_hub_operator_version - ) - odf_multicluster_orchestrator_version = ( - get_odf_multicluster_orchestrator_version() - ) - if odf_multicluster_orchestrator_version: - record_testsuite_property( - "rp_odf_multicluster_orchestrator_version", - odf_multicluster_orchestrator_version, - ) - gitops_operator_version = get_ocp_gitops_operator_version() - if gitops_operator_version: - record_testsuite_property("rp_gitops_version", gitops_operator_version) - with ocsci_config.RunWithPrimaryConfigContext(): - oadp_operator_version = get_oadp_version() - if oadp_operator_version: - record_testsuite_property("rp_oadp_version", oadp_operator_version) - ocp_dr_cluster_operator_version = get_ocp_dr_cluster_operator_version() - if ocp_dr_cluster_operator_version: - record_testsuite_property( - "rp_ocp_dr_cluster_version", ocp_dr_cluster_operator_version - ) - gitops_operator_version = get_ocp_gitops_operator_version() - if gitops_operator_version: - record_testsuite_property("rp_gitops_version", gitops_operator_version) - volsync_operator_version = get_volsync_operator_version() - if volsync_operator_version: - record_testsuite_property( - "rp_volsync_version", volsync_operator_version - ) - submariner_operator_version = get_submariner_operator_version() - if submariner_operator_version: - record_testsuite_property( - "rp_submariner_version", submariner_operator_version - ) + dr_operator_versions = get_dr_operator_versions() + for dr_operator_name, dr_operator_version in dr_operator_versions.items(): + record_testsuite_property(f"rp_{dr_operator_name}", dr_operator_version) @pytest.fixture(scope="session") From 01363675884f155686836c4a372561cf9a59052b Mon Sep 17 00:00:00 2001 From: oviner Date: Wed, 24 Jul 2024 17:13:38 +0300 Subject: [PATCH 3/7] fix code Signed-off-by: oviner --- ocs_ci/ocs/resources/ocs.py | 10 ++++++++++ ocs_ci/ocs/utils.py | 5 +---- ocs_ci/utility/version.py | 2 +- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/ocs_ci/ocs/resources/ocs.py b/ocs_ci/ocs/resources/ocs.py index 168e5592eac..dcade8a8565 100644 --- a/ocs_ci/ocs/resources/ocs.py +++ b/ocs_ci/ocs/resources/ocs.py @@ -194,6 +194,16 @@ def __setstate__(self, d): def get_version_info(namespace=None): + """ + Get OCS versions and DR operator versions + + Args: + namespace (str): the CSVs namespace + + Returns: + dict: the ocs versions and DR operator versions + + """ operator_selector = get_selector_for_ocs_operator() subscription_plan_approval = config.DEPLOYMENT.get("subscription_plan_approval") package_manifest = PackageManifest( diff --git a/ocs_ci/ocs/utils.py b/ocs_ci/ocs/utils.py index c8ff18022ed..93099a96ea4 100644 --- a/ocs_ci/ocs/utils.py +++ b/ocs_ci/ocs/utils.py @@ -1735,16 +1735,13 @@ def get_dr_operator_versions(): versions_dic[ "odf_multicluster_orchestrator_version" ] = odf_multicluster_orchestrator_version - gitops_operator_version = get_ocp_gitops_operator_version() - if gitops_operator_version: - versions_dic["gitops_version"] = gitops_operator_version with ocsci_config.RunWithPrimaryConfigContext(): oadp_operator_version = get_oadp_version() if oadp_operator_version: versions_dic["oadp_version"] = oadp_operator_version ocp_dr_cluster_operator_version = get_ocp_dr_cluster_operator_version() if ocp_dr_cluster_operator_version: - versions_dic["ocp_dr_cluster_version"] = ocp_dr_cluster_operator_version + versions_dic["dr_cluster_version"] = ocp_dr_cluster_operator_version gitops_operator_version = get_ocp_gitops_operator_version() if gitops_operator_version: versions_dic["gitops_version"] = gitops_operator_version diff --git a/ocs_ci/utility/version.py b/ocs_ci/utility/version.py index d48f783a02d..ab916ac2dda 100644 --- a/ocs_ci/utility/version.py +++ b/ocs_ci/utility/version.py @@ -252,7 +252,7 @@ def get_ocp_gitops_operator_version(namespace=constants.OPENSHIFT_NAMESPACE): "openshift-gitops-operator", namespace=namespace ) for csv in csv_list: - if "openshift-gitops-operator" in csv["metadata"]["name"]: + if constants.GITOPS_OPERATOR_NAME in csv["metadata"]["name"]: # extract version string return csv["spec"]["version"] From 5971b48e175b8c0f29a172cd2b63d0c18323ed86 Mon Sep 17 00:00:00 2001 From: oviner Date: Wed, 24 Jul 2024 17:16:17 +0300 Subject: [PATCH 4/7] fix code Signed-off-by: oviner --- ocs_ci/ocs/resources/ocs.py | 1 + 1 file changed, 1 insertion(+) diff --git a/ocs_ci/ocs/resources/ocs.py b/ocs_ci/ocs/resources/ocs.py index dcade8a8565..faaaf4ca177 100644 --- a/ocs_ci/ocs/resources/ocs.py +++ b/ocs_ci/ocs/resources/ocs.py @@ -215,6 +215,7 @@ def get_version_info(namespace=None): csv_name = package_manifest.get_current_csv(channel) csv_pre = CSV(resource_name=csv_name, namespace=namespace) info = get_images(csv_pre.get()) + # Importing here to avoid circular dependency from ocs_ci.ocs.utils import get_dr_operator_versions dr_operator_versions = get_dr_operator_versions() From 8c0d955ad0a8f13db42d0de32c73bdeb84217aca Mon Sep 17 00:00:00 2001 From: oviner Date: Wed, 24 Jul 2024 17:21:41 +0300 Subject: [PATCH 5/7] fix code Signed-off-by: oviner --- ocs_ci/ocs/resources/ocs.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ocs_ci/ocs/resources/ocs.py b/ocs_ci/ocs/resources/ocs.py index faaaf4ca177..d98b342595c 100644 --- a/ocs_ci/ocs/resources/ocs.py +++ b/ocs_ci/ocs/resources/ocs.py @@ -204,6 +204,9 @@ def get_version_info(namespace=None): dict: the ocs versions and DR operator versions """ + # Importing here to avoid circular dependency + from ocs_ci.ocs.utils import get_dr_operator_versions + operator_selector = get_selector_for_ocs_operator() subscription_plan_approval = config.DEPLOYMENT.get("subscription_plan_approval") package_manifest = PackageManifest( @@ -215,9 +218,6 @@ def get_version_info(namespace=None): csv_name = package_manifest.get_current_csv(channel) csv_pre = CSV(resource_name=csv_name, namespace=namespace) info = get_images(csv_pre.get()) - # Importing here to avoid circular dependency - from ocs_ci.ocs.utils import get_dr_operator_versions - dr_operator_versions = get_dr_operator_versions() versions = {**info, **dr_operator_versions} return versions From 152e6f29321fd3f5987ae7cd7cb36d839c420d84 Mon Sep 17 00:00:00 2001 From: oviner Date: Wed, 24 Jul 2024 17:24:11 +0300 Subject: [PATCH 6/7] fix code Signed-off-by: oviner --- ocs_ci/utility/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ocs_ci/utility/version.py b/ocs_ci/utility/version.py index ab916ac2dda..aee79f7aefb 100644 --- a/ocs_ci/utility/version.py +++ b/ocs_ci/utility/version.py @@ -249,7 +249,7 @@ def get_ocp_gitops_operator_version(namespace=constants.OPENSHIFT_NAMESPACE): from ocs_ci.ocs.resources.csv import get_csvs_start_with_prefix csv_list = get_csvs_start_with_prefix( - "openshift-gitops-operator", namespace=namespace + constants.GITOPS_OPERATOR_NAME, namespace=namespace ) for csv in csv_list: if constants.GITOPS_OPERATOR_NAME in csv["metadata"]["name"]: From 529f32a55b434800f42a869492a12d5a94dc2be8 Mon Sep 17 00:00:00 2001 From: oviner Date: Wed, 24 Jul 2024 17:30:25 +0300 Subject: [PATCH 7/7] fix code Signed-off-by: oviner --- ocs_ci/ocs/utils.py | 4 ++-- ocs_ci/utility/version.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ocs_ci/ocs/utils.py b/ocs_ci/ocs/utils.py index 93099a96ea4..ea30c7147ca 100644 --- a/ocs_ci/ocs/utils.py +++ b/ocs_ci/ocs/utils.py @@ -40,7 +40,7 @@ ) from ocs_ci.utility.version import ( get_dr_hub_operator_version, - get_ocp_dr_cluster_operator_version, + get_dr_cluster_operator_version, get_odf_multicluster_orchestrator_version, get_ocp_gitops_operator_version, get_submariner_operator_version, @@ -1739,7 +1739,7 @@ def get_dr_operator_versions(): oadp_operator_version = get_oadp_version() if oadp_operator_version: versions_dic["oadp_version"] = oadp_operator_version - ocp_dr_cluster_operator_version = get_ocp_dr_cluster_operator_version() + ocp_dr_cluster_operator_version = get_dr_cluster_operator_version() if ocp_dr_cluster_operator_version: versions_dic["dr_cluster_version"] = ocp_dr_cluster_operator_version gitops_operator_version = get_ocp_gitops_operator_version() diff --git a/ocs_ci/utility/version.py b/ocs_ci/utility/version.py index aee79f7aefb..98c8da04059 100644 --- a/ocs_ci/utility/version.py +++ b/ocs_ci/utility/version.py @@ -195,9 +195,9 @@ def get_dr_hub_operator_version(namespace=constants.OPENSHIFT_NAMESPACE): return csv["spec"]["version"] -def get_ocp_dr_cluster_operator_version(namespace=constants.OPENSHIFT_NAMESPACE): +def get_dr_cluster_operator_version(namespace=constants.OPENSHIFT_NAMESPACE): """ - Get DR Hub Operator Version + Get DR Cluster Operator Version Returns: str: returns version string