From: ssum21 Date: Fri, 4 Oct 2024 02:00:08 +0000 (+0900) Subject: Enhance logging and error handling in uninstall_databases.sh X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F12%2F13512%2F1;p=aiml-fw%2Faimlfw-dep.git Enhance logging and error handling in uninstall_databases.sh - Improved script readability - Introduced a `log_message` function to standardize log output with different levels (INFO, ERROR). - Added success and error logging for PostgreSQL (tm-db) uninstallation. - Implemented error handling for PostgreSQL (tm-db) uninstallation, with exit on failure. Issue-ID: AIMLFW-103 Change-Id: I58b4f825fce191853157e8a36870e9cc76bf17c1 Signed-off-by: ssum21 --- diff --git a/bin/uninstall_databases.sh b/bin/uninstall_databases.sh index 91ef683..9a4b1fd 100755 --- a/bin/uninstall_databases.sh +++ b/bin/uninstall_databases.sh @@ -17,7 +17,23 @@ # ================================================================================== #Uninstall databases + +# Function to log messages with different levels: INFO, WARN, ERROR +log_message() { + local log_level=$1 + local component=$2 + local message=$3 + echo "[$log_level] $component: $message" +} + +log_message "INFO" "Helm" "Uninstalling PostgreSQL (tm-db) from 'traininghost' namespace..." helm delete tm-db -n traininghost +if [ $? -eq 0 ]; then + log_message "INFO" "Helm" "Successfully uninstalled tm-db" +else + log_message "ERROR" "Helm" "Failed to uninstall tm-db" + exit 1 +fi kubectl delete pvc data-tm-db-postgresql-0 -n traininghost helm delete cassandra -n traininghost sleep 10