Make E2E cleanup easier (#353)

* Make E2E cleanup easier
Signed-off-by: Fabian Kammel <fk@edgeless.systems>
This commit is contained in:
Fabian Kammel 2022-08-10 10:13:18 +02:00 committed by GitHub
parent 919a2165ae
commit c35e85b22b
4 changed files with 49 additions and 0 deletions

2
hack/fetch-broken-e2e/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
azure
gcp

View File

@ -0,0 +1,13 @@
# Motivation
Sometimes E2E pipeline fails in a way that cleanup was not possible, but a state was stored. These scripts help with manual cleanup.
## Usage
```bash
# Downloads states of all recent (last 20) runs
./fetch.sh
# Find the UID of cluster in Azure/GCP you want to delete
./find.sh <UID>
# Follow the instructions
```

21
hack/fetch-broken-e2e/fetch.sh Executable file
View File

@ -0,0 +1,21 @@
#!/bin/bash
set -euo pipefail
LATEST_AZURE_RUNS=$(gh run list -R edgelesssys/constellation -w 'e2e Test Azure' --json databaseId -q '.[].databaseId')
echo $LATEST_AZURE_RUNS
for RUN_ID in $LATEST_AZURE_RUNS
do
# Might fail, because no state was written, because e2e pipeline failed early
# Or, because state was downloaded by earlier run of this script
gh run download ${RUN_ID} -R edgelesssys/constellation -n constellation-state.json -D azure/${RUN_ID} || true
done
LATEST_GCP_RUNS=$(gh run list -R edgelesssys/constellation -w 'e2e Test GCP' --json databaseId -q '.[].databaseId')
echo $LATEST_GCP_RUNS
for RUN_ID in $LATEST_GCP_RUNS
do
# Might fail, because no state was written, because e2e pipeline failed early
# Or, because state was downloaded by earlier run of this script
gh run download ${RUN_ID} -R edgelesssys/constellation -n constellation-state.json -D gcp/${RUN_ID} || true
done

13
hack/fetch-broken-e2e/find.sh Executable file
View File

@ -0,0 +1,13 @@
#!/bin/bash
set -euo pipefail
TO_DELETE=$(grep -lr "\"uid\": \"${1}\"" . || true)
if [ -z "$TO_DELETE" ]
then
printf "Unable to find '${1}'\n"
else
printf "Statefile found. You should run:\n\n"
printf "cd %s\n" $TO_DELETE
printf "constellation terminate\n\n"
fi