Skip to content

Prevent mixing cached and uploaded content in repositories - #50

Open
aKlimau wants to merge 2 commits into
pulp:mainfrom
aKlimau:mixed-content
Open

Prevent mixing cached and uploaded content in repositories#50
aKlimau wants to merge 2 commits into
pulp:mainfrom
aKlimau:mixed-content

Conversation

@aKlimau

@aKlimau aKlimau commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Prevent mixing cached and uploaded content in repositories.

When a distribution is created or updated, the serializer checks the repo's existing relationships - its own remote, and the remote/allow_uploads of any sibling distributions pointing at the same repo. If the operation results in mixing caching and uploads - it will be rejected.

Closes #28.

📜 Checklist

  • Commits are cleanly separated with meaningful messages (simple features and bug fixes should be squashed to one commit)
  • A changelog entry or entries has been added for any significant changes
  • Follows the Pulp policy on AI Usage
  • (For new features) - User documentation and test coverage has been added

See: Pull Request Walkthrough

@aKlimau
aKlimau force-pushed the mixed-content branch 2 times, most recently from 65e9452 to 79b100b Compare August 4, 2026 12:21
@github-actions github-actions Bot removed the no-issue label Aug 4, 2026
@aKlimau

aKlimau commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

There is still a case were both uploaded and cached content can coexist in the same Repo, it can happen after a user decides to change repo_type value after the repo is already linked to a distributions.

Should repo_type field be immutable? This would cover such cases.

@aKlimau
aKlimau marked this pull request as draft August 4, 2026 12:33
…tories

closes pulp#28.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@aKlimau
aKlimau marked this pull request as ready for review August 5, 2026 10:31
@dralley

dralley commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Should repo_type field be immutable? This would cover such cases.

I need to think about it and ask around to see if others have a similar use case. I had considered in the past that perhaps we could expose different types of repositories like this without two different models entirely, but I haven't thought through all of the implications. Probably this is the right choice for the first version of this feature though.

@aKlimau aKlimau changed the title Add repo_type field to enforce separation of cache and private reposi… Prevent mixing cached and uploaded content in repositories Aug 24, 2026
)

# A repository is the unit of exclusivity: it may be used for pull-through caching
# OR for uploads, but never both.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strange wording

# OR for uploads, but never both.
if repository:
repo = repository.cast()
sibling_distributions = models.RustDistribution.objects.filter(repository=repo)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems fragile, at the very least the Distribution could probably be pointing to a repository version - "frozen" so to speak.

Which probably ought to also disable uploads?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But why would anyone try to upload something to a repository version? We are trying to prevent mixing of cached and uploaded content and uploading to a repo version doesn't lead to it.

I'm open to other solutions, but I don't see an issue with this one.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They're not uploading to the repository version, they're uploading to the distribution, which has a repo version set. And it shouldn't work. I think right now (not under this PR, I haven't checked, but master branch) it would upload to the repository and make new versions even though the distribution & distributed content doesn't change.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understood the code correctly, uploading via cargo publish won't work if a distribution has repo_version set, since it relies on distro.repository having a value: https://github.com/pulp/pulp_rust/blob/main/pulp_rust/app/views.py#L347

And base distribution class doesn't allow for a distro to have both repo and repo_version set.
https://github.com/pulp/pulpcore/blob/main/pulpcore/app/serializers/publication.py#L315

Was that your concern or am I missing smt?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enforce that private and public content cannot be mixed within a repository?

2 participants