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

Adjust dispatch calls to core>=3.15 interface #659

Merged
merged 1 commit into from
Oct 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES/9483.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Changed the use of ``dispatch`` to match the signature from pulpcore>=3.15.
2 changes: 1 addition & 1 deletion pulp_ansible/app/galaxy/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ def _dispatch_import_collection_task(self, temp_file_pk, repository=None, **kwar
locks.append(repository)
kwargs["repository_pk"] = repository.pk

return dispatch(import_collection, locks, kwargs=kwargs)
return dispatch(import_collection, exclusive_resources=locks, kwargs=kwargs)
2 changes: 1 addition & 1 deletion pulp_ansible/app/galaxy/v3/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ def update(self, request, *args, **kwargs):

task = dispatch(
add_and_remove,
[repo_version.repository],
exclusive_resources=[repo_version.repository],
kwargs={
"repository_pk": repo_version.repository.pk,
"base_version_pk": repo_version.pk,
Expand Down
4 changes: 2 additions & 2 deletions pulp_ansible/app/tasks/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,13 @@ def promote_content(repos_per_task, num_repos_to_update):
locks.append(repo)
if len(repos_to_dispatch) == repos_per_task:
task_args = (random_collection_version.pk, repos_to_dispatch)
dispatch(add_content_to_repositories, locks, args=task_args)
dispatch(add_content_to_repositories, exclusive_resources=locks, args=task_args)
repos_to_dispatch = []
locks = []

if repos_to_dispatch:
task_args = (random_collection_version.pk, repos_to_dispatch)
dispatch(add_content_to_repositories, locks, args=task_args)
dispatch(add_content_to_repositories, exclusive_resources=locks, args=task_args)


def add_content_to_repositories(collection_version_pk, repositories_pks):
Expand Down
6 changes: 3 additions & 3 deletions pulp_ansible/app/viewsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ def sync(self, request, pk):

result = dispatch(
sync_func,
[repository, remote],
exclusive_resources=[repository, remote],
Copy link
Member

Choose a reason for hiding this comment

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

remote can be among shared_resources.

Copy link
Member Author

Choose a reason for hiding this comment

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

I drafted this to be the minimal change to unbreak master, but i can add shared_resources if desired. Not sure if it were a feature though.

kwargs=sync_kwargs,
)
return OperationPostponedResponse(result, request)
Expand Down Expand Up @@ -304,7 +304,7 @@ def update(self, request, pk, **kwargs):
lock.extend(repos)
async_result = dispatch(
update_collection_remote,
lock,
exclusive_resources=lock,
args=(pk,),
kwargs={"data": request.data, "partial": partial},
)
Expand Down Expand Up @@ -401,7 +401,7 @@ def create(self, request):

config, repos = self._process_config(config)

async_result = dispatch(copy_content, repos, args=[config], kwargs={})
async_result = dispatch(copy_content, exclusive_resources=repos, args=[config], kwargs={})
Copy link
Member

Choose a reason for hiding this comment

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

since this is a content copy operation, the source repo can be among shared_resources, _process_config should be updated so it returns 2 lists of repos.

return OperationPostponedResponse(async_result, request)

def _process_config(self, config):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@
while repos_to_still_make > 0:
if repos_to_still_make >= args.batch_size[0]:
task_args = (args.batch_size[0], num_repo_versions_per_repo, collection_percentage)
async_result = dispatch(create_repos_with_collections, [], args=task_args)
async_result = dispatch(create_repos_with_collections, args=task_args)
print("Dispatched task with {} repositories".format(args.batch_size[0]))
repos_to_still_make = repos_to_still_make - args.batch_size[0]
else:
task_args = (repos_to_still_make, num_repo_versions_per_repo, collection_percentage)
async_result = dispatch(create_repos_with_collections, [], args=task_args)
async_result = dispatch(create_repos_with_collections, args=task_args)
print("Dispatched task with {} repositories".format(repos_to_still_make))
repos_to_still_make = 0
2 changes: 1 addition & 1 deletion pulp_ansible/tests/performance/fast_load_collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@
for file in files:
if file.endswith(".tar.gz"):
async_result = dispatch(
import_collection_from_path, [], args=(os.path.join(root, file),)
import_collection_from_path, args=(os.path.join(root, file),)
)
2 changes: 1 addition & 1 deletion pulp_ansible/tests/performance/generate_collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@
"collection_n": args.collections_per_namespace[0],
"versions_per_collection": args.versions_per_collection[0],
}
async_result = dispatch(create_namespace, [], args=(args.base_path[0],), kwargs=kwargs)
async_result = dispatch(create_namespace, args=(args.base_path[0],), kwargs=kwargs)
2 changes: 1 addition & 1 deletion pulp_ansible/tests/performance/promote.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@

if __name__ == "__main__":
task_args = (args.repos_per_task[0], args.num_repos_to_update[0])
dispatch(promote_content, [], args=task_args)
dispatch(promote_content, args=task_args)