-
Notifications
You must be signed in to change notification settings - Fork 54
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 is_highest logic on resyncs #1548
Conversation
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.
Content in Pulp is meant to be immutable.
is_highest
does not even look right to me when a collection version is in two different repositories.
# Ensure that this collection_version doesn't have is_highest improperly set | ||
if collection_version.is_highest: | ||
collection_version.is_highest = False | ||
if save: |
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 this save trying to tell us?
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 do you mean? I explained the bug in the issue. This if save
is to just be consistent with how the function can be called.
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 see if <condition> or save :
in other places of this function. I'm really confused whether this flag should tell us to always save the unit, or whether it allows us to.
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.
That previous condition is for an odd scenario where none of the collection versions for a collection had is_highest
set. The reason why save
is conditional is for an optimization since this function is called to update a collection version before it is saved in the CollectionSaver
stage or the import_collection
task, there is no point in saving the collection twice in a row.
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 assume this fixes the issue at hand then.
Can you add some of the explanations as comments to the code, please?
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 really not happy, we ignore that content must be immutable.
What happens if we remove the uniqueness constraint on the is_latest
and specifically allow it to be a bit fuzzy at times? A mutable field within a uniqueness constraint seems to be additionally painful. Also what is true for a collection in one repository version does not necessarily be as true in another. Could we move that information elsewhere?
# Ensure that this collection_version doesn't have is_highest improperly set | ||
if collection_version.is_highest: | ||
collection_version.is_highest = False | ||
if save: |
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 assume this fixes the issue at hand then.
Can you add some of the explanations as comments to the code, please?
This is how it has been for years... Yes we should refactor it to better be align with Pulp philosophy, not sure how though. For AAH it has been fine to have this field calculated on the model since they only cared about one repository, but with the introduction of repo management it might be time to look at this field again. I think we should file an issue for this and put the design discussion there. |
f238686
to
1334235
Compare
Backport to 0.17: 💚 backport PR created✅ Backport PR branch: Backported as #1552 🤖 @patchback |
Backport to 0.16: 💔 cherry-picking failed — conflicts found❌ Failed to cleanly apply 6f7f087 on top of patchback/backports/0.16/6f7f087aca62923870d7d408bdcdd25fa63d39d7/pr-1548 Backporting merged PR #1548 into main
🤖 @patchback |
Manual cherry-pick: |
fixes: #1547