Skip to content

Commit

Permalink
Improve ovh vm cleanup
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Alexandre Lavigne committed Sep 8, 2023
1 parent 2f51aa5 commit cf42a0a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion actions-cleanup-openstack-vms/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit cf42a0a

Please sign in to comment.