Skip to content

Commit

Permalink
ci: fix pvc clean-up on non deletable namespaces (#2994)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
daniel-weisse authored Mar 19, 2024
1 parent dc86a30 commit 0da6f0d
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .github/actions/constellation_destroy/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 0da6f0d

Please sign in to comment.