From db5d0f7a96cc6adcd7f4be5a42a50ae2c1c6d942 Mon Sep 17 00:00:00 2001 From: oviner Date: Mon, 10 Jun 2024 12:34:35 +0300 Subject: [PATCH 01/12] Multus Upgarde 4.15->4.16 - dropping holder design Signed-off-by: oviner --- ocs_ci/framework/conf/default_config.yaml | 1 + ocs_ci/helpers/helpers.py | 194 ++++++++++++++++++++++ ocs_ci/ocs/constants.py | 1 + ocs_ci/ocs/ocs_upgrade.py | 3 + 4 files changed, 199 insertions(+) diff --git a/ocs_ci/framework/conf/default_config.yaml b/ocs_ci/framework/conf/default_config.yaml index ac91575c07c..330b98fe556 100644 --- a/ocs_ci/framework/conf/default_config.yaml +++ b/ocs_ci/framework/conf/default_config.yaml @@ -268,6 +268,7 @@ ENV_DATA: multus_cluster_net_range: "192.168.30.0/24" multus_cluster_net_type: "macvlan" multus_cluster_net_mode: "bridge" + multus_destination_route: "192.168.252.0/24" #RDR Green field rdr_osd_deployment_mode: "greenfield" diff --git a/ocs_ci/helpers/helpers.py b/ocs_ci/helpers/helpers.py index 7d138b15a8a..0c108ecc6cc 100644 --- a/ocs_ci/helpers/helpers.py +++ b/ocs_ci/helpers/helpers.py @@ -4776,3 +4776,197 @@ def is_rbd_default_storage_class(custom_sc=None): logger.error("Storageclass {default_rbd_sc} is not a default RBD StorageClass.") return False + + +def get_network_attachment_definitions( + nad_name, namespace=config.ENV_DATA["cluster_namespace"] +): + """ + Get network_attachment_definitions obj + Args: + nad_name (str) : network_attachment_definition name + namespace (str): Namespace of the resource + Returns: + network_attachment_definitions (obj) : network_attachment_definitions object + """ + return OCP( + kind=constants.NETWORK_ATTACHEMENT_DEFINITION, + namespace=namespace, + resource_name=nad_name, + ) + + +def add_route_public_nad(): + """ + Add route section to network_attachment_definitions object + + """ + nad_obj = get_network_attachment_definitions( + nad_name=config.ENV_DATA.get("multus_public_net_name"), + namespace=config.ENV_DATA.get("multus_public_net_namespace"), + ) + nad_config_str = nad_obj.data["spec"]["config"] + nad_config_dict = json.loads(nad_config_str) + nad_config_dict["ipam"]["routes"] = [ + {"dst": config.ENV_DATA["multus_destination_route"]} + ] + nad_config_dict_string = json.dumps(nad_config_dict) + logger.info("Creating Multus public network") + public_net_data = templating.load_yaml(constants.MULTUS_PUBLIC_NET_YAML) + public_net_data["metadata"]["name"] = config.ENV_DATA.get("multus_public_net_name") + public_net_data["metadata"]["namespace"] = config.ENV_DATA.get( + "multus_public_net_namespace" + ) + public_net_data["spec"]["config"] = nad_config_dict_string + public_net_yaml = tempfile.NamedTemporaryFile( + mode="w+", prefix="multus_public", delete=False + ) + templating.dump_data_to_temp_yaml(public_net_data, public_net_yaml.name) + run_cmd(f"oc apply -f {public_net_yaml.name}") + + # nad_obj = OCP( + # kind=constants.NETWORK_ATTACHEMENT_DEFINITION, + # namespace="default", + # resource_name="public-net", + # ) + # params = f'{{"spec": {{"config": "a"}}}}' + # nad_obj.patch(params=params, format_type="merge") + # nad_obj = get_network_attachment_definitions(nad_name=nad_name, namespace=namespace) + # nad_config_str = nad_obj.data["spec"]["config"] + # nad_config_dict = json.loads(nad_config_str) + # nad_config_dict["ipam"]["routes"] = [{"dst": config.ENV_DATA["multus_destination_route"]}] + # nad_config_dict_string = json.dumps(nad_config_dict) + # params = f"""[{{ "op": "replace", "path": "/spec/config", + # "value": {str(nad_config_dict_string)}}}]""" + # nad_obj.patch( + # resource_name=nad_name, + # params=params.strip("\n"), + # format_type="json", + # ) + + +def reset_all_osd_pods(): + from ocs_ci.ocs.resources.pod import get_osd_pods + + osd_pod_objs = get_osd_pods() + for osd_pod_obj in osd_pod_objs: + osd_pod_obj.delete() + + +def enable_csi_disable_holder_pods(): + """ + + Returns: + + """ + configmap_obj = OCP( + kind=constants.CONFIGMAP, + namespace=config.ENV_DATA["cluster_namespace"], + resource_name=constants.ROOK_OPERATOR_CONFIGMAP, + ) + value = "true" + params = f'{{"data": {{"CSI_DISABLE_HOLDER_PODS": "{value}"}}}}' + configmap_obj.patch(params=params, format_type="merge") + + +def delete_csi_holder_pods(): + from ocs_ci.ocs.utils import get_pod_name_by_pattern + from ocs_ci.ocs.node import drain_nodes, schedule_nodes + + pods_csi_cephfsplugin = get_pod_name_by_pattern("csi-rbdplugin") + worker_pods_dict = dict() + from ocs_ci.ocs.resources.pod import get_pod_obj + + for pod_name in pods_csi_cephfsplugin: + pod_obj = get_pod_obj( + name=pod_name, namespace=config.ENV_DATA["cluster_namespace"] + ) + if pod_obj.pod_data["spec"]["nodeName"] in worker_pods_dict: + worker_pods_dict[pod_obj.pod_data["spec"]["nodeName"]].append(pod_obj) + else: + worker_pods_dict[pod_obj.pod_data["spec"]["nodeName"]] = [pod_obj] + + for worker_node_name, csi_pod_objs in worker_pods_dict.items(): + drain_nodes([worker_node_name]) + for csi_pod_obj in csi_pod_objs: + csi_pod_obj.delete() + schedule_nodes([worker_node_name]) + + +def configure_node_network_configuration_policy_on_all_worker_nodes(): + from ocs_ci.ocs.node import get_worker_nodes + + logger.info("Configure NodeNetworkConfigurationPolicy on all worker nodes") + worker_node_names = get_worker_nodes() + for worker_node_name in worker_node_names: + worker_network_configuration = config.ENV_DATA["baremetal"]["servers"][ + worker_node_name + ] + node_network_configuration_policy = templating.load_yaml( + constants.NODE_NETWORK_CONFIGURATION_POLICY + ) + node_network_configuration_policy["spec"]["nodeSelector"][ + "kubernetes.io/hostname" + ] = worker_node_name + node_network_configuration_policy["metadata"][ + "name" + ] = worker_network_configuration["node_network_configuration_policy_name"] + node_network_configuration_policy["spec"]["desiredState"]["interfaces"][0][ + "ipv4" + ]["address"][0]["ip"] = worker_network_configuration[ + "node_network_configuration_policy_ip" + ] + node_network_configuration_policy["spec"]["desiredState"]["interfaces"][0][ + "ipv4" + ]["address"][0]["prefix-length"] = worker_network_configuration[ + "node_network_configuration_policy_prefix_length" + ] + node_network_configuration_policy["spec"]["desiredState"]["routes"]["config"][ + 0 + ]["destination"] = worker_network_configuration[ + "node_network_configuration_policy_destination_route" + ] + public_net_yaml = tempfile.NamedTemporaryFile( + mode="w+", prefix="multus_public", delete=False + ) + templating.dump_data_to_temp_yaml( + node_network_configuration_policy, public_net_yaml.name + ) + run_cmd(f"oc create -f {public_net_yaml.name}") + + +def get_daemonsets_names(namespace=config.ENV_DATA["cluster_namespace"]): + daemonset_names = list() + daemonset_objs = OCP( + kind=constants.DAEMONSET, + namespace=namespace, + ) + for daemonset_obj in daemonset_objs.data.get("items"): + daemonset_names.append(daemonset_obj["metadata"]["name"]) + return daemonset_names + + +def get_daemonsets_obj(name, namespace=config.ENV_DATA["cluster_namespace"]): + return OCP(kind=constants.DAEMONSET, namespace=namespace, resource_name=name) + + +def delete_csi_holder_daemonsets(): + daemonset_names = get_daemonsets_names() + for daemonset_name in daemonset_names: + if "holder" in daemonset_name: + daemonsets_obj = get_daemonsets_obj(daemonset_name) + daemonsets_obj.delete() + + +def upgrade_multus_holder_design(): + add_route_public_nad() + from ocs_ci.deployment.nmstate import NMStateInstaller + + logger.info("Install NMState operator and create an instance") + nmstate_obj = NMStateInstaller() + nmstate_obj.running_nmstate() + configure_node_network_configuration_policy_on_all_worker_nodes() + reset_all_osd_pods() + enable_csi_disable_holder_pods() + delete_csi_holder_pods() + delete_csi_holder_daemonsets() diff --git a/ocs_ci/ocs/constants.py b/ocs_ci/ocs/constants.py index 806f0c97ff8..66a387d168f 100644 --- a/ocs_ci/ocs/constants.py +++ b/ocs_ci/ocs/constants.py @@ -154,6 +154,7 @@ POD = "Pod" ROUTE = "Route" SERVICE = "Service" +DAEMONSET = "DaemonSet" CEPHOBJECTSTORE = "cephobjectstore" NODE = "Node" DEPLOYMENTCONFIG = "deploymentconfig" diff --git a/ocs_ci/ocs/ocs_upgrade.py b/ocs_ci/ocs/ocs_upgrade.py index c795a6944c7..98c648b6df1 100644 --- a/ocs_ci/ocs/ocs_upgrade.py +++ b/ocs_ci/ocs/ocs_upgrade.py @@ -782,7 +782,10 @@ def run_ocs_upgrade( # in pending state is_all_csvs_succeeded = check_all_csvs_are_succeeded(namespace=namespace) assert is_all_csvs_succeeded, "Not all CSV's are in succeeded state" + if config.ENV_DATA.get("is_multus_enabled"): + from ocs_ci.helpers.helpers import upgrade_multus_holder_design + upgrade_multus_holder_design() ocs_install_verification( timeout=600, skip_osd_distribution_check=True, From 89b2d7989e23231438daf3b0f9ad873b345e5d15 Mon Sep 17 00:00:00 2001 From: oviner Date: Sat, 15 Jun 2024 13:29:42 +0300 Subject: [PATCH 02/12] fix code Signed-off-by: oviner --- ocs_ci/deployment/deployment.py | 53 ++++++-------------------------- ocs_ci/helpers/helpers.py | 54 ++++++++++++++++++++++++++++----- 2 files changed, 56 insertions(+), 51 deletions(-) diff --git a/ocs_ci/deployment/deployment.py b/ocs_ci/deployment/deployment.py index 7d61bfcf6c4..dde07f7a2cf 100644 --- a/ocs_ci/deployment/deployment.py +++ b/ocs_ci/deployment/deployment.py @@ -1012,50 +1012,17 @@ def deploy_ocs_via_operator(self, image=None): # Create Multus Networks if config.ENV_DATA.get("is_multus_enabled"): - from ocs_ci.deployment.nmstate import NMStateInstaller - - logger.info("Install NMState operator and create an instance") - nmstate_obj = NMStateInstaller() - nmstate_obj.running_nmstate() - logger.info("Configure NodeNetworkConfigurationPolicy on all worker nodes") - worker_node_names = get_worker_nodes() - for worker_node_name in worker_node_names: - worker_network_configuration = config.ENV_DATA["baremetal"]["servers"][ - worker_node_name - ] - node_network_configuration_policy = templating.load_yaml( - constants.NODE_NETWORK_CONFIGURATION_POLICY - ) - node_network_configuration_policy["spec"]["nodeSelector"][ - "kubernetes.io/hostname" - ] = worker_node_name - node_network_configuration_policy["metadata"][ - "name" - ] = worker_network_configuration[ - "node_network_configuration_policy_name" - ] - node_network_configuration_policy["spec"]["desiredState"]["interfaces"][ - 0 - ]["ipv4"]["address"][0]["ip"] = worker_network_configuration[ - "node_network_configuration_policy_ip" - ] - node_network_configuration_policy["spec"]["desiredState"]["interfaces"][ - 0 - ]["ipv4"]["address"][0]["prefix-length"] = worker_network_configuration[ - "node_network_configuration_policy_prefix_length" - ] - node_network_configuration_policy["spec"]["desiredState"]["routes"][ - "config" - ][0]["destination"] = worker_network_configuration[ - "node_network_configuration_policy_destination_route" - ] - public_net_yaml = tempfile.NamedTemporaryFile( - mode="w+", prefix="multus_public", delete=False - ) - templating.dump_data_to_temp_yaml( - node_network_configuration_policy, public_net_yaml.name + if config.ENV_DATA.get("multus_create_public_net"): + from ocs_ci.deployment.nmstate import NMStateInstaller + + logger.info("Install NMState operator and create an instance") + nmstate_obj = NMStateInstaller() + nmstate_obj.running_nmstate() + from ocs_ci.helpers.helpers import ( + configure_node_network_configuration_policy_on_all_worker_nodes, ) - run_cmd(f"oc create -f {public_net_yaml.name}") + + configure_node_network_configuration_policy_on_all_worker_nodes() create_public_net = config.ENV_DATA["multus_create_public_net"] create_cluster_net = config.ENV_DATA["multus_create_cluster_net"] diff --git a/ocs_ci/helpers/helpers.py b/ocs_ci/helpers/helpers.py index 0c108ecc6cc..7ef2513865a 100644 --- a/ocs_ci/helpers/helpers.py +++ b/ocs_ci/helpers/helpers.py @@ -4782,12 +4782,14 @@ def get_network_attachment_definitions( nad_name, namespace=config.ENV_DATA["cluster_namespace"] ): """ - Get network_attachment_definitions obj + Get NetworkAttachmentDefinition obj + Args: nad_name (str) : network_attachment_definition name namespace (str): Namespace of the resource Returns: network_attachment_definitions (obj) : network_attachment_definitions object + """ return OCP( kind=constants.NETWORK_ATTACHEMENT_DEFINITION, @@ -4846,6 +4848,10 @@ def add_route_public_nad(): def reset_all_osd_pods(): + """ + Reset all osd pods + + """ from ocs_ci.ocs.resources.pod import get_osd_pods osd_pod_objs = get_osd_pods() @@ -4870,6 +4876,11 @@ def enable_csi_disable_holder_pods(): def delete_csi_holder_pods(): + """ + + Returns: + + """ from ocs_ci.ocs.utils import get_pod_name_by_pattern from ocs_ci.ocs.node import drain_nodes, schedule_nodes @@ -4894,6 +4905,10 @@ def delete_csi_holder_pods(): def configure_node_network_configuration_policy_on_all_worker_nodes(): + """ + Configure NodeNetworkConfigurationPolicy CR on each worker node in cluster + + """ from ocs_ci.ocs.node import get_worker_nodes logger.info("Configure NodeNetworkConfigurationPolicy on all worker nodes") @@ -4936,6 +4951,15 @@ def configure_node_network_configuration_policy_on_all_worker_nodes(): def get_daemonsets_names(namespace=config.ENV_DATA["cluster_namespace"]): + """ + Get all daemonspaces in namespace + + Args: + namespace: + + Returns: + + """ daemonset_names = list() daemonset_objs = OCP( kind=constants.DAEMONSET, @@ -4947,10 +4971,23 @@ def get_daemonsets_names(namespace=config.ENV_DATA["cluster_namespace"]): def get_daemonsets_obj(name, namespace=config.ENV_DATA["cluster_namespace"]): + """ + Get daemonset obj + Args: + name: + namespace: + + Returns: + + """ return OCP(kind=constants.DAEMONSET, namespace=namespace, resource_name=name) def delete_csi_holder_daemonsets(): + """ + Delete csi holder daemonsets + + """ daemonset_names = get_daemonsets_names() for daemonset_name in daemonset_names: if "holder" in daemonset_name: @@ -4959,13 +4996,14 @@ def delete_csi_holder_daemonsets(): def upgrade_multus_holder_design(): - add_route_public_nad() - from ocs_ci.deployment.nmstate import NMStateInstaller - - logger.info("Install NMState operator and create an instance") - nmstate_obj = NMStateInstaller() - nmstate_obj.running_nmstate() - configure_node_network_configuration_policy_on_all_worker_nodes() + if config.ENV_DATA.get("multus_create_public_net"): + add_route_public_nad() + from ocs_ci.deployment.nmstate import NMStateInstaller + + logger.info("Install NMState operator and create an instance") + nmstate_obj = NMStateInstaller() + nmstate_obj.running_nmstate() + configure_node_network_configuration_policy_on_all_worker_nodes() reset_all_osd_pods() enable_csi_disable_holder_pods() delete_csi_holder_pods() From 27c0abe98cc37f728e80a4a9c63a479122645d77 Mon Sep 17 00:00:00 2001 From: oviner Date: Wed, 19 Jun 2024 19:08:09 +0300 Subject: [PATCH 03/12] fix code Signed-off-by: oviner --- ocs_ci/helpers/helpers.py | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/ocs_ci/helpers/helpers.py b/ocs_ci/helpers/helpers.py index 7ef2513865a..a263f05536e 100644 --- a/ocs_ci/helpers/helpers.py +++ b/ocs_ci/helpers/helpers.py @@ -4884,11 +4884,13 @@ def delete_csi_holder_pods(): from ocs_ci.ocs.utils import get_pod_name_by_pattern from ocs_ci.ocs.node import drain_nodes, schedule_nodes - pods_csi_cephfsplugin = get_pod_name_by_pattern("csi-rbdplugin") + pods_csi_cephfsplugin_holder = get_pod_name_by_pattern("csi-cephfsplugin-holder") + pods_csi_rbdplugin_holder = get_pod_name_by_pattern("csi-rbdplugin-holder") + pods_csi_holder = pods_csi_cephfsplugin_holder + pods_csi_rbdplugin_holder worker_pods_dict = dict() from ocs_ci.ocs.resources.pod import get_pod_obj - for pod_name in pods_csi_cephfsplugin: + for pod_name in pods_csi_holder: pod_obj = get_pod_obj( name=pod_name, namespace=config.ENV_DATA["cluster_namespace"] ) @@ -4898,6 +4900,7 @@ def delete_csi_holder_pods(): worker_pods_dict[pod_obj.pod_data["spec"]["nodeName"]] = [pod_obj] for worker_node_name, csi_pod_objs in worker_pods_dict.items(): + run_cmd(f"oc adm cordon {worker_node_name}") drain_nodes([worker_node_name]) for csi_pod_obj in csi_pod_objs: csi_pod_obj.delete() @@ -4992,7 +4995,21 @@ def delete_csi_holder_daemonsets(): for daemonset_name in daemonset_names: if "holder" in daemonset_name: daemonsets_obj = get_daemonsets_obj(daemonset_name) - daemonsets_obj.delete() + daemonsets_obj.delete(resource_name=daemonset_name) + + +def verify_csi_holder_pods_do_not_exist(): + """ + + Returns: + + """ + from ocs_ci.ocs.utils import get_pod_name_by_pattern + + if len(get_pod_name_by_pattern("holder")) > 0: + raise AssertionError( + "The csi holder pod exist even though we deleted the daemonset" + ) def upgrade_multus_holder_design(): @@ -5008,3 +5025,4 @@ def upgrade_multus_holder_design(): enable_csi_disable_holder_pods() delete_csi_holder_pods() delete_csi_holder_daemonsets() + verify_csi_holder_pods_do_not_exist() From 0eb9e697235e5e94159929f61d5f31a9743658f0 Mon Sep 17 00:00:00 2001 From: oviner Date: Thu, 20 Jun 2024 13:52:33 +0300 Subject: [PATCH 04/12] fix docsting Signed-off-by: oviner --- ocs_ci/helpers/helpers.py | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/ocs_ci/helpers/helpers.py b/ocs_ci/helpers/helpers.py index a263f05536e..a005e20bf9c 100644 --- a/ocs_ci/helpers/helpers.py +++ b/ocs_ci/helpers/helpers.py @@ -4861,8 +4861,7 @@ def reset_all_osd_pods(): def enable_csi_disable_holder_pods(): """ - - Returns: + Enable CSI_DISABLE_HOLDER_PODS in rook-ceph-operator-config config-map """ configmap_obj = OCP( @@ -4878,7 +4877,14 @@ def enable_csi_disable_holder_pods(): def delete_csi_holder_pods(): """ - Returns: + Drain/schedule worker nodes and reset csi-holder-pods + + Procedure: + 1.Cordon worker node-X + 2.Drain worker node-X + 3.Reset csi-cephfsplugin-holder and csi-rbdplugin-holder pods on node-X + 4.schedule node-X + 5.Verify all node-X in Ready state """ from ocs_ci.ocs.utils import get_pod_name_by_pattern @@ -4958,9 +4964,10 @@ def get_daemonsets_names(namespace=config.ENV_DATA["cluster_namespace"]): Get all daemonspaces in namespace Args: - namespace: + namespace (str): namespace Returns: + list: all daemonset names in the namespace """ daemonset_names = list() @@ -4977,10 +4984,11 @@ def get_daemonsets_obj(name, namespace=config.ENV_DATA["cluster_namespace"]): """ Get daemonset obj Args: - name: - namespace: + name (str): the name of daemeonset + namespace (str): the namespace of daemonset Returns: + ocp_obj: daemonset ocp obj """ return OCP(kind=constants.DAEMONSET, namespace=namespace, resource_name=name) @@ -5000,8 +5008,10 @@ def delete_csi_holder_daemonsets(): def verify_csi_holder_pods_do_not_exist(): """ + Verify csi-holder pods do not exist Returns: + AssertionError: if csi-holder pod exist raise Exception """ from ocs_ci.ocs.utils import get_pod_name_by_pattern @@ -5013,6 +5023,10 @@ def verify_csi_holder_pods_do_not_exist(): def upgrade_multus_holder_design(): + """ + Upgrade multus holder design from ODF4.15 to ODF4.16 + + """ if config.ENV_DATA.get("multus_create_public_net"): add_route_public_nad() from ocs_ci.deployment.nmstate import NMStateInstaller From a8a30acd7e733f30fb589df47ff0d7c749238e6f Mon Sep 17 00:00:00 2001 From: oviner Date: Thu, 20 Jun 2024 13:59:38 +0300 Subject: [PATCH 05/12] fix Signed-off-by: oviner --- ocs_ci/helpers/helpers.py | 2 +- ocs_ci/ocs/ocs_upgrade.py | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ocs_ci/helpers/helpers.py b/ocs_ci/helpers/helpers.py index a005e20bf9c..56ea77584d5 100644 --- a/ocs_ci/helpers/helpers.py +++ b/ocs_ci/helpers/helpers.py @@ -4785,7 +4785,7 @@ def get_network_attachment_definitions( Get NetworkAttachmentDefinition obj Args: - nad_name (str) : network_attachment_definition name + nad_name (str): network_attachment_definition name namespace (str): Namespace of the resource Returns: network_attachment_definitions (obj) : network_attachment_definitions object diff --git a/ocs_ci/ocs/ocs_upgrade.py b/ocs_ci/ocs/ocs_upgrade.py index 98c648b6df1..7341aab1c64 100644 --- a/ocs_ci/ocs/ocs_upgrade.py +++ b/ocs_ci/ocs/ocs_upgrade.py @@ -786,6 +786,13 @@ def run_ocs_upgrade( from ocs_ci.helpers.helpers import upgrade_multus_holder_design upgrade_multus_holder_design() + ocs_install_verification( + timeout=600, + skip_osd_distribution_check=True, + ocs_registry_image=upgrade_ocs.ocs_registry_image, + post_upgrade_verification=False, + version_before_upgrade=upgrade_ocs.version_before_upgrade, + ) ocs_install_verification( timeout=600, skip_osd_distribution_check=True, From c517a618e014de2e45d232c47d9c9f1f4b19d120 Mon Sep 17 00:00:00 2001 From: oviner Date: Sun, 23 Jun 2024 17:10:55 +0300 Subject: [PATCH 06/12] fix code Signed-off-by: oviner --- ocs_ci/deployment/deployment.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ocs_ci/deployment/deployment.py b/ocs_ci/deployment/deployment.py index dde07f7a2cf..a142e9b8acc 100644 --- a/ocs_ci/deployment/deployment.py +++ b/ocs_ci/deployment/deployment.py @@ -1012,7 +1012,11 @@ def deploy_ocs_via_operator(self, image=None): # Create Multus Networks if config.ENV_DATA.get("is_multus_enabled"): - if config.ENV_DATA.get("multus_create_public_net"): + ocs_version = version.get_semantic_ocs_version_from_config() + if ( + config.ENV_DATA.get("multus_create_public_net") + and ocs_version >= version.VERSION_4_16 + ): from ocs_ci.deployment.nmstate import NMStateInstaller logger.info("Install NMState operator and create an instance") From 9fc20aebf408c22ffb7d9fe9d19341f45fa7f21f Mon Sep 17 00:00:00 2001 From: oviner Date: Wed, 3 Jul 2024 10:05:52 +0300 Subject: [PATCH 07/12] fix code Signed-off-by: oviner --- ocs_ci/helpers/helpers.py | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/ocs_ci/helpers/helpers.py b/ocs_ci/helpers/helpers.py index 56ea77584d5..651f47dc4fc 100644 --- a/ocs_ci/helpers/helpers.py +++ b/ocs_ci/helpers/helpers.py @@ -5006,19 +5006,41 @@ def delete_csi_holder_daemonsets(): daemonsets_obj.delete(resource_name=daemonset_name) -def verify_csi_holder_pods_do_not_exist(): +def verify_pod_pattern_does_not_exist(pattern, namespace): """ Verify csi-holder pods do not exist + Args: + pattern (str): the pattern of pod + namespace (str): the namespace of pod + Returns: - AssertionError: if csi-holder pod exist raise Exception + bool: if pod with pattern exist return False otherwise return True """ from ocs_ci.ocs.utils import get_pod_name_by_pattern - if len(get_pod_name_by_pattern("holder")) > 0: - raise AssertionError( - "The csi holder pod exist even though we deleted the daemonset" + return len(get_pod_name_by_pattern(pattern=pattern, namespace=namespace)) == 0 + + +def verify_csi_holder_pods_do_not_exist(): + """ + Verify csi holder pods do not exist + + Returns: + TimeoutExpiredError: if csi-holder pod exist raise Exception + + """ + sample = TimeoutSampler( + timeout=300, + sleep=10, + func=verify_pod_pattern_does_not_exist, + pattern="holder", + namespace=config.ENV_DATA["cluster_namespace"], + ) + if not sample.wait_for_func_status(result=True): + raise TimeoutExpiredError( + "The csi holder pod exist even though we deleted the daemonset after 300 seconds" ) From 18164dc0d99fc3c14c41ced91b46692d27da41c1 Mon Sep 17 00:00:00 2001 From: oviner Date: Wed, 3 Jul 2024 17:03:24 +0300 Subject: [PATCH 08/12] fix code Signed-off-by: oviner --- ocs_ci/helpers/helpers.py | 20 -------------------- ocs_ci/ocs/ocs_upgrade.py | 8 +------- 2 files changed, 1 insertion(+), 27 deletions(-) diff --git a/ocs_ci/helpers/helpers.py b/ocs_ci/helpers/helpers.py index 651f47dc4fc..74b31f6a32a 100644 --- a/ocs_ci/helpers/helpers.py +++ b/ocs_ci/helpers/helpers.py @@ -4826,26 +4826,6 @@ def add_route_public_nad(): templating.dump_data_to_temp_yaml(public_net_data, public_net_yaml.name) run_cmd(f"oc apply -f {public_net_yaml.name}") - # nad_obj = OCP( - # kind=constants.NETWORK_ATTACHEMENT_DEFINITION, - # namespace="default", - # resource_name="public-net", - # ) - # params = f'{{"spec": {{"config": "a"}}}}' - # nad_obj.patch(params=params, format_type="merge") - # nad_obj = get_network_attachment_definitions(nad_name=nad_name, namespace=namespace) - # nad_config_str = nad_obj.data["spec"]["config"] - # nad_config_dict = json.loads(nad_config_str) - # nad_config_dict["ipam"]["routes"] = [{"dst": config.ENV_DATA["multus_destination_route"]}] - # nad_config_dict_string = json.dumps(nad_config_dict) - # params = f"""[{{ "op": "replace", "path": "/spec/config", - # "value": {str(nad_config_dict_string)}}}]""" - # nad_obj.patch( - # resource_name=nad_name, - # params=params.strip("\n"), - # format_type="json", - # ) - def reset_all_osd_pods(): """ diff --git a/ocs_ci/ocs/ocs_upgrade.py b/ocs_ci/ocs/ocs_upgrade.py index 7341aab1c64..aafe19e9c8d 100644 --- a/ocs_ci/ocs/ocs_upgrade.py +++ b/ocs_ci/ocs/ocs_upgrade.py @@ -786,13 +786,7 @@ def run_ocs_upgrade( from ocs_ci.helpers.helpers import upgrade_multus_holder_design upgrade_multus_holder_design() - ocs_install_verification( - timeout=600, - skip_osd_distribution_check=True, - ocs_registry_image=upgrade_ocs.ocs_registry_image, - post_upgrade_verification=False, - version_before_upgrade=upgrade_ocs.version_before_upgrade, - ) + ocs_install_verification( timeout=600, skip_osd_distribution_check=True, From 4cf03200f6f1cdead32c1906085c1743cc8990d9 Mon Sep 17 00:00:00 2001 From: oviner Date: Sun, 7 Jul 2024 17:15:54 +0300 Subject: [PATCH 09/12] fix code Signed-off-by: oviner --- ocs_ci/helpers/helpers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ocs_ci/helpers/helpers.py b/ocs_ci/helpers/helpers.py index 74b31f6a32a..132e7216207 100644 --- a/ocs_ci/helpers/helpers.py +++ b/ocs_ci/helpers/helpers.py @@ -5007,7 +5007,7 @@ def verify_csi_holder_pods_do_not_exist(): """ Verify csi holder pods do not exist - Returns: + Raises: TimeoutExpiredError: if csi-holder pod exist raise Exception """ From 74dd454325e37774d128312b9c4caacff7b90489 Mon Sep 17 00:00:00 2001 From: oviner Date: Mon, 8 Jul 2024 10:41:35 +0300 Subject: [PATCH 10/12] added conf file Signed-off-by: oviner --- conf/ocsci/multus_delete_csi_holder_pods.yaml | 4 ++++ ocs_ci/framework/conf/default_config.yaml | 1 + ocs_ci/helpers/helpers.py | 3 +++ 3 files changed, 8 insertions(+) create mode 100644 conf/ocsci/multus_delete_csi_holder_pods.yaml diff --git a/conf/ocsci/multus_delete_csi_holder_pods.yaml b/conf/ocsci/multus_delete_csi_holder_pods.yaml new file mode 100644 index 00000000000..c34b0192007 --- /dev/null +++ b/conf/ocsci/multus_delete_csi_holder_pods.yaml @@ -0,0 +1,4 @@ +--- +# This configuration file is used for delete csi holder pods on ODF cluster with multus post upgrade +ENV_DATA: + multus_delete_csi_holder_pods: True diff --git a/ocs_ci/framework/conf/default_config.yaml b/ocs_ci/framework/conf/default_config.yaml index 330b98fe556..d5d65b62426 100644 --- a/ocs_ci/framework/conf/default_config.yaml +++ b/ocs_ci/framework/conf/default_config.yaml @@ -269,6 +269,7 @@ ENV_DATA: multus_cluster_net_type: "macvlan" multus_cluster_net_mode: "bridge" multus_destination_route: "192.168.252.0/24" + multus_delete_csi_holder_pods: False #RDR Green field rdr_osd_deployment_mode: "greenfield" diff --git a/ocs_ci/helpers/helpers.py b/ocs_ci/helpers/helpers.py index 132e7216207..e5e2ad08467 100644 --- a/ocs_ci/helpers/helpers.py +++ b/ocs_ci/helpers/helpers.py @@ -4900,6 +4900,7 @@ def configure_node_network_configuration_policy_on_all_worker_nodes(): """ from ocs_ci.ocs.node import get_worker_nodes + # This function require changes for compact mode logger.info("Configure NodeNetworkConfigurationPolicy on all worker nodes") worker_node_names = get_worker_nodes() for worker_node_name in worker_node_names: @@ -5029,6 +5030,8 @@ def upgrade_multus_holder_design(): Upgrade multus holder design from ODF4.15 to ODF4.16 """ + if config.ENV_DATA.get("multus_delete_csi_holder_pods"): + return if config.ENV_DATA.get("multus_create_public_net"): add_route_public_nad() from ocs_ci.deployment.nmstate import NMStateInstaller From 500590815cae0c8bb21d65f3bfd3519c99ceb0e1 Mon Sep 17 00:00:00 2001 From: oviner Date: Mon, 8 Jul 2024 10:53:02 +0300 Subject: [PATCH 11/12] fix code Signed-off-by: oviner --- ocs_ci/ocs/ocs_upgrade.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ocs_ci/ocs/ocs_upgrade.py b/ocs_ci/ocs/ocs_upgrade.py index aafe19e9c8d..ae875b16749 100644 --- a/ocs_ci/ocs/ocs_upgrade.py +++ b/ocs_ci/ocs/ocs_upgrade.py @@ -782,7 +782,10 @@ def run_ocs_upgrade( # in pending state is_all_csvs_succeeded = check_all_csvs_are_succeeded(namespace=namespace) assert is_all_csvs_succeeded, "Not all CSV's are in succeeded state" - if config.ENV_DATA.get("is_multus_enabled"): + if ( + config.ENV_DATA.get("is_multus_enabled") + and upgrade_version == version.VERSION_4_16 + ): from ocs_ci.helpers.helpers import upgrade_multus_holder_design upgrade_multus_holder_design() From 0abfcbfa6eb1449f90da8cd63a8a8997ba5b0fda Mon Sep 17 00:00:00 2001 From: oviner Date: Tue, 9 Jul 2024 17:10:54 +0300 Subject: [PATCH 12/12] fix code Signed-off-by: oviner --- ocs_ci/helpers/helpers.py | 2 +- ocs_ci/ocs/ocs_upgrade.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/ocs_ci/helpers/helpers.py b/ocs_ci/helpers/helpers.py index e5e2ad08467..63f23e77b9e 100644 --- a/ocs_ci/helpers/helpers.py +++ b/ocs_ci/helpers/helpers.py @@ -5030,7 +5030,7 @@ def upgrade_multus_holder_design(): Upgrade multus holder design from ODF4.15 to ODF4.16 """ - if config.ENV_DATA.get("multus_delete_csi_holder_pods"): + if not config.ENV_DATA.get("multus_delete_csi_holder_pods"): return if config.ENV_DATA.get("multus_create_public_net"): add_route_public_nad() diff --git a/ocs_ci/ocs/ocs_upgrade.py b/ocs_ci/ocs/ocs_upgrade.py index ae875b16749..805fe176428 100644 --- a/ocs_ci/ocs/ocs_upgrade.py +++ b/ocs_ci/ocs/ocs_upgrade.py @@ -782,6 +782,7 @@ def run_ocs_upgrade( # in pending state is_all_csvs_succeeded = check_all_csvs_are_succeeded(namespace=namespace) assert is_all_csvs_succeeded, "Not all CSV's are in succeeded state" + upgrade_version = version.get_semantic_version(upgrade_version, True) if ( config.ENV_DATA.get("is_multus_enabled") and upgrade_version == version.VERSION_4_16