From a230975b925f80acaaef913d726ff0fa63efb772 Mon Sep 17 00:00:00 2001 From: Mohammed Abdi Date: Thu, 22 Feb 2024 10:50:28 -0500 Subject: [PATCH] promethues undeploy cleanup Signed-off-by: Mohammed Abdi --- deployment/deploy.sh | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/deployment/deploy.sh b/deployment/deploy.sh index abdf2e7..3c357af 100644 --- a/deployment/deploy.sh +++ b/deployment/deploy.sh @@ -137,13 +137,29 @@ do helm upgrade --install prometheus -f ${PROMETHEUS_YAML} --namespace ${SUSQL_NAMESPACE} prometheus-community/prometheus elif [[ ${action} = "prometheus-undeploy" ]]; then - echo "Undeploying Prometheus controller..." + echo "->Undeploying Prometheus controller..." echo "All data will be lost if the Prometheus deployment was not using a volume for permanent storage." echo -n "Would you like to procceed? [y/n]: " read response if [[ ${response} == "Y" || ${response} == "y" ]]; then - helm uninstall prometheus --namespace ${SUSQL_NAMESPACE} + output=$(helm uninstall prometheus --namespace ${SUSQL_NAMESPACE} 2>&1) + if [ $? -ne 0 ]; then + # Extract the error message + error_message=$(echo "$output" | tail -n 1) + + # Check if the error message contains "not found" + if [[ "$error_message" == *"not found"* ]]; then + # Custom message if release not found + echo "Prometheus: release: not found" + else + # Display the original error message + echo "$error_message" + fi + else + # Success message if the command was successful + echo "Prometheus uninstall successful." + fi fi elif [[ ${action} = "susql-deploy" ]]; then