Project

Profile

Help

Story #3442

Updated by amacdona@redhat.com about 6 years ago

* 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/. /api/v3/orphans. 

 h3. Technical Design 

 Create a function that when called will: 

 <pre><code class="python"> 
 @shared_task(base=UserFacingTask) 
 def orphan_cleanup(): 
     # loop forever while waiting for 0 reservations 
     while True: 
         if zero_reservations is True: 
             # update the current status to running like a real celery task would 
             current_task.status = RUNNING 
             current_task.save() 
             do_cleanup_here() 
             # update the current status to running like a real celery task would 
             current_task.status = COMPLETE 
             current_task.save() 
             break 
         sleep(1) 
 </code></pre> 

 Then make a celery task that will never actually run, but will be intercepted by "<code>queue_reserve_task()</code>":https://github.com/pulp/pulp/blob/3.0-dev/pulpcore/pulpcore/tasking/tasks.py#L100. Something like: 

 <pre><code class="python"> 
     if task.name == "orphan_cleanup": 
         orphan_cleanup()    # this is called synchronously instead of routing it to a dedicated worker 
         return 
 </code></pre>

Back