Actions
Story #3442
closedAs a user, I can clean up both orphaned content units and orphaned artifacts
Start date:
Due date:
% Done:
100%
Estimated time:
Platform Release:
Groomed:
Yes
Sprint Candidate:
Yes
Tags:
Sprint:
Sprint 34
Quarter:
Description
- This would be a single action
- I cannot specify the units specifically (all types).
- I can follow the progress of all cleanups. (Cleanups are asynchronous.)
- Call would be to DELETE /api/v3/orphans/.
Technical Design¶
Create a function that when called will:
@shared_task(base=UserFacingTask)
def orphan_cleanup():
# This should contain all of the orphan code
Then make a celery task that will never actually run, but will be intercepted by queue_reserve_task()
. Something like:
if task.name == "orphan_cleanup":
# loop forever while waiting for 0 reservations
while True:
if zero_reservations is True:
try:
orphan_cleanup() # this automatically handles transitioning the task to RUNNING
except:
orphan_cleanup.on_failure(...) # we need to pass it the right args. This marks the task as failed.
else:
orphan_cleanup.on_success(...) # we need to pass it the right args. This marks the task as successful.
return
Cancellation¶
To ensure that task cancellation work as expected we should have the _queue_release_resource receive the task ID typically specified by the inner_task_id
. This should be safe because _queue_release_resource has no side effects on the Task data because it does not inherit from UserFacingTask
To accomplish ^ we need to have a conditional path like:
if task.name == "orphan_cleanup":
_queue_reserved_task.apply_async(task_id=inner_task_id, args=(task_name, inner_task_id, list(resources), args,
kwargs, options),
queue=RESOURCE_MANAGER_QUEUE)
else:
_queue_reserved_task.apply_async(args=(task_name, inner_task_id, list(resources), args,
kwargs, options),
queue=RESOURCE_MANAGER_QUEUE)
Related issues
Actions
As a user, I can cleanup orphan content and artifacts
fixes #3442 https://pulp.plan.io/issues/3442