-
Notifications
You must be signed in to change notification settings - Fork 107
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
Conversation
Required PR: pulp/pulpcore#117 Ref #4785
Required PR: pulp/pulpcore#117 ref #4785
Addresses the base URL part of issue #19 Required PR: pulp/pulpcore#117 Required PR: pulp/pulpcore-plugin#95
Addresses the base URL part of issue #19 Required PR: pulp/pulpcore#117 Required PR: pulp/pulpcore-plugin#95
b7fdbc6
to
1661837
Compare
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
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
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
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
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
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
1661837
to
a7768f2
Compare
a7768f2
to
d52fc71
Compare
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
Required PR: pulp/pulpcore#117 Required PR: pulp/pulpcore-plugin#95 Required PR: pulp/pulp_file#217 Required PR: pulp/pulp-smash#1205 ref #4785 https://pulp.plan.io/issues/4785
Required PR: pulp/pulpcore#117 Required PR: pulp/pulpcore-plugin#95 Required PR: pulp/pulp_file#217 Required PR: pulp/pulp-smash#1205 ref #4785 https://pulp.plan.io/issues/4785
d52fc71
to
830bc99
Compare
Required PR: pulp/pulpcore#117 Required PR: pulp/pulpcore-plugin#95 Required PR: pulp/pulp_file#217 Required PR: pulp/pulp-smash#1205 ref #4785 https://pulp.plan.io/issues/4785
830bc99
to
affb99f
Compare
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
affb99f
to
0fe3cbd
Compare
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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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/
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:
We could introduce a content app name field in the distribution. Then, we would have: 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) |
@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, (_( |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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.
There was a problem hiding this 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! 🥇 👍 🌴 🍊
Required PR: pulp/pulpcore#117 Required PR: pulp/pulpcore-plugin#95 Required PR: pulp/pulp_file#217 Required PR: pulp/pulp-smash#1205 ref #4785 https://pulp.plan.io/issues/4785
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
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