Project

Profile

Help

Story #3285

Updated by amacdona@redhat.com over 4 years ago

Tasks that create new RepositoryVersions have to write to pulpcore tables in transactions, set up a working directory, finalize the new version and clean up the database if the task fails. All of this should be handled by a context manager that is a part of the plugin API. 

 This context manager should: 

 # Prepare for task 
 ## Create a new RepositoryVersion(complete=False number=respository.last_version+1) RepositoryVersion(complete=False) 
 ## Increment RepositoryVersion.repository.last_version 
 ## Create a CreatedResource(content_object=new_version) 
 ## Create a working directory 
 # Finalize after a successful task 
 ## RepositoryVersion.complete = True 
 ## unset working directory 
 # Clean up after a failed task 
 ## Delete new version 
 ## delete created resource 
 ## do not decrement new_version.repository.last_version 

 This list is based on the work done by the File plugin's sync task: 
 https://github.com/asmacdo/pulp_file/blob/a8997383e2a64f915769db629435ae4abecf576c/pulp_file/app/tasks.py#L52-L79

Back