Skip to content

Commit

Permalink
divide app deletion into two phases:
Browse files Browse the repository at this point in the history
normap apps and operators
  • Loading branch information
robertchoi80 committed Oct 12, 2021
1 parent 0e28280 commit dfebc88
Showing 1 changed file with 42 additions and 3 deletions.
45 changes: 42 additions & 3 deletions templates/argo-cd/delete-apps-by-label-wftpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,53 @@ spec:
./argocd login $ARGO_SERVER --plaintext --insecure --username $ARGO_USERNAME \
--password $ARGO_PASSWORD
# Pre-check: validate if the label is correct
app_list=$(./argocd app list -l $FILTER --output name)
if [[ $? -eq 0 && -n $app_list ]]; then
echo "Deleting apps: $app_list"
echo "$app_list" | xargs ./argocd app delete --cascade -y
echo "App deletion command's been finished!"
echo "Found apps with label '$FILTER'.. Start deleting apps.."
else
echo "No such label: $FILTER. Exiting.."
exit 1
deleted=False
# Delete normal apps including CRs
app_list=$(./argocd app list -l $FILTER --output name | grep -v operator)
if [[ $? -eq 0 && -n $app_list ]]; then
echo "[1st phase] Deleting apps: $app_list"
echo "$app_list" | xargs ./argocd app delete --cascade -y
until [ $(./argocd app list -l $FILTER --output name | grep -v operator | wc -l) == 0 ]
do
echo "Waiting 20 secs for apps to be deleted.."
done
echo "[1st phase] App deletion have been finished!"
deleted=True
else
echo "No apps found except operators. Skipping 1st phase.."
fi
# Delete operators
app_list=$(./argocd app list -l $FILTER --output name)
if [[ $? -eq 0 && -n $app_list ]]; then
echo "[2nd phase] Deleting operators: $app_list"
echo "$app_list" | xargs ./argocd app delete --cascade -y
until [ $(./argocd app list -l $FILTER --output name | wc -l) == 0 ]
do
echo "Waiting 20 secs for apps to be deleted.."
done
echo "[2nd phase] App deletion have been finished!"
deleted=True
else
echo "No operators found. Skipping 2nd phase.."
fi
if [ $deleted != True ] ; then
echo "No apps have been deleted at all. Something wrong.."
exit 1
fi
envFrom:
- secretRef:
Expand Down

0 comments on commit dfebc88

Please sign in to comment.