Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Content app auto-distributes latest publication #1328

Merged
merged 1 commit into from
May 19, 2021
Merged

Conversation

gerrod3
Copy link
Contributor

@gerrod3 gerrod3 commented May 14, 2021

@bmbouter Here is the problem(and assumption) I ran into https://pulp.plan.io/issues/8760#note-2

fixes: #8760
https://pulp.plan.io/issues/8760

Please be sure you have read our documentation on creating PRs:
https://docs.pulpproject.org/contributing/pull-request-walkthrough.html

@pulpbot
Copy link
Member

pulpbot commented May 14, 2021

Attached issue: https://pulp.plan.io/issues/8760

repo_version = distro.repository.latest_version()
# Search for publication serving latest_version
try:
publication = repo_version.publication_set.earliest("pulp_created")
Copy link
Member

Choose a reason for hiding this comment

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

Can the distribution have both a repository and a publication set?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes for now, but in the future no.

Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure i understand the logic here.
What if we have a repository that needs publications, and a new version has just been created, but the autopublishing is still in progress. Then the content app will attempt to handle this repository version as one without publications, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, you would end up getting a 404 if you tried accessing a file that was only created through a publication. If you were to access a piece of content it would probably work. This means for a time you could access content inside of a repository that would not have been exposed due to publication settings.

Copy link
Member

Choose a reason for hiding this comment

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

Should we use the latest version that has a publication instead in those cases?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think so.

Copy link
Member

Choose a reason for hiding this comment

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

I agree

try:
versions = repository.versions.all()
publications = Publication.objects.filter(repository_version__in=versions)
publication = publications.latest("repository_version", "-pulp_created")
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we add an index for this?

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

+1 to this

Copy link
Contributor

Choose a reason for hiding this comment

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

I've backed off on this, we should investigate indexes but we should probably try to measure the impact rather than adding them speculatively.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added task to keep track of this: https://pulp.plan.io/issues/8777

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we want to exclude publications where complete=False as well here.

Copy link
Member

Choose a reason for hiding this comment

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

Ah great point!

CHANGES/8760.feature Outdated Show resolved Hide resolved
@bmbouter
Copy link
Member

The code and tests here look good. I'll wait until the index is added and the tiny changelog fix.

@bmbouter
Copy link
Member

I also did some testing, which due to the tests wasn't really needed, but it did test well when I ran this code with pulp_file FWIW.

"""

@classmethod
def setUpClass(cls):
"""Create class-wide variables."""
cls.cfg = config.get_config()
cls.client = api.Client(cls.cfg)
cls.file_client = gen_file_client()
Copy link
Member

Choose a reason for hiding this comment

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

Nice bindings tests, ty!

Copy link
Member

@bmbouter bmbouter left a comment

Choose a reason for hiding this comment

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

This looks good to me, but I want to also see the final from @daviddavis if that's ok.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants