The scrubber can leave orphaned objects and db records in error / edge cases. This is because the order in which it updates the DB and object store. Recommended solution:
For each image that has status pending_delete:
For each image location that has status pending_delete:
Delete the object in the object store
If error other than object not found, continue
Mark image location status as deleted
If all image locations are deleted, mark image as deleted
Else if no image locations are marked as pending_delete, change status to something else??? # I suppose it's possible an image_location would still be active or some other non-deleted status. I don't think we want to orphan the image_location by marking the image deleted in this case.
I suppose examples are warranted:
I had a case where the scheme wasn't supported as configured and all the image statuses were marked as deleted and all the image_location statuses were still pending_delete with objects still in object store.
I had another case where the image statuses were marked as deleted, image location statuses were still pending_delete and there were no objects in the object store.