2022-07-13 08:04:46 -04:00
|
|
|
name: Constellation destroy
|
2022-05-03 05:15:53 -04:00
|
|
|
description: "Destroy a running Constellation cluster."
|
2022-10-27 10:57:54 -04:00
|
|
|
|
2022-11-09 04:28:34 -05:00
|
|
|
inputs:
|
|
|
|
kubeconfig:
|
|
|
|
description: "The kubeconfig for the cluster."
|
|
|
|
required: true
|
2023-10-27 03:37:26 -04:00
|
|
|
selfManagedInfra:
|
|
|
|
description: "Use self-managed infrastructure instead of infrastructure created by the Constellation CLI."
|
|
|
|
required: true
|
2022-11-09 04:28:34 -05:00
|
|
|
|
2022-05-03 05:15:53 -04:00
|
|
|
runs:
|
2022-10-27 10:57:54 -04:00
|
|
|
using: "composite"
|
2022-05-03 05:15:53 -04:00
|
|
|
steps:
|
2022-11-09 04:28:34 -05:00
|
|
|
- name: Delete persistent volumes
|
|
|
|
if: inputs.kubeconfig != ''
|
2022-10-27 10:57:54 -04:00
|
|
|
shell: bash
|
2022-11-09 04:28:34 -05:00
|
|
|
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"
|
2022-11-09 04:28:34 -05:00
|
|
|
|
|
|
|
# Scrap namespaces that contain PVCs
|
|
|
|
for namespace in `kubectl get namespace --no-headers=true -o custom-columns=":metadata.name"`; do
|
2022-12-09 05:51:38 -05:00
|
|
|
if [[ `kubectl get pvc -n $namespace --no-headers=true -o custom-columns=":metadata.name" | wc -l` -gt 0 ]]; then
|
2022-11-09 04:28:34 -05:00
|
|
|
kubectl delete namespace $namespace --wait
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2022-12-09 05:51:38 -05:00
|
|
|
until [[ "$(kubectl get pv -o json | jq '.items | length')" == "0" ]] || [[ $ELAPSED -gt $PV_DELETION_TIMEOUT ]];
|
2022-10-27 10:57:54 -04:00
|
|
|
do
|
2022-11-09 04:28:34 -05:00
|
|
|
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
|
2022-12-09 05:51:38 -05:00
|
|
|
if [[ $ELAPSED -gt $PV_DELETION_TIMEOUT ]]; then
|
2022-11-09 04:28:34 -05:00
|
|
|
echo "Timed out waiting for PV deletion.."
|
|
|
|
exit 1
|
2022-10-27 10:57:54 -04:00
|
|
|
fi
|
|
|
|
echo "::endgroup::"
|
|
|
|
|
|
|
|
- name: Constellation terminate
|
2023-10-27 03:37:26 -04:00
|
|
|
if: inputs.selfManagedInfra != 'true'
|
2022-10-27 10:57:54 -04:00
|
|
|
shell: bash
|
2023-04-28 05:25:45 -04:00
|
|
|
run: |
|
2023-08-16 05:34:58 -04:00
|
|
|
constellation terminate --yes --tf-log=DEBUG
|
2023-10-27 03:37:26 -04:00
|
|
|
|
|
|
|
- name: Constellation terminate (self-managed)
|
|
|
|
if: inputs.selfManagedInfra == 'true'
|
|
|
|
shell: bash
|
|
|
|
working-directory: ${{ github.workspace }}/e2e-infra
|
|
|
|
run: |
|
|
|
|
terraform init
|
|
|
|
terraform destroy -auto-approve
|
|
|
|
# Explicitly delete the state file
|
|
|
|
rm ${{ github.workspace }}/constellation-state.yaml
|
|
|
|
rm ${{ github.workspace }}/constellation-admin.conf
|