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
Add Repository.finalize_new_version #369
Conversation
f73c932
to
a985533
Compare
e4c6b80
to
b90bd64
Compare
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.
Thank you!
3ae4c55
to
ea94c1f
Compare
… and sync. Also removes one_shot_upload as it's not used anymore. Required PR: pulp/pulpcore#369 https://pulp.plan.io/issues/3541 re #3541
… and sync. Also removes one_shot_upload as it's not used anymore. Required PR: pulp/pulpcore#369 https://pulp.plan.io/issues/3541 re #3541
… and sync. Also removes one_shot_upload as it's not used anymore. Required PR: pulp/pulpcore#369 https://pulp.plan.io/issues/3541 re #3541
… and sync. Also removes one_shot_upload as it's not used anymore. Required PR: pulp/pulpcore#369 https://pulp.plan.io/issues/3541 re #3541
Required PR: pulp/pulpcore#369 closes #3541
Required PR: pulp/pulpcore#369 closes #3541
Required PR: pulp/pulpcore#369 closes #3541
|
@gmbnomis and @mdellweg I talked w/ @dralley, @daviddavis, @dkliban, and @goosemania; here is what we came up with:
I'm going to add this in as an additional commit to demonstrate the idea with the hopes of merging it. What do you think of this? Will this work your your needs? |
|
Does |
|
Yes I'll use |
|
If i read correctly, the suggestion now is to make the validitator an instance method of repository, and any possible parameter to it a field on said repository. This is exactly, what i thought it to be, as i see this method to put some common (for all operations) constraints on the resulting repository versions. |
And i would argue here, that they belong to the repository to ensure the same constraints for all (future) versions independently of the operation performed. |
Required PR: pulp/pulpcore#369 closes #3541
49540c9
to
e222024
Compare
| """ | ||
| query_for_repo_duplicates_by_type = defaultdict(lambda: Q()) | ||
| for item in repository_version.added(): | ||
| detail_item = item.cast() |
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.
Future performance improvement to take note of
- Sort these into groups based on their
pulp_typewhich is present on the master Content model. - Look up the detail content models that represent the
pulp_typestrings - Query the detail content models directly, in bulk, provided a list of PKs, instead of
cast()individually - Then within each type group check for duplicates
Or, alternately, each repository can list all of the content types it supports and step 2 can be skipped, and we can add an extra layer of protection around making sure you can't have e.g. file content in an RPM repository which we can't easily or centrally guarantee otherwise.
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.
Thanks for filing @dralley https://pulp.plan.io/issues/5701
pulpcore/plugin/actions.py
Outdated
| if 'remove_content_units' in request.data: | ||
| for url in request.data['remove_content_units']: | ||
| if url == '*': | ||
| remove_content_units.append(url) |
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.
Does * mean remove everything?
Should we do
if url == "*":
remove_content_units=["*"]
breakThere 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 agree with the break change because when at least one remove_content_units specifies to remove all, additional remove_content_units params specified are unproductive.
I am going to leave remove_content_units=[url] because it DRYs the definition of *.
pulpcore/plugin/actions.py
Outdated
| add_content_units = [] | ||
| remove_content_units = [] | ||
| repository = Repository.objects.get(pk=pk) | ||
| repository.cast() |
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.
Is this detail_repository = repository.cast() ?
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 this line is unproductive since the result is never saved. It's also not needed since we only use the pk and that's the same for both master and detail. Also I verified that when the line is removed a repository PATCH and a later 'modify' call both use the same reserved_resource so they will be serialized correctly. I'm pushing the change that removes this line now.
Also removes one_shot_upload as it's not used anymore. Required PR: pulp/pulpcore#369 closes #4898 https://pulp.plan.io/issues/4898
Also removes one_shot_upload as it's not used anymore. Required PR: pulp/pulpcore#369 closes #4898 https://pulp.plan.io/issues/4898
Required PR: pulp/pulpcore#369 closes #3541
Required PR: pulp/pulpcore#369 closes #3541
b2e39b5
to
d681090
Compare
This PR adds a central place for plugin writers to put validation and content modification code. * `RepositoryVersion.__exit__` calls `finalize_new_version` * Moves the `/modify/` endpoint to `pulpcore.plugin.actions` as a mixin named `ModifyRepositoryActionMixin`. * Renames `Repository.repo_key` to `Repository.repo_key_fields`. * Remove the `RemoveDuplicates` stage for plugin writers to instead use `Repository.finalize_new_version` * Remove the implicit usage of `RemoveDuplicates` from `RepositoryVerison.add_content` and `RepositoryVersion.remove_content`. * Make the `RemoveDuplicates` available as `pulpcore.plugin.repo_version_utils.remove_duplicates`. As an unrelated change, it also replaces the the `>>>` python codeblocks in various docblocks with python codeblock using `::` and indention. Required PR: pulp/pulp_file#307 https://pulp.plan.io/issues/3541 re pulp#3541
| @@ -0,0 +1,4 @@ | |||
| Renamed the Content.repo_key to be Content.repo_unit_key. Also the calling of `RemoveDuplicates` | |||
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.
Did you mean Content.repo_key_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.
And also RemoveDuplicates is now remove_duplicates
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 but I want to fix in separate PR because I need to unblock the other Prs with the skiptest in this one. Is that ok?
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.
sure
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.
followup PR here: #382
| a `repo_key_fields` attribute with the field names to be compared. If all `repo_key_fields` | ||
| contain the same value for two content units, they are considered "repository duplicates". | ||
|
|
||
| After instantiating `RemoveDuplicates` call it with the `run()` method and pass in the |
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.
remove_duplicates
And there is no longer run since it's just a function
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.
Followup PR here: #382
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.
Thanks!
Just a couple of docs comments which can be addressed in a follow-up PR
|
Thank you! I will make the followup PR now and ensure it's merged pre-branch and pre-RC8. |
Adapt to pulp/pulpcore#369 (Repository /modify mixin) and pulp/pulpcore#380 (Don't create a new repository version if no content was added or removed). No functional changes.
Adapt to pulp/pulpcore#369 (Repository /modify mixin) and pulp/pulpcore#380 (Don't create a new repository version if no content was added or removed). No functional changes.
This PR adds a central place for plugin writers to put validation and
content modification code.
RepositoryVersion.__exit__callsfinalize_new_versionMoves the
/modify/endpoint topulpcore.plugin.actionsas a mixinnamed
ModifyRepositoryActionMixin.Renames
Repository.repo_keytoRepository.repo_key_fields.Remove the
RemoveDuplicatesstage for plugin writers to instead useRepository.finalize_new_versionRemove the implicit usage of
RemoveDuplicatesfromRepositoryVerison.add_contentandRepositoryVersion.remove_content.Make the
RemoveDuplicatesavailable aspulpcore.plugin.repo_version_utils.remove_duplicates.As an unrelated change, it also replaces the the
>>>pythoncodeblocks in various docblocks with python codeblock using
::andindention.
Required PR: pulp/pulp_file#307
https://pulp.plan.io/issues/3541
re #3541