From cf42a0aec84a5cdf7af89842ed59505799b0efc3 Mon Sep 17 00:00:00 2001 From: Alexandre Lavigne Date: Fri, 8 Sep 2023 14:37:13 +0200 Subject: [PATCH] Improve ovh vm cleanup By defautl any bash command runs with `set -e` which enables: exit on error Running the `openstack server delete` command may exit with an error but we don't want to stop there. Around that specific part of the action do not exit on error. --- actions-cleanup-openstack-vms/action.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/actions-cleanup-openstack-vms/action.yaml b/actions-cleanup-openstack-vms/action.yaml index df2fba7..c7255de 100644 --- a/actions-cleanup-openstack-vms/action.yaml +++ b/actions-cleanup-openstack-vms/action.yaml @@ -77,12 +77,14 @@ runs: creation_time=$(openstack server show -f value -c created "$vm") timestamp=$(date -d "$creation_time" +%s) if [ "$timestamp" -lt "$delta" ]; then - openstack server delete "$vm" --wait --verbose --wait + set +e + openstack server delete "$vm" --wait --verbose if [ $? -eq 0 ]; then echo "VM '$vm' deletion successful" else echo "VM '$vm' deletion failed" fi + set -e fi done echo echo ":rocket: Cleanup of VMs older that ${{ inputs.AGE_HOURS }} hours successful" >> $GITHUB_STEP_SUMMARY