Project

Profile

Help

Issue #3541

closed

Core should not add/remove content to a repository or create a repository_version without plugin input

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

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

Description

General Problem:

Some plugins have validation requirements for the membership of content units in a repository. The validation required depends on the plugin and the content type. Currently add/remove is done with a POST to v3/repositories/1234/versions/. This does not involve the plugins at all, so there is no opportunity for plugins to create these validations.

Example Problem with Docker:

ManifestLists cannot be added unless the Manifests they refer to are also in the repository.
L1 is ManifestList, and it refers to (contains) 2 Manifests, M1, M2. The repository is considered corrupt if it contains L1, but not M1 and M2. M1 and M2 could be in the repository without L1.

Solutions:

Add a plugin opportunity to be involved

The RepositoryVersion.create() method will take a new, optional parameter called handler. A new object will be created in pulpcore.plugin.handlers.RepositoryVersionHandler.

class RepositoryVersionHandler:

    def add_content(self, qs_add_content, repo_version):
        pass

    def remove_content(self, qs_remove_content, repo_version):
        pass

    def validate(self, repo_version):
        # this method should only validate
        pass

    def repo_key_implementation(qs_add_content, repo_version, model_class, repo_unit_key):
        # the implementation of repo_key
        # not enabled by default
        # remove the content form repo_version when repo_unit_key has "another one" already in it.

Then a subclass would be:

class FileRepositoryVersionHandler(RepositoryVersionHandler):

    def __init__(custom_foo, custom_bar):
        # allow for customization here from params.
        pass

    def add_content(self, qs_add_content, repo_version):
        cls.repo_key_implementation(qs_add_content, repo_version, FileContent, 'relative_path')
        # This effectively "enables" the repo_key functionality here instead of on the Content object.

The plugin will create an instance of their subclass, e.g. FileRepositoryVersionHandler, configured how they want, and then pass it to RepositoryVersion.create() like:

my_handler = FileRepositoryVersionHandler('a', 'b')
RepositoryVersion.create(handler=my_handler)

Providing a RepositoryVersionHandler is optional.

Integration with DeclarativeVersion

A new, optional parameter called handler will be added to DeclarativeVersion which will also accept and use the handler for various operations on the RepositoryVersion.


Related issues

Related to Pulp - Task #3522: Plan Master/Detail TasksCLOSED - WONTFIX

Actions
Related to Python Support - Issue #3604: Bugs around creating content unitsMODIFIEDbizhangActions
Has duplicate Pulp - Issue #4740: Pulpcore doesn't provide a way to guarantee uniqueness in repo versionsCLOSED - DUPLICATEActions
Blocked by Pulp - Story #5625: Typed RepositoriesCLOSED - CURRENTRELEASEdalley

Actions

Also available in: Atom PDF