Project

Profile

Help

Story #3442

closed

As a user, I can clean up both orphaned content units and orphaned artifacts

Added by daviddavis over 6 years ago. Updated almost 5 years ago.

Status:
CLOSED - CURRENTRELEASE
Priority:
Normal
Assignee:
Category:
-
Sprint/Milestone:
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

Related to Pulp - Issue #3445: Remove the ability for users to delete a single content unit.CLOSED - CURRENTRELEASEdalleyActions
Related to Pulp - Issue #3508: Artifact files aren't getting deleted along with artifactsCLOSED - CURRENTRELEASEdaviddavisActions
Related to Pulp - Story #3542: As a plugin writer, I can create a task that waits until there are no reservationsCLOSED - WONTFIX

Actions
Related to Pulp - Story #2484: As a pulp 3.0 user, orphan content delete reports how many units were deletedCLOSED - CURRENTRELEASE

Actions
Related to Pulp - Test #4663: Test remove orphans endpointCLOSED - DUPLICATEkersomActions

Also available in: Atom PDF