constellation/.github/actions/constellation_destroy/action.yml

45 lines
1.4 KiB
YAML
Raw Normal View History

name: Constellation destroy
description: "Destroy a running Constellation cluster."
2022-10-27 10:57:54 -04:00
inputs:
kubeconfig:
description: "The kubeconfig for the cluster."
required: true
runs:
2022-10-27 10:57:54 -04:00
using: "composite"
steps:
- name: Delete persistent volumes
if: inputs.kubeconfig != ''
continue-on-error: true
2022-10-27 10:57:54 -04:00
shell: bash
env:
KUBECONFIG: ${{ inputs.kubeconfig }}
PV_DELETION_TIMEOUT: "120" # 2 minutes timeout for pv deletion
2022-10-27 10:57:54 -04:00
run: |
ELAPSED=0
echo "::group::Wait for PV deletion"
# 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
kubectl delete namespace $namespace --wait
fi
done
until [[ "$(kubectl get pv -o json | jq '.items | length')" == "0" ]] || [[ $ELAPSED -gt $PV_DELETION_TIMEOUT ]];
2022-10-27 10:57:54 -04:00
do
echo $(kubectl get pv -o json | jq '.items | length') PV remaining..
sleep 1
ELAPSED=$((ELAPSED+1))
2022-10-27 10:57:54 -04:00
done
if [[ $ELAPSED -gt $PV_DELETION_TIMEOUT ]]; then
echo "Timed out waiting for PV deletion.."
exit 1
2022-10-27 10:57:54 -04:00
fi
echo "::endgroup::"
- name: Constellation terminate
shell: bash
run: constellation terminate --yes