From 8809324c5f51e557f7a9fd129db861dfa6ca3542 Mon Sep 17 00:00:00 2001 From: Romain Arnaud Date: Thu, 13 Feb 2025 11:54:34 -0500 Subject: [PATCH] fix: improve hack scripts - reset.sh: add '--all' flag - reset.sh: remove the '-i dh' option as DH can now be reset with '-n rhtap-dh' - reset.sh: delete PVCs on namespace deletion - fix a small issue with the ENVFILE var rh-pre-commit.version: 2.3.2 rh-pre-commit.check-secrets: ENABLED --- hack/ci-set-org-vars.sh | 2 +- hack/deploy.sh | 2 +- hack/reset.sh | 24 ++++++++++-------------- 3 files changed, 12 insertions(+), 16 deletions(-) diff --git a/hack/ci-set-org-vars.sh b/hack/ci-set-org-vars.sh index 35b3b009..680554b2 100755 --- a/hack/ci-set-org-vars.sh +++ b/hack/ci-set-org-vars.sh @@ -37,7 +37,7 @@ parse_args() { while [[ $# -gt 0 ]]; do case $1 in -e | --env-file) - ENVFILE="$2" + ENVFILE="$(readlink -e "$2")" shift ;; -n | --namespace) diff --git a/hack/deploy.sh b/hack/deploy.sh index 8257d167..029e9afb 100755 --- a/hack/deploy.sh +++ b/hack/deploy.sh @@ -55,7 +55,7 @@ parse_args() { shift ;; -e | --env-file) - ENVFILE="$2" + ENVFILE="$(readlink -e "$2")" shift ;; -i|--integration) diff --git a/hack/reset.sh b/hack/reset.sh index 6c063ad6..81ecee24 100755 --- a/hack/reset.sh +++ b/hack/reset.sh @@ -18,6 +18,8 @@ Usage: ${0##*/} [options] Optional arguments: + -a, --all + Reset the cluster and integration services. -c, --cluster Reset all RHTAP namespaces in the cluster. -e, --env-file @@ -26,7 +28,7 @@ Optional arguments: Delete the specified namespace. The option can be repeated to delete multiple namespaces. -i, --integration INTEGRATION - Service to reset [dh, github, gitlab]. The option can be repeated + Service to reset [github, gitlab]. The option can be repeated to reset multiple services. -d, --debug Activate tracing/debug mode. @@ -43,20 +45,20 @@ parse_args() { NAMESPACES=() while [[ $# -gt 0 ]]; do case $1 in + -a|--all) + CLUSTER=1 + GITHUB=1 + GITLAB=1 + ;; -c|--cluster) CLUSTER=1 ;; -e | --env-file) - ENVFILE="$2" + ENVFILE="$(readlink -e "$2")" shift ;; -i|--integration) case $2 in - dh) - if kubectl get backstages.rhdh.redhat.com --ignore-not-found 2>/dev/null; then - DH=1 - fi - ;; github) GITHUB=1 ;; @@ -120,7 +122,7 @@ action() { for ns in "${NAMESPACES[@]}"; do kubectl delete namespace "$ns" & echo "Deleting namespace $ns..." - for cr in "applications.argoproj.io" "kafkatopics.kafka.strimzi.io"; do + for cr in "applications.argoproj.io" "kafkatopics.kafka.strimzi.io" "persistentvolumeclaims"; do sleep 3 while [ "$(oc get "$cr" -n "$ns" -o name | wc -l)" != "0" ]; do for kt in $(oc get "$cr" -n "$ns" -o name); do @@ -133,12 +135,6 @@ action() { echo "✓ Deleted all namespaces" echo fi - if [ -n "${DH:-}" ]; then - echo '# Developer Hub' - kubectl delete backstages.rhdh.redhat.com -n "$NAMESPACE" developer-hub --ignore-not-found --wait=true - kubectl delete persistentvolumeclaims -n "$NAMESPACE" data-backstage-psql-developer-hub-0 --ignore-not-found --wait=true - echo - fi if [ -n "${GITHUB:-}" ]; then echo '# GitHub' for REPO in $(gh repo list "$GITHUB__ORG" --json url | yq '.[].url'); do