Project

Profile

Help

Story #3295

closed

Story #3209: As a user, I have Repository Versions

As a plugin writer, I have a tool that helps me write tasks that create Publications

Added by amacdona@redhat.com almost 7 years ago. Updated about 5 years ago.

Status:
CLOSED - CURRENTRELEASE
Priority:
Normal
Category:
-
Sprint/Milestone:
Start date:
Due date:
% Done:

100%

Estimated time:
Platform Release:
Groomed:
Yes
Sprint Candidate:
Yes
Tags:
Sprint:
Sprint 32
Quarter:

Description

Tasks that create new Publications have to write to pulpcore tables in transactions, mark the publication complete, 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.

Proposal: Wrapper for the Publication object in the plugin API

The pulpcore model for Publication will be removed from the plugin API, so the wrapper will be the only supported way for plugin writers to create new Publications, and must be performed only in celery tasks.

The Publication wrapper:

  • can be used as a context manager that creates Publications.
  • can be used to retrieve the latest Publication of a repository.
  • Publications accept a RepositoryVersion facade/wrapper
  • uses transactions to create a new publication and update related tables
  • handles failure scenarios by cleaning up incomplete work
  • can create new PublishedMetadata objects from files
  • can create new PublishedArtifacts from content_artifacts
  • Can only add Metadata and Artifacts if complete=False
  • Can only add Metadata and Artifacts if run in a task
  • has exclusive control of the Publication.complete flag
  • Implements auto distribute. This means finding all Distributions by repository and publisher and setting the publication to the newly created on.

example usage

Create a new Publication. Plugin writers can use this object to create and write metadata, and can be used to create PublishedMetadata.


with Publication.create(repository_version) as publication:
    # If Publication requires new metadata, generate and write it.
    metadata_path = some_function_to_write_metadata(publication)
    # Safely and save PublishedMetadata object
    publication.add_metadata(metadata_path)
    # Safely create and save PublishedArtifact 
    # relative_path defaults to artifact.relative_path, but some plugins may want to customize the location.
    # For example, the rpm plugin may want to put all artifacts under the packages/ path.
    publication.add_artifact(artifact, relative_path=some_path)

The wrapper object can also be used to access the Publication model layer, which replaces the use of plugin.models.Publication.objects.get() with:


latest_publication = Publication.latest(repository)
# repository_version is a RepositoryVersion wrapper from #3285
some_publication = Publication.get(repository_version=repository_version)

Note:
Since the Publication accepts a RepositoryVersion facade (https://pulp.plan.io/issues/3285), it will need to use `RepositoryVersion._model`. `_model` is an protected method to prevent plugin use. Since we need the model here, we have to fudge the rules a little bit here to keep the Plugin API clean. Please include this in a comment.


Related issues

Related to File Support - Task #3323: Refit to use the Publication (Facade)CLOSED - CURRENTRELEASEjortel@redhat.com

Actions
Blocked by Pulp - Task #3184: Add complete field to Publication. CLOSED - CURRENTRELEASEmilan

Actions
Copied from Pulp - Story #3285: As a plugin writer, I have a tool that helps me write tasks that create RepositoryVersionsCLOSED - CURRENTRELEASEbizhang

Actions
Actions #1

Updated by amacdona@redhat.com almost 7 years ago

  • Copied from Story #3285: As a plugin writer, I have a tool that helps me write tasks that create RepositoryVersions added
Actions #2

Updated by amacdona@redhat.com almost 7 years ago

  • Blocked by Task #3184: Add complete field to Publication. added
Actions #3

Updated by amacdona@redhat.com almost 7 years ago

  • Description updated (diff)
Actions #4

Updated by amacdona@redhat.com almost 7 years ago

  • Description updated (diff)
Actions #5

Updated by amacdona@redhat.com almost 7 years ago

  • Description updated (diff)
Actions #6

Updated by jortel@redhat.com almost 7 years ago

  • Groomed changed from No to Yes
  • Sprint Candidate changed from No to Yes
Actions #7

Updated by jortel@redhat.com almost 7 years ago

  • Related to Task #3323: Refit to use the Publication (Facade) added
Actions #8

Updated by jortel@redhat.com almost 7 years ago

  • Sprint/Milestone set to 54
Actions #9

Updated by jortel@redhat.com almost 7 years ago

  • Description updated (diff)
Actions #10

Updated by jortel@redhat.com almost 7 years ago

  • Status changed from NEW to ASSIGNED

Added by jortel@redhat.com almost 7 years ago

Revision 48f29385 | View on GitHub

Publication context manager. closes #3295

Added by jortel@redhat.com almost 7 years ago

Revision 48f29385 | View on GitHub

Publication context manager. closes #3295

Actions #11

Updated by jortel@redhat.com almost 7 years ago

  • Status changed from ASSIGNED to MODIFIED
  • % Done changed from 0 to 100
Actions #12

Updated by ipanova@redhat.com almost 7 years ago

  • Assignee set to jortel@redhat.com
Actions #13

Updated by bmbouter almost 7 years ago

  • Sprint set to Sprint 32
Actions #14

Updated by bmbouter almost 7 years ago

  • Sprint/Milestone deleted (54)
Actions #15

Updated by daviddavis over 5 years ago

  • Sprint/Milestone set to 3.0.0
Actions #16

Updated by bmbouter over 5 years ago

  • Tags deleted (Pulp 3)
Actions #17

Updated by bmbouter about 5 years ago

  • Status changed from MODIFIED to CLOSED - CURRENTRELEASE

Also available in: Atom PDF