Project

Profile

Help

Issue #5304

closed

Pulp 3 publishes metadata outside of artifact storage

Added by dkliban@redhat.com over 5 years ago. Updated almost 5 years ago.

Status:
CLOSED - CURRENTRELEASE
Priority:
Normal
Category:
-
Sprint/Milestone:
Start date:
Due date:
Estimated time:
Severity:
2. Medium
Version:
Platform Release:
OS:
Triaged:
Yes
Groomed:
Yes
Sprint Candidate:
Yes
Tags:
Sprint:
Sprint 59
Quarter:

Description

The initial bug report has led to the identification of the following problems:

  • pulp 3 cannot create PublishedMetadata files in /var/lib/pulp/published/ because POSIX permissions prevent it on a machine where Pulp 2 has already published content
  • PublishedMetadata are the only files that are stored in /var/lib/pulp/published, everything else is stored in /var/lib/pulp/artifact
  • Plugin API provides 2 ways to represent content: Content (made up of Artifacts) and PublishedMetadata
    • content app has two code paths for serving PublishedMetada and Content
    • metadata that is mirrored exactly as published is represented as a Content model and the same metadata generated by Pulp is represented as PublishedArtifcat
    • any code that exports a publication to a filesystem needs to have 2 code paths to export the contents of a publication

The solution to all these problems is to make PublishedMetadata inherit from Content. This way the artifact backing the PublishedMetadata would be stored in artifact storage. The plugin writer experience can be simplified by providing a constructor that allows the plugin writer to pass in a file, a relative path, and a publication. The creation of Artifact, ContentArtifact, and PublishedArtifact is handled by the constructor. The constructor will also save the PublishedMetada to the database.

Here is some example code from the publish task in the File plugin:

with WorkingDirectory():
    with FilePublication.create(repo_version, pass_through=True) as publication:
        manifest = Manifest(manifest)
        manifest.write(populate(publication))
        metadata = PublishedMetadata(
            relative_path=os.path.basename(manifest.relative_path),
            publication=publication,
            file=File(open(manifest.relative_path, "rb")),
        )
        metadata.save()

So the only difference for the plugin writer will be not having to call save():

with WorkingDirectory():
    with FilePublication.create(repo_version, pass_through=True) as publication:
        manifest = Manifest(manifest)
        manifest.write(populate(publication))
        metadata = PublishedMetadata(
            relative_path=os.path.basename(manifest.relative_path),
            publication=publication,
            file=File(open(manifest.relative_path, "rb"))
        )

The orphan cleanup query needs to be updated to consider content that is part of a publication to not be considered orphaned.


Related issues

Has duplicate Pulp - Issue #4834: File directories between pulp 2 and pulp 3 conflictCLOSED - DUPLICATEActions

Also available in: Atom PDF