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

Fix remove_missing option and unnecessary downloads for forge importer #255

Merged
merged 1 commit into from Mar 10, 2017

Conversation

goosemania
Copy link
Member

Fix remove_missing option for the forge and directory importers.
Do not re-download units if they are in DB and on a disk for the forge importer.

closes #2606
https://pulp.plan.io/issues/2606

@mention-bot
Copy link

@goosemania, thanks for your PR! By analyzing the history of the files in this pull request, we identified @mhrivnak, @jortel and @bmbouter to be potential reviewers.

@ipanova ipanova self-assigned this Mar 9, 2017
@@ -120,7 +132,7 @@ def run(self, **kwargs):

# Remove the importer keys from kwargs so they don't get added to the repo config
for key in importer_config:
kwargs.pop(key, None)
kwargs.pop(key.replace('_', '-'), None)
Copy link
Member

Choose a reason for hiding this comment

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

good catch

@@ -304,7 +305,7 @@ def _remove_missing(self, existing_module_ids_by_key, remote_unit_keys):
keys_to_remove = list(set(existing_module_ids_by_key.keys()) - set(remote_unit_keys))
doomed_ids = [existing_module_ids_by_key[key] for key in keys_to_remove]
doomed_module_iterator = Module.objects.in_bulk(doomed_ids).itervalues()
repo_controller.disassociate_units(self.repo, doomed_module_iterator)
repo_controller.disassociate_units(self.repo.repo_obj, doomed_module_iterator)
Copy link
Member

Choose a reason for hiding this comment

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

Was this part of the plugin completely broken? It seems that way to me.

Copy link
Member Author

Choose a reason for hiding this comment

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

@dkliban , yes, it was.

"""
return list(set(metadata_unit_keys) - set(existing_unit_keys))
model = plugin_api.get_unit_model_by_id(constants.TYPE_PUPPET_MODULE)
Copy link
Member

Choose a reason for hiding this comment

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

i guess there is an issue somewhere around here because it is not able to correctly detect what to download.

create a repo and set query=stdlib. It will not download any modules, meanwhile on master branch it will fetch and import into the repo 19 modules. Alos this outpit https://forge.puppet.com/modules.json?q=stdlib proves that there are modules on puppetforge meeting the query. There was performed an orphan removal before the repo creation.

Copy link
Member Author

Choose a reason for hiding this comment

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

@ipanova, thanks! Fixed.

@ipanova
Copy link
Member

ipanova commented Mar 9, 2017

This was my testing approach pulp/pulp-smash#578

Fix remove_missing option for the forge and directory importers.
Do not re-download units if they are in DB and on a disk for the forge importer.

closes #2606
https://pulp.plan.io/issues/2606
for unit in units_controller.find_units(unit_generator):
file_exists = unit._storage_path is not None and os.path.isfile(unit._storage_path)
if file_exists:
if unit.unit_key_as_named_tuple not in existing:
Copy link
Member

Choose a reason for hiding this comment

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

it is purely matter of personal preference but i would move line 341 to right after condition on line 338 happens, it is more readable imho

@ipanova
Copy link
Member

ipanova commented Mar 10, 2017

@goosemania, fyi, i've tested the sync with directory as well with remove-missing option.

Copy link
Member

@dkliban dkliban left a comment

Choose a reason for hiding this comment

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

Thank you Таня!

@goosemania goosemania merged commit 034ef74 into pulp:2.12-dev Mar 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
4 participants