pulp / pulp/pulpcore

PublishedMetadata is unsafe to subclass (not documented)

Open
#3,330 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Documentation Task
Dominant language
Python
Stars
598
Forks
168
Avg merge
1d 4h
Merged PRs (30d)
86

Description

And generally, our handling of orphan cleanup around PublishedMetadata seems a bit unsafe and fragile.

Version
Any

Describe the bug

Orphan cleanup relies on the fact that metadata for publications is saved as PublishedMetadata content - very specifically, using that type name.

https://github.com/pulp/pulpcore/blob/cb68fe59ae8f6da4eb3c95c6d05870483cac863e/pulpcore/app/tasks/orphan.py#L53-L55

If it's not created with that precise type name, orphan cleanup will happily delete all such metadata, as it's not strictly associated with a piece of content in the repository, and because create_from_file() is a classmethod

https://github.com/pulp/pulpcore/blob/cb68fe59ae8f6da4eb3c95c6d05870483cac863e/pulpcore/app/models/publication.py#L265

No plugins actually do this as far as I'm aware, but in general the code feels a bit dangerous. I saw https://bugzilla.redhat.com/show_bug.cgi?id=2073183, and while no specific potential causes jump out at me immediately, it feels like there might be a bug lurking in the create_from_file() code. Perhaps even a race condition.

It would be worthwhile to do a broader rethink of how all of this fits together.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading pulpcore/app/tasks/orphan.py at lines 53-55 and pulpcore/app/models/publication.py around line 265, especially the PublishedMetadata handling and create_from_file(). Trace how metadata is associated with content and how orphan cleanup selects records. Done should include an agreed safer design, coverage for subclassing and concurrency cases, and tests demonstrating that valid metadata is not removed.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.