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
Adds new Distribution MasterModel
#1198
Conversation
|
WARNING!!! This PR is not attached to an issue. In most cases this is not advisable. Please see our PR docs for more information about how to attach this PR to an issue. |
|
|
||
| if error: | ||
| msg = _( | ||
| "The attributes 'repository' and 'repository_version' must be used exclusively." |
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.
This doesn't necessarily need to be true. We could have the same semantics as publication-based distributions, where one particular {publication | repository_version} is being pointed to, but the existence of "repository" or not tells it whether or not to auto-distribute.
I'm not opposed to this but we should have a good justification for the different semantics.
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 this was a copy/paste from what we had. The thing really is that we can't have a distribution point to both a repository and a publication at the same time. Let me try to work on this validation to make that true instead and tell me what you think.
|
I added the overlapping cross-model base path support. I'm hand-testing it because pulpcore's CI doesn't have two plugins with heterogeneous Distribution types. This code isn't going to be around long enough to justify adding two plugins for dedicated tests. So what I did was:
|
|
I added the overlapping cross-model name uniqueness support. I'm hand-testing it because pulpcore's CI doesn't have two plugins with heterogeneous Distribution types. This code isn't going to be around long enough to justify adding two plugins for dedicated tests. So what I did was:
|
|
|
||
| Subclasses are expected to use either the ``publication`` or ``repository_version`` field, but | ||
| not both. The content app that serves content is not prepared to serve content both ways at the | ||
| same time. |
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 wish we could unify this either by attaching publication to repository version, or using publication.pass_through for "RepositoryVersionDistributions"
No action item here, just a thought.
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.
It would be nice to unify, but some plugins don't need a publication at all so I'm not sure creating an object would make sense to them. I see where you're coming from though. Either way maybe we can still unify in the future somehow.
669e4fb
to
9fda294
Compare
pulpcore==3.12 introduces a new MasterModel named `Distribution` designed to replace the `BaseDistribution` MasterModel. This PR switches the `FileDistribution` to use `Distribution`. It also ships a migration which moves the data from the `BaseDistribution` table to the `Distribution` field. Required PR: pulp/pulpcore#1198 closes #8387
4a52067
to
c9fcfdf
Compare
pulpcore==3.12 introduces a new MasterModel named `Distribution` designed to replace the `BaseDistribution` MasterModel. This PR switches the `FileDistribution` to use `Distribution`. It also ships a migration which moves the data from the `BaseDistribution` table to the `Distribution` field. Required PR: pulp/pulpcore#1198 closes #8387
pulpcore==3.12 introduces a new MasterModel named `Distribution` designed to replace the `BaseDistribution` MasterModel. This PR switches the `FileDistribution` to use `Distribution`. It also ships a migration which moves the data from the `BaseDistribution` table to the `Distribution` field. Required PR: pulp/pulpcore#1198 closes #8387
pulpcore==3.12 introduces a new MasterModel named `Distribution` designed to replace the `BaseDistribution` MasterModel. This PR switches the `FileDistribution` to use `Distribution`. It also ships a migration which moves the data from the `BaseDistribution` table to the `Distribution` field. Required PR: pulp/pulpcore#1198 closes #8387
|
|
||
|
|
||
| class DistributionRepositoryVersionSerializerMixin: | ||
| repository = DetailRelatedField( |
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 think repository needs to either be copied to DistributionPublicationSerializerMixin or it needs to become its own mixin. @daviddavis @dralley @mdellweg wdyt?
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.
Why should it be copied if it's now present and usable by both? I would think it would be part of the standard distribution serializer.
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.
Won't the help text be slightly different for publication distributions vs repo version distributions?
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 don't think it necessarily has to be. Something like The latest version of this repository will be distributed automatically is still true even if there's a publication step that happens in the middle.
It's actually not even true that the latest publication is what gets served, at least not atm.
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'm moving repository to DistributionSerializer itself. Also I have to remove these Mixins because the tests point out that we can't create a distribution that has a publication due to the error: {"publication":["Invalid hyperlink - Incorrect URL match."]}.
To work around that I tried setting:
view_name_pattern=r"publication(-.*/.*)?-detail",view_name_pattern=r"publications(-.*/.*)?-detail",view_name_pattern="publication-detail",
None of ^ worked.
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.
What is the consequence of removing the mixins, unnecessary fields?
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.
Plugins will have to copy the block now shown in the docstring of DistributionSerializer. We can't provide a de-duplicated copy.
c9fcfdf
to
48b1874
Compare
Distribution MasterModel
7aa903e
to
7351dda
Compare
092a2f0
to
6ed39c5
Compare
pulpcore==3.12 introduces a new MasterModel named `Distribution` designed to replace the `BaseDistribution` MasterModel. This PR switches the `FileDistribution` to use `Distribution`. It also ships a migration which moves the data from the `BaseDistribution` table to the `Distribution` field. Required PR: pulp/pulpcore#1198 closes #8387
|
FYI I wrote up the two issues to resolve the
|
7aae22f
to
b0db519
Compare
pulpcore==3.12 introduces a new MasterModel named `Distribution` designed to replace the `BaseDistribution` MasterModel. This PR switches the `FileDistribution` to use `Distribution`. It also ships a migration which moves the data from the `BaseDistribution` table to the `Distribution` field. Required PR: pulp/pulpcore#1198 closes #8387
| validators=[ | ||
| UniqueValidator(queryset=models.BaseDistribution.objects.all()), | ||
| UniqueValidator(queryset=models.Distribution.objects.all()), | ||
| ], |
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.
Nice!
b0db519
to
319cdb9
Compare
pulpcore==3.12 introduces a new MasterModel named `Distribution` designed to replace the `BaseDistribution` MasterModel. This PR switches the `FileDistribution` to use `Distribution`. It also ships a migration which moves the data from the `BaseDistribution` table to the `Distribution` field. Required PR: pulp/pulpcore#1198 closes #8387
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.
Looks good to me.
461decc
to
d5ce7d1
Compare
| def validate(self, data): | ||
| super().validate(data) | ||
|
|
||
| publication_in_data = "publication" in data |
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.
@dralley check this portion out, it's revised.
|
|
||
| if error: | ||
| msg = _( | ||
| "The attributes 'publication' and 'repository_version' must be used exclusively." |
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.
This is very slightly unclear I think. Maybe say something like
Only one of the attributes 'publication' and 'repository_version' may be used simultaneously.
dfa89ed
to
3142a24
Compare
Added the following new objects related to a new ``Distribution`` MasterModel: * ``pulpcore.plugin.models.Distribution`` - A new MasterModel ``Distribution`` which replaces the ``pulpcore.plugin.models.BaseDistribution``. This now contains the ``repository``, ``repository_version``, and ``publication`` fields on the MasterModel instead of on the detail models as was done with ``pulpcore.plugin.models.BaseDistribution``. * ``pulpcore.plugin.serializer.DistributionSerializer`` - A serializer plugin writers should use with the new ``pulpcore.plugin.models.Distribution``. * ``pulpcore.plugin.viewset.DistributionViewSet`` - The viewset that replaces the deprecated ``pulpcore.plugin.viewset.BaseDistributionViewSet``. * ``pulpcore.plugin.viewset.NewDistributionFilter`` - The filter that pairs with the ``Distribution`` model. closes #8384
3142a24
to
d92b6ea
Compare
| warnings.warn( | ||
| _( | ||
| "BaseDistributionSerializer is deprecated and could be removed as early as " | ||
| "pulpcore==3.13; use pulpcore.plugin.serializers.DistributionSerializer instead." |
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 would almost suggest putting a link to the Pulp File PR in here since it is a fairly "involved" migration process.
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.
Actually one of the other ones calls out the migration specifically. I'm going to merge for now if that's alright.
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.
See suggestion, otherwise LGTM
pulpcore==3.12 introduces a new MasterModel named `Distribution` designed to replace the `BaseDistribution` MasterModel. This PR switches the `FileDistribution` to use `Distribution`. It also ships a migration which moves the data from the `BaseDistribution` table to the `Distribution` field. Required PR: pulp/pulpcore#1198 closes #8387
Added the following new objects related to a new
DistributionMasterModel:
pulpcore.plugin.models.Distribution- A new MasterModelDistributionwhich replaces thepulpcore.plugin.models.BaseDistribution. This now contains therepository,repository_version, andpublicationfields onthe MasterModel instead of on the detail models as was done with
pulpcore.plugin.models.BaseDistribution.pulpcore.plugin.serializer.DistributionSerializer- A serializerplugin writers should use with the new
pulpcore.plugin.models.Distribution.pulpcore.plugin.viewset.DistributionViewSet- The viewset thatreplaces the deprecated
pulpcore.plugin.viewset.BaseDistributionViewSet.pulpcore.plugin.viewset.NewDistributionFilter- The filter thatpairs with the
Distributionmodel.closes #8384