Skip to content

Commit

Permalink
enhancement: add new logic to support custom namespaces for both oper…
Browse files Browse the repository at this point in the history
…ator and applications
  • Loading branch information
CFSNM committed Feb 6, 2025
1 parent b2a64e3 commit c07322b
Showing 1 changed file with 66 additions and 15 deletions.
81 changes: 66 additions & 15 deletions ods_ci/tasks/Resources/RHODS_OLM/install/oc_install.robot
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,29 @@ Install RHODS
[Arguments] ${cluster_type} ${image_url}
Install Kserve Dependencies
Clone OLM Install Repo
IF "${PRODUCT}" == "ODH"
${csv_display_name} = Set Variable ${ODH_CSV_DISPLAY}
IF "${OPERATOR_NAMESPACE}" != "redhat-ods-operator" and "${OPERATOR_NAMESPACE}" != "opendatahub-operators"
# If the operator namespace is not the default one, we need to check if exists
# and create if not prior to installing ODH/RHOAI
${result} ${out}= Run And Return Rc And Output oc get namespace ${OPERATOR_NAMESPACE}

Check notice

Code scanning / Robocop

Variable '{{ name }}' is assigned but not used Note

Variable '${result}' is assigned but not used

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

Check notice

Code scanning / Robocop

Variable '{{ name }}' is assigned but not used Note

Variable '${out}' is assigned but not used
IF "$out" == "Error from server (NotFound): namespaces \"${OPERATOR_NAMESPACE}\" not found"

Check warning

Code scanning / Robocop

{{ bad_indent_msg }} Warning

Line is over-indented
${create_ns_rc} = Run And Return Rc oc create namespace ${OPERATOR_NAMESPACE}
IF ${create_ns_rc} == 0

Check notice

Code scanning / Robocop

'{{ block_name }}' condition can be simplified Note

'IF' condition can be simplified
Log To Console Namespace ${OPERATOR_NAMESPACE} created successfully
ELSE
FAIL Can not create namespace ${OPERATOR_NAMESPACE}
END
END

Check warning

Code scanning / Robocop

{{ bad_indent_msg }} Warning

Line is over-indented
END
IF "${APPLICATIONS_NAMESPACE}" != "redhat-ods-applications" and "${APPLICATIONS_NAMESPACE}" != "opendatahub"
# If the applications namespace is not the default one, we need to apply some steps prior to installing ODH/RHOAI

Check warning

Code scanning / Robocop

{{ bad_indent_msg }} Warning

Line is under-indented
Configure Custom Applications Namespace ${APPLICATIONS_NAMESPACE}
END
IF "${PRODUCT}" == "ODH"
${csv_display_name} = Set Variable ${ODH_CSV_DISPLAY}
ELSE
${csv_display_name} = Set Variable ${RHODS_CSV_DISPLAY}
${csv_display_name} = Set Variable ${RHODS_CSV_DISPLAY}
END
IF "${cluster_type}" == "selfmanaged"
IF "${cluster_type}" == "selfmanaged"
IF "${TEST_ENV}" in "${SUPPORTED_TEST_ENV}" and "${INSTALL_TYPE}" == "Cli"
Install RHODS In Self Managed Cluster Using CLI ${cluster_type} ${image_url}
ELSE IF "${TEST_ENV}" in "${SUPPORTED_TEST_ENV}" and "${INSTALL_TYPE}" == "OperatorHub"
Expand All @@ -62,7 +79,7 @@ Install RHODS
ELSE
FAIL Provided test environment and install type is not supported
END
ELSE IF "${cluster_type}" == "managed"
ELSE IF "${cluster_type}" == "managed"
IF "${TEST_ENV}" in "${SUPPORTED_TEST_ENV}" and "${INSTALL_TYPE}" == "Cli" and "${UPDATE_CHANNEL}" == "odh-nightlies"
# odh-nightly is not build for Managed, it is only possible for Self-Managed
Set Global Variable ${OPERATOR_NAMESPACE} openshift-marketplace
Expand All @@ -85,19 +102,31 @@ Verify RHODS Installation
Wait For Pods Status namespace=${OPERATOR_NAMESPACE} timeout=1200
Log Verified ${OPERATOR_NAMESPACE} console=yes

IF "${UPDATE_CHANNEL}" == "odh-nightlies" or "${cluster_type}" != "managed"
IF "${PRODUCT}" == "ODH"
Apply DSCInitialization CustomResource dsci_name=${DSCI_NAME}
IF "${TEST_ENV.lower()}" == "crc"
${timeout_in_seconds} = Set Variable 180
ELSE
${timeout_in_seconds} = Set Variable 60
IF "${APPLICATIONS_NAMESPACE}" != "redhat-ods-applications" and "${APPLICATIONS_NAMESPACE}" != "opendatahub"
# If the applications namespace is not the default one, we need to add a new workflow where we need to wait for
# the DSCI to be created, delete it and recreate it using the proper applications namespace.
# This is needed because by default, the DSCI is automatically created pointing to the default apps namespace.
Wait For DSCInitialization CustomResource To Be Ready timeout=180
${delete_dsci_rc} = Run And Return Rc oc delete DSCInitialization --all --ignore-not-found
IF ${delete_dsci_rc} == 0

Check notice

Code scanning / Robocop

'{{ block_name }}' condition can be simplified Note

'IF' condition can be simplified
Log To Console DSCInitialization CRs successfully deleted
ELSE
FAIL Cannot delete DSCInitialization CRs
END
Apply DSCInitialization CustomResource dsci_name=${DSCI_NAME}
Wait For DSCInitialization CustomResource To Be Ready timeout=180
ELSE
# If the applications namespace is the default one, we keep the same workflow as it was
IF "${UPDATE_CHANNEL}" == "odh-nightlies" or "${cluster_type}" != "managed"
IF "${PRODUCT}" == "ODH"
Apply DSCInitialization CustomResource dsci_name=${DSCI_NAME}
Wait For DSCInitialization CustomResource To Be Ready timeout=180
END
Wait For DSCInitialization CustomResource To Be Ready timeout=${timeout_in_seconds}
END
Apply DataScienceCluster CustomResource dsc_name=${DSC_NAME}
END
END

Apply DataScienceCluster CustomResource dsc_name=${DSC_NAME}

${dashboard} = Is Component Enabled dashboard ${DSC_NAME}
IF "${dashboard}" == "true"
Wait For Deployment Replica To Be Ready namespace=${APPLICATIONS_NAMESPACE}
Expand Down Expand Up @@ -517,6 +546,28 @@ Install Kserve Dependencies
Log To Console message=Serverless Operator is already installed
END

Configure Custom Applications Namespace
[Documentation] Configures a custom namespace to be able to be used as the ODH/RHOAI applications namespace.
... If this namespace does not exist, its created.
[Arguments] ${namespace}
${result} ${out}= Run And Return Rc And Output oc get namespace ${namespace}

Check notice

Code scanning / Robocop

Variable '{{ name }}' is assigned but not used Note

Variable '${result}' is assigned but not used

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

Check notice

Code scanning / Robocop

Variable '{{ name }}' is assigned but not used Note

Variable '${out}' is assigned but not used
IF "$out" == "Error from server (NotFound): namespaces \"$namespace\" not found"
${create_ns_rc} = Run And Return Rc oc create namespace ${namespace}
IF ${create_ns_rc} == 0
Log To Console Namespace ${namespace} created successfully
ELSE
FAIL Can not create namespace ${namespace}
END
END

# Next step, add the label opendatahub.io/application-namespace: true to the namespace
${add_label_rc} = Run And Return Rc oc label namespace ${namespace} opendatahub.io/application-namespace=true
IF ${add_label_rc} == 0
Log To Console Label added to namespace ${namespace} successfully
ELSE
FAIL Can not add label to namespace ${namespace}
END

Set Component State
[Documentation] Set component state in Data Science Cluster (state should be Managed or Removed)
[Arguments] ${component} ${state}
Expand Down

0 comments on commit c07322b

Please sign in to comment.