From 6e55b1d76ee0cd22018de4fe3746506ee349db9a Mon Sep 17 00:00:00 2001 From: ssum21 Date: Fri, 4 Oct 2024 11:00:08 +0900 Subject: [PATCH] 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 --- bin/uninstall_databases.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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 -- 2.16.6