From c2a17e05bcc54ca858efed311b78aa7a41d8e9f6 Mon Sep 17 00:00:00 2001 From: tarukumar <93319437+tarukumar@users.noreply.github.com> Date: Mon, 6 May 2024 10:37:57 +0530 Subject: [PATCH] Add support to uninstall odh-nightly from managed cluster (#1421) Add support to uninstall odh-nightly from managed cluster --- .../pre-tasks/oc_is_operator_installed.robot | 12 ++++++++++-- .../RHODS_OLM/uninstall/oc_uninstall.robot | 7 +++++-- .../RHODS_OLM/uninstall/uninstall.robot | 18 +++++++++++++++--- 3 files changed, 30 insertions(+), 7 deletions(-) diff --git a/ods_ci/tasks/Resources/RHODS_OLM/pre-tasks/oc_is_operator_installed.robot b/ods_ci/tasks/Resources/RHODS_OLM/pre-tasks/oc_is_operator_installed.robot index 71bef3a12..989e4c6d5 100644 --- a/ods_ci/tasks/Resources/RHODS_OLM/pre-tasks/oc_is_operator_installed.robot +++ b/ods_ci/tasks/Resources/RHODS_OLM/pre-tasks/oc_is_operator_installed.robot @@ -24,15 +24,23 @@ Is RHODS Installed FAIL Provided test environment and install type combination is not supported END ELSE IF "${cluster_type}" == "managed" + Set Global Variable ${SUB_NAME} addon-managed-odh + Set Global Variable ${CATALOG_NAME} addon-managed-odh-catalog + #For managed cluster + IF "${UPDATE_CHANNEL}" == "odh-nightlies" + Set Global Variable ${OPERATOR_NAMESPACE} openshift-marketplace + Set Global Variable ${SUB_NAME} rhoai-operator-dev + Set Global Variable ${CATALOG_NAME} rhoai-catalog-dev + END ${result}= Run Keyword And Return Status ... Run Keywords ... Check A RHODS Family Operator Is Installed namespace=${OPERATOR_NAMESPACE} - ... subscription=addon-managed-odh AND + ... subscription=${SUB_NAME} AND ... Oc Get kind=Namespace field_selector=metadata.name=${MONITORING_NAMESPACE} AND ... Oc Get kind=Namespace field_selector=metadata.name=${APPLICATIONS_NAMESPACE} AND ... Oc Get kind=Namespace field_selector=metadata.name=${OPERATOR_NAMESPACE} AND ... Oc Get kind=CatalogSource namespace=${OPERATOR_NAMESPACE} - ... field_selector=metadata.name=addon-managed-odh-catalog + ... field_selector=metadata.name=${CATALOG_NAME} ELSE FAIL Provided test environment and install type ${INSTALL_TYPE} ${UPDATE_CHANNEL} ${cluster_type} combination ... is not supported diff --git a/ods_ci/tasks/Resources/RHODS_OLM/uninstall/oc_uninstall.robot b/ods_ci/tasks/Resources/RHODS_OLM/uninstall/oc_uninstall.robot index 198df4cfc..6404dcbb7 100644 --- a/ods_ci/tasks/Resources/RHODS_OLM/uninstall/oc_uninstall.robot +++ b/ods_ci/tasks/Resources/RHODS_OLM/uninstall/oc_uninstall.robot @@ -14,7 +14,7 @@ Verify RHODS Uninstallation IF "${cluster_type}" == "managed" Run Keyword And Expect Error *Not Found* ... Oc Get kind=CatalogSource namespace=${OPERATOR_NAMESPACE} - ... field_selector=metadata.name=addon-managed-odh-catalog + ... field_selector=metadata.name=${CATALOG_NAME} ELSE IF "${cluster_type}" == "selfmanaged" Run Keyword And Expect Error *Not Found* ... Oc Get kind=CatalogSource namespace=openshift-marketplace @@ -22,7 +22,10 @@ Verify RHODS Uninstallation END Verify Project Does Not Exists ${MONITORING_NAMESPACE} Verify Project Does Not Exists ${APPLICATIONS_NAMESPACE} - Verify Project Does Not Exists ${OPERATOR_NAMESPACE} + IF "${OPERATOR_NAMESPACE}" != "openshift-marketplace" + Verify Project Does Not Exists ${OPERATOR_NAMESPACE} + END + Verify Project Does Not Exists [Arguments] ${project} diff --git a/ods_ci/tasks/Resources/RHODS_OLM/uninstall/uninstall.robot b/ods_ci/tasks/Resources/RHODS_OLM/uninstall/uninstall.robot index 2e08c1bef..a36a934c8 100644 --- a/ods_ci/tasks/Resources/RHODS_OLM/uninstall/uninstall.robot +++ b/ods_ci/tasks/Resources/RHODS_OLM/uninstall/uninstall.robot @@ -64,13 +64,19 @@ Uninstall RHODS In Self Managed Cluster For Operatorhub Uninstall RHODS V2 [Documentation] Keyword to uninstall the version 2 of the RHODS operator in Self-Managed + Log To Console message=Deleting DSC CR From Cluster + ${return_code} ${output} Run And Return Rc And Output + ... oc get DataScienceCluster --all-namespaces -o custom-columns=:metadata.name --ignore-not-found | xargs -I {} oc patch DataScienceCluster {} --type=merge -p '{"metadata": {"finalizers":null}}' || true #robocop:disable ${return_code} ${output} Run And Return Rc And Output ... oc delete datasciencecluster --all --ignore-not-found Should Be Equal As Integers ${return_code} 0 msg=Error deleting DataScienceCluster CR + Log To Console message=Deleting DSCi CR From Cluster + ${return_code} ${output} Run And Return Rc And Output + ... oc get DSCInitialization --all-namespaces -o custom-columns=:metadata.name --ignore-not-found | xargs -I {} oc patch DSCInitialization {} --type=merge -p '{"metadata": {"finalizers":null}}' || true #robocop:disable ${return_code} ${output} Run And Return Rc And Output ... oc delete dscinitialization --all --ignore-not-found Should Be Equal As Integers ${return_code} 0 msg=Error deleting DSCInitialization CR - + Log To Console message=Deleting Operator Subscription From Cluster ${return_code} ${subscription_name} Run And Return Rc And Output ... oc get subscription -n ${OPERATOR_NAMESPACE} --no-headers | awk '{print $1}' IF "${return_code}" == "0" and "${subscription_name}" != "${EMPTY}" @@ -85,18 +91,24 @@ Uninstall RHODS V2 ... oc delete subscription ${subscription_name} -n ${OPERATOR_NAMESPACE} --ignore-not-found Should Be Equal As Integers ${return_code} 0 msg=Error deleting RHODS subscription END + Log To Console message=Deleting Operator CSV From Cluster ${return_code} ${output} Run And Return Rc And Output ... oc delete clusterserviceversion opendatahub-operator.1.18.0 -n openshift-operators --ignore-not-found + Log To Console message=Deleting Operator Catalog From Cluster ${return_code} ${output} Run And Return Rc And Output ... oc delete CatalogSource rhoai-catalog-dev -n openshift-marketplace --ignore-not-found # robocop: disable ${return_code} ${output} Run And Return Rc And Output ... oc delete CatalogSource addon-managed-odh-catalog -n openshift-marketplace --ignore-not-found # robocop: disable + Log To Console message=Deleting Operator Group From Cluster ${return_code} ${output} Run And Return Rc And Output ... oc delete operatorgroup --all -n ${OPERATOR_NAMESPACE} --ignore-not-found Should Be Equal As Integers ${return_code} 0 msg=Error deleting operatorgroup + Log To Console message=Deleting Operator and it's associate namepsace ${return_code} ${output} Run And Return Rc And Output oc delete ns -l opendatahub.io/generated-namespace --ignore-not-found Verify Project Does Not Exists ${APPLICATIONS_NAMESPACE} Verify Project Does Not Exists ${MONITORING_NAMESPACE} Verify Project Does Not Exists ${NOTEBOOKS_NAMESPACE} - ${return_code} ${output} Run And Return Rc And Output oc delete namespace ${OPERATOR_NAMESPACE} --ignore-not-found - Verify Project Does Not Exists ${OPERATOR_NAMESPACE} + IF "${OPERATOR_NAMESPACE}" != "openshift-marketplace" + ${return_code} ${output} Run And Return Rc And Output oc delete namespace ${OPERATOR_NAMESPACE} --ignore-not-found + Verify Project Does Not Exists ${OPERATOR_NAMESPACE} + END