Cleanup dangling virtualbox resources
What does this MR do?
Cleanup dangling virtualbox resources when a user cancels a job while the VM is being created.
Why was this MR needed?
When job is cancelled while the VM is being created, the VM creation is aborted midway and it leaves dangling resources which are not cleaned up. This prevents from a new job getting scheduled in certain cases since the VM name matches.
To resolve this, we delete all the hard drives associated to the VM and delete the machine folder where the VM data is present.
What's the best way to test this MR?
- Setup virtualbox executor.
- Checkout
mainbranch and follow the steps mentioned here to reproduce this issue. - Checkout
vtak/virtualbox_dangling_cleanupbranch(this MR) and retry the above failed job. - Verify that the job passes successfully.
What are the relevant issue numbers?
Screenshots
-
main branch- Job is cancelled while the VM is being created - https://gitlab.com/vtak/my-ci-bug-reproducing-project/-/jobs/12057709579
-
main branch- A new job is ran which results in a failure - https://gitlab.com/vtak/my-ci-bug-reproducing-project/-/jobs/12057827257
-
vtak/virtualbox_dangling_cleanup branch- Retry the job which runs into the same error but cleans it up properly and then on automatic retry, it passes - https://gitlab.com/vtak/my-ci-bug-reproducing-project/-/jobs/12057861077


