Project

Profile

Help

Story #3442

Updated by bmbouter 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/. 

 h3. Technical Design 

 Create a function that when called will: 

 <pre><code class="python"> 
 @shared_task(base=UserFacingTask) 
 def orphan_cleanup(): 
     # This should contain all of loop forever while waiting for 0 reservations 
     while True: 
         if zero_reservations is True: 
             # update the orphan code 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": 
         # 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 is called synchronously instead of routing 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. 
                 a dedicated worker 
         return 
 </code></pre>

Back