Skip to content
Snippets Groups Projects
Commit 8bcc357d authored by Danylo Vanin (EPAM)'s avatar Danylo Vanin (EPAM)
Browse files

[GONRG-9896] Limit helm release cleanup to partition

parent 4b3c700a
No related branches found
No related tags found
1 merge request!572[GONRG-9896] Limit helm release cleanup to partition
Checking pipeline status
#!/usr/bin/env bash
# # This script performs cleanup operations for Kubernetes and Datastore test environments.
# It provides options to clean up Helm releases in a Kubernetes test namespace,
# clean up Datastore entries, or both. The Helm releases to be deleted are filtered
# based on a configurable variable GC_TEST_HELM_NAME, which defaults to "partition".
# Configurable variable
GC_TEST_HELM_NAME=${GC_TEST_HELM_NAME:-partition}
cluster_cleanup() {
# check variable for namespace
# Check if the namespace contains the word "test"
if [[ "$GC_HELM_NAMESPACE" == *test ]]
then
# uninstall partition helm releases
# List all Helm releases in the namespace and uninstall those containing the value of GC_TEST_HELM_NAME
LIST=$(helm -n $GC_HELM_NAMESPACE list -o json | jq -r .[].name)
for RELEASE in $LIST
do
helm -n $GC_HELM_NAMESPACE uninstall $RELEASE
if [[ "$RELEASE" == *"$GC_TEST_HELM_NAME"* ]]; then
helm -n $GC_HELM_NAMESPACE uninstall $RELEASE
fi
done
echo "Cluster cleanup Finished"
else
......@@ -19,16 +28,19 @@ cluster_cleanup() {
}
datastore_cleanup () {
# Install necessary packages and Python dependencies
apk add py3-pip python3-dev libffi-dev
pip install --upgrade pip
pip install --upgrade setuptools
pip install -q -r devops/gc/tests/clean_up/requirements.txt
# Run the datastore cleanup script
python3 devops/gc/tests/clean_up/datastore_clean_up.py -p "$GC_PROJECT" -n $PARTITION_NAMESPACE --delete-all
echo "Datastore cleanup finished"
}
# Enable script debugging and exit immediately if a command exits with a non-zero status
set -ex
case "$1" in
......@@ -43,6 +55,6 @@ case "$1" in
cluster_cleanup
datastore_cleanup;;
*)
echo "You must setup option like --cluster/datastore/all"
echo "You must set up an option like --cluster, --datastore, or --all"
exit 1;;
esac
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment