Skip to content

Commit

Permalink
fix the uninstall of rhoai operator
Browse files Browse the repository at this point in the history
Signed-off-by: Kobi Hakimi <khakimi@redhat.com>
  • Loading branch information
kobihk committed Jan 6, 2025
1 parent 0b7a4c2 commit 6f0cf73
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ Is RHODS Installed
IF "${INSTALL_TYPE}" == "Cli"
${result}= Run Keyword And Return Status
... Run Keywords
... Check A RHODS Family Operator Is Installed namespace=${OPERATOR_NAMESPACE}
... subscription=rhoai-operator-dev AND
... Check A RHODS Family Operator Is Installed 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
Expand All @@ -15,8 +14,7 @@ Is RHODS Installed
ELSE IF "${INSTALL_TYPE}" == "OperatorHub"
${result}= Run Keyword And Return Status
... Run Keywords
... Check A RHODS Family Operator Is Installed namespace=${OPERATOR_NAMESPACE}
... subscription=${OPERATOR_NAME} AND
... Check A RHODS Family Operator Is Installed 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}
Expand All @@ -34,8 +32,7 @@ Is RHODS Installed
END
${result}= Run Keyword And Return Status
... Run Keywords
... Check A RHODS Family Operator Is Installed namespace=${OPERATOR_NAMESPACE}
... subscription=${SUB_NAME} AND
... Check A RHODS Family Operator Is Installed 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
Expand All @@ -49,17 +46,40 @@ Is RHODS Installed
RETURN ${result}

Check A RHODS Family Operator Is Installed
[Documentation] Returns if an operator with given subscription name has a CSV in the given namespace
[Arguments] ${namespace} ${subscription}
Log Getting CSV from subscription ${subscription} namespace ${namespace} console=yes
${rc} ${current_csv_name} = Run And Return Rc And Output
... oc get subscription ${subscription} -n ${namespace} -ojson | jq '.status.currentCSV' | tr -d '"'
Log Got CSV ${current_csv_name} from subscription ${subscription}, result: ${rc} console=yes
IF "${rc}" == "0" and "${current_csv_name}" != "${EMPTY}"
${result} = Run Keyword And Return Status
... Oc Get kind=ClusterServiceVersion namespace=${namespace} name=${current_csv_name}
ELSE
${result} = Set Variable False
[Documentation] Returns if RHODS operator has a CSV
${result} = Set Variable False

Check warning

Code scanning / Robocop

The assignment sign is not consistent within the file. Expected '{{ expected_sign }}' but got '{{ actual_sign }}' instead Warning

The assignment sign is not consistent within the file. Expected '=' but got ' =' instead
Log Check if the RHODS operator installed. console=yes
${subscription}= Get RHODS Subscription Name
${namespace}= Get RHODS Namespace
IF "${subscription}" != "${EMPTY}"
Log Getting CSV from subscription ${subscription} namespace ${namespace} console=yes
${rc} ${current_csv_name} = Run And Return Rc And Output

Check warning

Code scanning / Robocop

The assignment sign is not consistent within the file. Expected '{{ expected_sign }}' but got '{{ actual_sign }}' instead Warning

The assignment sign is not consistent within the file. Expected '=' but got ' =' instead
... oc get subscription ${subscription} -n ${namespace} -ojson | jq '.status.currentCSV' | tr -d '"'
Log Got CSV '${current_csv_name}' from subscription '${subscription}', result: ${rc} console=yes
IF "${rc}" == "0" and "${current_csv_name}" != "${EMPTY}"
${rc}= Run Keyword And Return Status oc get csv ${current_csv_name} -n ${namespace}

Check warning

Code scanning / Robocop

Keyword name '{{ keyword_name }}' does not follow case convention Warning

Keyword name 'oc get csv ${current_csv_name} -n ${namespace}' does not follow case convention
${result}= Evaluate ${rc} == 0
Log The csv exists: ${result} console=yes
END
END
Log Operator with sub ${subscription} is installed result: ${result} console=yes
Log Operator with sub '${subscription}' is installed result: ${result} console=yes
IF not ${result} FAIL The operator with sub ${subscription} is not installed.

Get RHODS Subscription Name
[Documentation] Returns the subscription name of RHOAI/ODH operator
Log Get the RHODS subscription name by package name: '${RHODS_PACKAGE_NAME}' console=yes
${rc} ${out}= Run And Return RC And Output
... oc get sub -A -o json | jq --arg pkgName "${RHODS_PACKAGE_NAME}" -r '.items[] | select(.spec.name==$pkgName) | .metadata.name'

Check warning

Code scanning / Robocop

Line is too long ({{ line_length }}/{{ allowed_length }}) Warning

Line is too long (137/120)
Should Be Equal As Integers ${rc} 0
Log The RHODS Subscription Name is: '${out}' console=yes
RETURN ${out}

Get RHODS Namespace
[Documentation] Returns the namespace of RHOAI/ODH operator
Log Get the RHODS namespace by package name: '${RHODS_PACKAGE_NAME}' console=yes
${rc} ${out}= Run And Return RC And Output
... oc get sub -A -o json | jq --arg pkgName "${RHODS_PACKAGE_NAME}" -r '.items[] | select(.spec.name==$pkgName) | .metadata.namespace'

Check warning

Code scanning / Robocop

Line is too long ({{ line_length }}/{{ allowed_length }}) Warning

Line is too long (142/120)
Should Be Equal As Integers ${rc} 0
Log The RHODS Namespace is: '${out}' console=yes
RETURN ${out}
10 changes: 0 additions & 10 deletions ods_ci/tasks/Resources/RHODS_OLM/uninstall/oc_uninstall.robot
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,12 @@ Trigger RHODS Uninstall
Log Triggered RHODS uninstallation

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=${CATALOG_NAME}
ELSE IF "${cluster_type}" == "selfmanaged"
Run Keyword And Expect Error *Not Found*
... Oc Get kind=CatalogSource namespace=openshift-marketplace
... field_selector=metadata.name=rhoai-catalog-dev
END
Verify Project Does Not Exists ${MONITORING_NAMESPACE}
Verify Project Does Not Exists ${APPLICATIONS_NAMESPACE}
IF "${OPERATOR_NAMESPACE}" != "openshift-marketplace"
Verify Project Does Not Exists ${OPERATOR_NAMESPACE}
END


Verify Project Does Not Exists
[Arguments] ${project}
Log ${project}
Expand Down
3 changes: 3 additions & 0 deletions ods_ci/tasks/Tasks/rhods_olm.robot
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Documentation Perform and verify RHODS OLM tasks
Metadata RHODS OLM Version 1.0.0
Resource ../Resources/RHODS_OLM/RHODS_OLM.resource
Resource ../../tests/Resources/Common.robot
Resource ../../tests/Resources/RHOSi.resource
Library OpenShiftLibrary
Library OperatingSystem
Library String
Expand All @@ -22,6 +23,7 @@ ${CATALOG_SOURCE} redhat-operators
*** Tasks ***
Can Install RHODS Operator
[Tags] install
RHOSi Setup
IF "${PRODUCT}" == "ODH"
Set Global Variable ${OPERATOR_NAMESPACE} opendatahub-operators
Set Global Variable ${OPERATOR_NAME_LABEL} opendatahub-operator
Expand All @@ -43,6 +45,7 @@ Can Install RHODS Operator

Can Uninstall RHODS Operator
[Tags] uninstall
RHOSi Setup
IF "${PRODUCT}" == "ODH"
Set Global Variable ${OPERATOR_NAMESPACE} opendatahub-operators
IF "${UPDATE_CHANNEL}" == "odh-nightlies"
Expand Down
1 change: 1 addition & 0 deletions ods_ci/tests/Resources/RHOSi.resource
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ Initialize Global Variables
Set Global Variable ${RHODS_VERSION}
Set Prometheus Variables
Set Global Variable ${DASHBOARD_APP_NAME} ${PRODUCT.lower()}-dashboard
Set Global Variable ${RHODS_PACKAGE_NAME} rhods-operator

Check notice

Code scanning / Robocop

{{ set_variable_keyword }} can be replaced with VAR Note test

Set Global Variable can be replaced with VAR

Check warning

Code scanning / Robocop

Don't set global variables outside the variables section Warning test

Don't set global variables outside the variables section

Required Global Variables Should Exist
[Documentation] Fails if new required global variables are not set
Expand Down

0 comments on commit 6f0cf73

Please sign in to comment.