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

Switch Distribution to Master/Detail #117

Merged
merged 1 commit into from
May 8, 2019

Conversation

gmbnomis
Copy link
Contributor

@gmbnomis gmbnomis commented May 5, 2019

The models offered by pulpcore are:

  • BaseDistribution: a (non-abstract) MasterModel. This class can be used in
    plugins that don't use publications.

  • Distribution: a subclass of BaseDistribution. This class is the "standard"
    Distributor that will be subclassed by plugins using the standard content
    app.

Required PR: pulp/pulpcore-plugin#95
Required PR: pulp/pulp_file#217
Required PR: pulp/pulp-smash#1205
Required PR: pulp/pulp-certguard#20
Required PR: pulp/pulp-openapi-generator#12

ref #4785
https://pulp.plan.io/issues/4785

gmbnomis added a commit to gmbnomis/pulpcore-plugin that referenced this pull request May 5, 2019
gmbnomis added a commit to gmbnomis/pulpcore-plugin that referenced this pull request May 5, 2019
gmbnomis added a commit to pulp/pulp_cookbook that referenced this pull request May 5, 2019
Addresses the base URL part of issue #19

Required PR: pulp/pulpcore#117
Required PR: pulp/pulpcore-plugin#95
gmbnomis added a commit to pulp/pulp_cookbook that referenced this pull request May 5, 2019
Addresses the base URL part of issue #19

Required PR: pulp/pulpcore#117
Required PR: pulp/pulpcore-plugin#95
@gmbnomis gmbnomis marked this pull request as ready for review May 6, 2019 18:45
@gmbnomis gmbnomis changed the title Switch Distribution to Master/Detail RFC: Switch Distribution to Master/Detail May 6, 2019
@gmbnomis gmbnomis force-pushed the master_detail_distribution branch from b7fdbc6 to 1661837 Compare May 6, 2019 18:46
@codecov
Copy link

codecov bot commented May 6, 2019

Codecov Report

Merging #117 into master will decrease coverage by <.01%.
The diff coverage is 83.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #117      +/-   ##
==========================================
- Coverage   67.86%   67.85%   -0.01%     
==========================================
  Files          65       64       -1     
  Lines        3015     2993      -22     
==========================================
- Hits         2046     2031      -15     
+ Misses        969      962       -7
Impacted Files Coverage Δ
pulpcore/app/viewsets/base.py 93.08% <100%> (+0.51%) ⬆️
pulpcore/app/viewsets/publication.py 100% <100%> (ø) ⬆️
pulpcore/app/serializers/publication.py 97.77% <100%> (-1.12%) ⬇️
pulpcore/app/tasks/__init__.py 100% <100%> (ø) ⬆️
pulpcore/app/serializers/repository.py 100% <100%> (ø) ⬆️
pulpcore/app/models/publication.py 71.23% <100%> (-0.77%) ⬇️
pulpcore/app/viewsets/__init__.py 100% <100%> (ø) ⬆️
pulpcore/app/tasks/base.py 22.72% <22.22%> (-0.35%) ⬇️
pulpcore/app/serializers/task.py 98.07% <0%> (-1.93%) ⬇️
pulpcore/app/serializers/base.py 94.87% <0%> (-1.29%) ⬇️
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e706e7a...0fe3cbd. Read the comment docs.

gmbnomis added a commit to gmbnomis/pulp_file that referenced this pull request May 6, 2019
and update the outdated parts of the README.

Required PR: pulp/pulpcore#117
Required PR: pulp/pulpcore-plugin#95
Required PR: pulp/pulp-smash#1205
gmbnomis added a commit to gmbnomis/pulp_file that referenced this pull request May 6, 2019
and update the outdated parts of the README.

Required PR: pulp/pulpcore#117
Required PR: pulp/pulpcore-plugin#95
Required PR: pulp/pulp-smash#1205
gmbnomis added a commit to gmbnomis/pulp_file that referenced this pull request May 6, 2019
and update the outdated parts of the README.

Required PR: pulp/pulpcore#117
Required PR: pulp/pulpcore-plugin#95
Required PR: pulp/pulp-smash#1205

ref #4785
https://pulp.plan.io/issues/4785
gmbnomis added a commit to gmbnomis/pulp_file that referenced this pull request May 6, 2019
and update the outdated parts of the README.

Required PR: pulp/pulpcore#117
Required PR: pulp/pulpcore-plugin#95
Required PR: pulp/pulp-smash#1205

ref #4785
https://pulp.plan.io/issues/4785
gmbnomis added a commit to gmbnomis/pulp_file that referenced this pull request May 6, 2019
and update the outdated parts of the README.

Required PR: pulp/pulpcore#117
Required PR: pulp/pulpcore-plugin#95
Required PR: pulp/pulp-smash#1205

ref #4785
https://pulp.plan.io/issues/4785
@gmbnomis gmbnomis force-pushed the master_detail_distribution branch from 1661837 to a7768f2 Compare May 6, 2019 21:06
@gmbnomis gmbnomis requested a review from a team May 6, 2019 21:06
@gmbnomis gmbnomis force-pushed the master_detail_distribution branch from a7768f2 to d52fc71 Compare May 6, 2019 21:10
gmbnomis added a commit to gmbnomis/pulp_file that referenced this pull request May 6, 2019
and update the outdated parts of the README.

Required PR: pulp/pulpcore#117
Required PR: pulp/pulpcore-plugin#95
Required PR: pulp/pulp-smash#1205

ref #4785
https://pulp.plan.io/issues/4785
gmbnomis added a commit to gmbnomis/pulp-certguard that referenced this pull request May 6, 2019
gmbnomis added a commit to gmbnomis/pulp-certguard that referenced this pull request May 6, 2019
@gmbnomis gmbnomis force-pushed the master_detail_distribution branch from d52fc71 to 830bc99 Compare May 6, 2019 21:52
gmbnomis added a commit to gmbnomis/pulp-swagger-codegen that referenced this pull request May 7, 2019
@gmbnomis gmbnomis changed the title RFC: Switch Distribution to Master/Detail Switch Distribution to Master/Detail May 7, 2019
@gmbnomis gmbnomis force-pushed the master_detail_distribution branch from 830bc99 to affb99f Compare May 7, 2019 05:31
The models offered by pulpcore are:

- BaseDistribution: a (non-abstract) MasterModel.  This class can be used in
  plugins that don't use publications.

- Distribution: a subclass of BaseDistribution.  This class is the "standard"
  Distributor that will be subclassed by plugins using the standard content
  app.

Required PR: pulp/pulpcore-plugin#95
Required PR: pulp/pulp_file#217
Required PR: pulp/pulp-smash#1205
Required PR: pulp/pulp-certguard#20
Required PR: pulp/pulp-openapi-generator#12

ref pulp#4785
https://pulp.plan.io/issues/4785
@gmbnomis gmbnomis force-pushed the master_detail_distribution branch from affb99f to 0fe3cbd Compare May 7, 2019 06:13
@gmbnomis
Copy link
Contributor Author

gmbnomis commented May 7, 2019

@dkliban @bmbouter This looks good now from my point of view. Do you want to have a look?

@bmbouter
Copy link
Member

bmbouter commented May 7, 2019

I'm going to test this out today. Thank you @gmbnomis !

@@ -285,5 +267,10 @@ class Distribution(BaseDistribution):
the distribution. This is the publication being served by Pulp through
this relative URL path and settings.
"""

publication = models.ForeignKey(Publication, null=True, on_delete=models.SET_NULL)
Copy link
Member

Choose a reason for hiding this comment

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

In some irc/bluejeans convo prior to this PR we observed these options are mutually exclusive. Design-wise that motivates splitting Distribution into two models, class PublicationDistribution(BaseDistribution) and class RepositoryVersionDistribution(BaseDistribution).

This has two significant positive effects. 1) it prevents say pulp_file users incorrectly specifying Distribution.repository or Distribution.repository_version which won't work because it needs a Publication since there is metadata. 2) it makes the docs much clearer so that the only options shown are those that are intented for use.

Copy link
Member

Choose a reason for hiding this comment

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

I also had imagined that core would allow these PublicationDistribution and RepositoryVersionDistribution as-is (that is they specify the TYPE field). This would allow plugin writers to avoid specifying another type. What do you think about this?

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, I think we should have these as base classes. However, if plugins would use these types directly, would we have endpoints like(.../distributions/core/publication and .../distributions/core/version?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If so, you would not be able to decide what type of distribution a particular plugin supports from the API specification. If we 'force' the plugin to use a detail viewset (and derived model) it becomes clear what is supported by looking at the fields in the endpoint, e.g. distributions/file/file/

@dkliban
Copy link
Member

dkliban commented May 8, 2019

I don't see any changes in the handler for the pulp-content-app. I expected to see something related to limiting which Distributions are served by the pulp-content-app. Prior to this change the handler provided py pulpcore only looked at Distributions when matching the base_path. Now it needs to check all types of Distributions, but not others like DockerDistribution.

@gmbnomis
Copy link
Contributor Author

gmbnomis commented May 8, 2019

@dkliban

I don't see any changes in the handler for the pulp-content-app. I expected to see something related to limiting which Distributions are served by the pulp-content-app. Prior to this change the handler provided py pulpcore only looked at Distributions when matching the base_path. Now it needs to check all types of Distributions, but not others like DockerDistribution.

The idea is that Docker derives from BaseDistribution and thus, would not be visible in the default content-app. But that is probably to coarse. I think there are three use cases:

  1. pulp-content-app is sufficient for plugin
  2. plugin needs to provide some additional URLs but artifact content is still served by the pulp-content-app (although not implement this way, pulp_cookbook could fit into this category)
  3. plugin needs a different content app, the plugin's content should not be visible in the default app.

We could introduce a content app name field in the distribution. Then, we would have:
case 1. Use the default type, e.g. 'core'
case 2. Use the default type + the additional URLs are served for the specific Distribution subclass
case 3. Define a new type, e.g. 'docker'

base path overlap checks would have to be done per content app name

What do you think? (If we do this, I think we should not do it in this PR, though)

@dkliban
Copy link
Member

dkliban commented May 8, 2019

@gmbnomis The behavior you describe as it is implemented in this PR makes sense to me. I agree that we should consider allowing plugin writers to specify if their Distribution should be visible to the default content app or not

AssertionError if instance is None (which happens for creation)

"""
assert instance is not None, (_(
Copy link
Member

Choose a reason for hiding this comment

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

I've been using assert for this kind of checking for years and I like it. Recently, I've been told that some environments run their interpreters with assert checking disabled and for that reason this should be avoided. Have you ever heard of someone doing that? Do you think this is something we should be concerned with?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. I am very cautious using assert for this reason. But I think it is ok in this case: It will raise as soon someone uses create() from AsyncCreateMixin without defining a custom async_reserved_resources(). IMHO, if someone uses AsynCreateMixin without writing a test (that will blow up immediately), it's their fault ;-)

But I can change that, of course (there another us of assert in this file already)

Copy link
Member

Choose a reason for hiding this comment

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

Yeah I was more just curious. We have this elsewhere so we can leave as-is for now. We can re-approach this later.

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.

I read through all this and it looks great! I also tested it all against the pulp_file plugin and everything worked there as expected. I think we're good to merge it since you've also answered all the questions from @dkliban. As discussed on the PR there will be followon work to split the classes into distinct objects anyway.

Thank you! 🥇 👍 🌴 🍊

@bmbouter bmbouter merged commit 8fc1286 into pulp:master May 8, 2019
bmbouter pushed a commit to pulp/pulp-certguard that referenced this pull request May 8, 2019
@gmbnomis gmbnomis deleted the master_detail_distribution branch May 10, 2019 20:47
daviddavis pushed a commit to daviddavis/pulp_file that referenced this pull request May 14, 2019
and update the outdated parts of the README.

Required PR: pulp/pulpcore#117
Required PR: pulp/pulpcore-plugin#95
Required PR: pulp/pulp-smash#1205

ref #4785
https://pulp.plan.io/issues/4785
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

3 participants