Prevent Permanent Deletion If No Groups Exist In test_resources_handler
What does this MR do and why?
This MR addresses the following error that occurs in the delete-failed-test-resources
job:
rake aborted!
NoMethodError: undefined method `each_with_object' for nil:NilClass
/home/gitlab/qa/qa/tools/test_resources_handler.rb:188:in `delete_groups_permanently'
/home/gitlab/qa/qa/tools/test_resources_handler.rb:63:in `block in run_delete'
/home/gitlab/qa/qa/tools/test_resources_handler.rb:49:in `each'
/home/gitlab/qa/qa/tools/test_resources_handler.rb:49:in `flat_map'
/home/gitlab/qa/qa/tools/test_resources_handler.rb:49:in `run_delete'
/home/gitlab/qa/Rakefile:70:in `block (2 levels) in <top (required)>'
/usr/local/bin/bundle:23:in `load'
/usr/local/bin/bundle:23:in `<main>'
This error occurs because we are not checking if groups exist in the filtered list of resources first before calling on delete_groups_permanently
.
This causes the job to fail and exit early before processing and deleting the remaining failed resources. Since the failed resources files are deleted right away after being downloaded from the bucket, the next retry of delete-failed-test-resources
will no longer have access to these, causing many resources to remain on the environment.
An example of this can be seen in this job, where failed-test-resources-468bcd.json
only had user resources to delete and no groups:
https://ops.gitlab.net/gitlab-org/quality/staging/-/jobs/8596730
Once this is fixed, this should hopefully prevent resources from accumulating on our environments and prevent E2E failures like #378488 (closed)
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.