From 0da6f0d014cb2c3d69061e4b6d3e4fd86d9f7800 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Wei=C3=9Fe?= <66256922+daniel-weisse@users.noreply.github.com> Date: Tue, 19 Mar 2024 14:53:58 +0100 Subject: [PATCH] ci: fix pvc clean-up on non deletable namespaces (#2994) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Only delete namespace if its deletable * For "default" namespace, delete all resources in that namespace * For "kube-system" namespace, delete all PVCs in that namespace * Don't abort terminate action if PVC deletion fails --------- Signed-off-by: Daniel Weiße --- .github/actions/constellation_destroy/action.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/actions/constellation_destroy/action.yml b/.github/actions/constellation_destroy/action.yml index af172c0c1..9ae79efd2 100644 --- a/.github/actions/constellation_destroy/action.yml +++ b/.github/actions/constellation_destroy/action.yml @@ -24,6 +24,7 @@ runs: - name: Delete persistent volumes if: inputs.kubeconfig != '' shell: bash + continue-on-error: true env: KUBECONFIG: ${{ inputs.kubeconfig }} PV_DELETION_TIMEOUT: "120" # 2 minutes timeout for pv deletion @@ -34,6 +35,14 @@ runs: # Scrap namespaces that contain PVCs for namespace in `kubectl get namespace --no-headers=true -o custom-columns=":metadata.name"`; do if [[ `kubectl get pvc -n $namespace --no-headers=true -o custom-columns=":metadata.name" | wc -l` -gt 0 ]]; then + if [[ "${namespace}" == "default" ]]; then + kubectl delete all --all --namespace "default" --wait + continue + fi + if [[ "${namespace}" == "kube-system" ]]; then + kubectl delete pvc --all --namespace "kube-system" --wait + continue + fi kubectl delete namespace $namespace --wait fi done