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
Do not use pre-release versions as is_highest unless no stable version exists. #1392
Conversation
…ns exist. fixes: pulp#1391 Signed-off-by: James Tanner <tanner.jc@gmail.com>
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.
Just one last question before i think we are ready to merge.
@@ -421,7 +421,7 @@ def _get_backend_storage_url(artifact_file): | |||
return url | |||
|
|||
|
|||
def _update_highest_version(collection_version): | |||
def _update_highest_version(collection_version, save=False): |
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 fail to see the use for save=False
. Don't we always want to update when we go to the lengths of running this function at 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.
I addressed this in a previous review comment. @gerrod3 wants to retain the behavior where the function caller does the saving when possible to reduce duplicate saving.
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.
We call this method in two places:
pulp_ansible/pulp_ansible/app/tasks/collections.py
Lines 347 to 349 in 3543bc9
_update_highest_version(collection_version) collection_version.save() # Save the FK updates pulp_ansible/pulp_ansible/app/tasks/upload.py
Lines 84 to 87 in 357cdca
_update_highest_version(collection_version) if origin_repository is not None: collection_version.repository = origin_repository collection_version.save()
In both cases we save the incoming collection_version after calling the method.
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, so we are actually preventing a superfluous save call.
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.
Last changes required (I think). Makes it a bit more performant. https://docs.djangoproject.com/en/3.2/ref/models/instances/#specifying-which-fields-to-save
@@ -421,7 +421,7 @@ def _get_backend_storage_url(artifact_file): | |||
return url | |||
|
|||
|
|||
def _update_highest_version(collection_version): | |||
def _update_highest_version(collection_version, save=False): |
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, so we are actually preventing a superfluous save call.
fixes: #1391