Skip to content

Commit

Permalink
[patch] UDS/DRO migration storage class fix (#849)
Browse files Browse the repository at this point in the history
Co-authored-by: Yuvraj Vansure <yuvraj.vansure1.ibm.com>
Co-authored-by: Lokesh <[email protected]>
Co-authored-by: lokesh-sreedhara <[email protected]>
Co-authored-by: Sanjay Prabhakar <[email protected]>
Co-authored-by: André Marcelino <[email protected]>
  • Loading branch information
5 people authored Apr 8, 2024
1 parent 7aba468 commit 7cbcc81
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 48 deletions.
1 change: 0 additions & 1 deletion image/cli/mascli/functions/mirror_images
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ Content Selection (Cloud Pak for Data):
Content Selection (Other Dependencies):
--mirror-cfs Mirror images for IBM Cloud Pak Foundation Services
--mirror-uds Mirror images for IBM User Data Services
--mirror-dro Mirror images for IBM Data Reporter Operator
--mirror-sls Mirror images for IBM Suite License Service
--mirror-tsm Mirror images for IBM Truststore Manager
--mirror-mongo Mirror images for MongoDb Community Edition
Expand Down
100 changes: 58 additions & 42 deletions image/cli/mascli/functions/update
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Update Dependencies (Optional):
--kafka-namespace ${COLOR_YELLOW}KAFKA_NAMESPACE${TEXT_RESET} Namespace where Kafka operator and instance will be updated
--kafka-provider ${COLOR_YELLOW}KAFKA_PROVIDER${TEXT_RESET} Set Kafka provider. Supported options are 'redhat' (Red Hat AMQ Streams), or 'strimzi'
--dro-migration ${COLOR_YELLOW}DRO_MIGRATION${TEXT_RESET} Confirm the removal of UDS and replacement with DRO as part of the update
--dro-storage-class ${COLOR_YELLOW}DRO_STORAGE_CLASS${TEXT_RESET} Set Custom RWO Storage Class name for DRO as part of the update
Other Commands:
--no-confirm Launch the update without prompting for confirmation
-h, --help Show this help message
Expand Down Expand Up @@ -123,57 +123,52 @@ function validate_existing_mongo() {
# Validate UDS to DRO Migration
# -----------------------------------------------------------------------------

function validate_dro_migration(){
function validate_dro_migration() {
# warn about DRO migration if UDS is running and MAS catalog is January 2024 or newer
MAS_CATALOG_DATE=${MAS_CATALOG_VERSION:3:6}

if [[ $MAS_CATALOG_DATE -ge 240227 ]]; then
echo -e "${COLOR_YELLOW}Verifing UDS status."
# If Jan catalog is detected, set DRO_MIGRATION Flag to True
UDS_NAMESPACE="ibm-common-services"
UDS_CSV=`oc get csv -n "${UDS_NAMESPACE}" | grep user-data-services | awk '{print $1}'`

if [[ -n $UDS_CSV ]]; then
UDS_STATUS=`oc get csv -n "${UDS_NAMESPACE}" "${UDS_CSV}" -o jsonpath='{.status.phase}'`

if [[ $UDS_STATUS = *'Succeeded'* ]]; then
echo -e "${COLOR_YELLOW}UDS is currently running in namespace ${UDS_NAMESPACE}."
echo -e "UDS will be uninstalled and MAS will migrate to use DRO (Data Reporter Operator). All compatible bascfg configuration will be updated and configured to use DRO ${COLOR_RESET}"
echo

if [[ "$NO_CONFIRM" != "true" ]]; then
prompt_for_confirm_default_yes "Do you want to proceed with uninstalling UDS and migrate to DRO?" DRO_MIGRATION
fi
if [[ "$NO_CONFIRM" != "true" ]] && [[ -z "${DRO_MIGRATION}" ]]; then
prompt_for_confirm_default_yes "Do you want to proceed with uninstalling UDS and migrate to DRO?" DRO_MIGRATION
fi
if [[ "$DRO_MIGRATION" == "true" ]]; then
echo -e "${COLOR_YELLOW}Verifing UDS status."
# If Jan catalog is detected, set DRO_MIGRATION Flag to True
UDS_NAMESPACE="ibm-common-services"
UDS_CSV=$(oc get csv -n "${UDS_NAMESPACE}" | grep user-data-services | awk '{print $1}')
if [[ -n $UDS_CSV ]]; then
UDS_STATUS=$(oc get csv -n "${UDS_NAMESPACE}" "${UDS_CSV}" -o jsonpath='{.status.phase}')
if [[ $UDS_STATUS = *'Succeeded'* ]]; then
echo -e "${COLOR_YELLOW}UDS is currently running in namespace ${UDS_NAMESPACE}."
echo -e "UDS will be uninstalled and MAS will migrate to use DRO (Data Reporter Operator). All compatible bascfg configuration will be updated and configured to use DRO ${COLOR_RESET}"
echo
if [[ "$NO_CONFIRM" != "true" ]] && [[ -z "${DRO_STORAGE_CLASS}" ]]; then
prompt_for_input "Enter the name of a RWO Storage Class to configure DRO, leave it blank if you want the CLI to autodetect a storage class:" DRO_STORAGE_CLASS
else
DRO_STORAGE_CLASS=""
fi

if [[ "$DRO_MIGRATION" == "true" ]]; then
## Check all avaliable Suite Instances versions , if any of them is 8.9.x cancel the dro migration. Exit mas update throw error.
for suite_namespace in $(oc get Suite --all-namespaces --ignore-not-found -o jsonpath='{.items[*].metadata.namespace}')
do
suite_name=`oc get Suite -n ${suite_namespace} -o NAME`
suite_version=`oc get ${suite_name} -n ${suite_namespace} -o jsonpath='{.status.versions.reconciled}'`
for suite_namespace in $(oc get Suite --all-namespaces --ignore-not-found -o jsonpath='{.items[*].metadata.namespace}'); do
suite_name=$(oc get Suite -n ${suite_namespace} -o NAME)
suite_version=$(oc get ${suite_name} -n ${suite_namespace} -o jsonpath='{.status.versions.reconciled}')

if [[ $suite_version = 9.* ]] || [[ $suite_version = 8.11.* ]] || [[ $suite_version = 8.10.* ]]
then
if [[ $suite_version = 9.* ]] || [[ $suite_version = 8.11.* ]] || [[ $suite_version = 8.10.* ]]; then

## Check if the BASCFG url has a local UDS on all instances, if not then exit and throw error
bascfg_name=`oc get BasCfg -n ${suite_namespace} -o NAME`
bas_url=`oc get ${bascfg_name} -n ${suite_namespace} -o jsonpath='{.spec.config.url}'`
uds_url=`oc get route uds-endpoint -n ibm-common-services -o jsonpath='{.spec.host}'`
bascfg_name=$(oc get BasCfg -n ${suite_namespace} -o NAME)
bas_url=$(oc get ${bascfg_name} -n ${suite_namespace} -o jsonpath='{.spec.config.url}')
uds_url=$(oc get route uds-endpoint -n ibm-common-services -o jsonpath='{.spec.host}')

if [[ -z ${uds_url} ]]
then
if [[ -z ${uds_url} ]]; then
echo -e "${COLOR_RED}UDS route is empty, Please fix your UDS installation to proceed with DRO migration, exiting mas update"
exit 1
fi

if [[ ${bas_url} == *${uds_url}* ]]
then
if [[ ${bas_url} == *${uds_url}* ]]; then
echo -e "${COLOR_YELLOW}UDS Configuration on ${suite_namespace} with MAS version ${suite_version} is compatible for DRO migration"

elif [[ ${bas_url} == *ibm-data-reporter* ]]
then
elif [[ ${bas_url} == *ibm-data-reporter* ]]; then
echo -e "${COLOR_YELLOW}${suite_namespace} is already configured with DRO"

else
echo -e "${COLOR_RED}${suite_namespace} appears to use a Remote UDS that is not running locally on this cluster. This setup is not compatible for DRO migration, exiting mas update"
exit 1
Expand All @@ -185,23 +180,35 @@ function validate_dro_migration(){
echo
done
else
echo -e "${COLOR_RED}You must accept the migration from UDS to DRO to continue with the update to ${MAS_CATALOG_VERSION}"
echo -e "${COLOR_RED}UDS is in Error state. Please fix your UDS installation to proceed with DRO migration, exiting mas update"
exit 1
fi
else
echo -e "${COLOR_RED}UDS is in Error state. Please fix your UDS installation to proceed with DRO migration, exiting mas update"
exit 1
DRO_MIGRATION="false"
echo -e "${COLOR_YELLOW}UDS does not exist, skipping DRO migration and proceeding with mas update"
DRO_NAMESPACE="redhat-marketplace"
DRO_CSV=$(oc get csv -n "${DRO_NAMESPACE}" | grep ibm-data-reporter-operator | awk '{print $1}')
echo $DRO_CSV
if [[ -n $DRO_CSV ]]; then
DRO_STATUS=$(oc get csv -n "${DRO_NAMESPACE}" "${DRO_CSV}" -o jsonpath='{.status.phase}')
if [[ $DRO_STATUS = *'Succeeded'* ]]; then
echo -e "${COLOR_YELLOW}DRO is currently running in namespace ${DRO_NAMESPACE}, skipping DRO migration and proceeding with mas update"
UDS_ACTION="skip"
fi
fi
fi
else
DRO_MIGRATION="false"
echo -e "${COLOR_YELLOW}UDS does not exist, skipping DRO migration and proceeding with mas update"
echo -e "${COLOR_YELLOW} Skipping the migration from UDS to DRO."
echo -e "${COLOR_YELLOW} By choosing 'Yes', you must confirm the migration from UDS to DRO"
echo -e "${COLOR_YELLOW} Or Add '--dro-migration' argument to the 'mas update' command in order to continue the migration from UDS to DRO"
fi
else
DRO_MIGRATION="false"
fi

}


# Auto-detect Grafana
# -----------------------------------------------------------------------------
# Detects whether Grafana V4 Operator is in the target cluster and prints a
Expand Down Expand Up @@ -344,6 +351,9 @@ function update_noninteractive() {
--dro-migration)
DRO_MIGRATION=true
;;
--dro-storage-class)
DRO_STORAGE_CLASS=$1 && shift
;;
--no-confirm)
NO_CONFIRM=true
;;
Expand Down Expand Up @@ -442,6 +452,8 @@ function update() {
export CERT_MANAGER_ACTION
export DRO_MIGRATION
export GRAFANA_V5_UPGRADE
export DRO_STORAGE_CLASS
export UDS_ACTION

echo_h2 "Review Settings"

Expand Down Expand Up @@ -494,9 +506,13 @@ function update() {

if [ "$DRO_MIGRATION" = "true" ]; then
echo_reset_dim "DRO Migration .............................. ${COLOR_GREEN}Yes${TEXT_RESET}"
if [ "$DRO_STORAGE_CLASS" != "" ]; then
echo_reset_dim "DRO Storage Class .............................. ${COLOR_GREEN}${DRO_STORAGE_CLASS}${TEXT_RESET}"
else
echo_reset_dim "DRO Storage Class .............................. ${COLOR_GREEN}None${TEXT_RESET}"
fi
else
echo_reset_dim "DRO Migration .............................. ${COLOR_RED}No${TEXT_RESET}"

fi

# Grafana Operator
Expand Down
4 changes: 4 additions & 0 deletions image/cli/mascli/templates/pipelinerun-update.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,9 @@ spec:
value: "$CERT_MANAGER_ACTION"
- name: dro_migration
value: '$DRO_MIGRATION'
- name: uds_storage_class
value: '$DRO_STORAGE_CLASS'
- name: uds_action
value: '$UDS_ACTION'
- name: grafana_v5_upgrade
value: '$GRAFANA_V5_UPGRADE'
16 changes: 14 additions & 2 deletions tekton/src/pipelines/update.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,15 @@ spec:
- name: dro_migration
default: ""
type: string
description: Set to 'true' to Migration UDS to DRO
description: Set to 'true' to Migration UDS to DRO
- name: uds_storage_class
default: ""
type: string
description: Set custom storageclass for UDS/DRO
- name: uds_action
default: "install-dro"
type: string
description: set UDS_ACTION, default is install-dro'

# grafana operator update
- name: grafana_v5_upgrade
Expand Down Expand Up @@ -298,7 +306,7 @@ spec:
value: $(params.kafka_namespace)
- name: kafka_provider
value: $(params.kafka_provider)

# UDS/DRO Migration
- name: update-uds
taskRef:
Expand All @@ -309,6 +317,10 @@ spec:
params:
- name: dro_migration
value: $(params.dro_migration)
- name: uds_storage_class
value: $(params.uds_storage_class)
- name: uds_action
value: $(params.uds_action)
- name: devops_suite_name
value: update-uds
{% if wait_for_install == true %}
Expand Down
6 changes: 3 additions & 3 deletions tekton/src/tasks/dependencies/uds.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@ spec:
value: $(params.uds_contact_firstname)
- name: UDS_CONTACT_LASTNAME
value: $(params.uds_contact_lastname)
- name: DRO_MIGRATION
value: $(params.dro_migration)


# IBM Data Reporter Operator (DRO)
# -------------------------------------------------------------------------
Expand Down Expand Up @@ -143,7 +142,8 @@ spec:
value: $(params.uds_contact_lastname)
- name: DRO_MIGRATION
value: $(params.dro_migration)

- name: DRO_STORAGE_CLASS
value: $(params.uds_storage_class)
workspaces:
- name: configs
optional: true
Expand Down

0 comments on commit 7cbcc81

Please sign in to comment.