-
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 ansible collections import error #1987
base: main
Are you sure you want to change the base?
Conversation
Avoid "duplicate key value violates unique" error when importing ansible collections. fixes pulp#1986
instance = super().get_instance(instance_loader, row) | ||
if not instance and row["is_highest"] == "1": | ||
CollectionVersion.objects.filter( | ||
collection_id=row["collection"], is_highest=True | ||
).update(is_highest=False) | ||
|
||
return instance |
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.
Oh damn it! is_highest
really needs to go away.
Thank you for finding this.
I think however, we cannot be sure that when importing a highest collection version, that there is no higher one in the system already. Am I right, that you don't actually care about the is_highest
flag? And this seems to fix the issue with the database constraint?
I guess we could also just lift the constraint, if we realize we want to accept inconsistent data here.
Speaking with the ansible folks, they don't seem to care about that field anymore either. |
Hey, can you have a try if this magically solves the issue for you too? |
Yeah, I'm thinking backporting a fix that removes the field from the api's is probably a bad thing to do. |
Not really. As far as I see, it will run only one additional sql update query per collection.
I think it is ok if we are sure we don't need it? I am not exactly sure what is depending on this flag. I didn't check if Satellite needs it or not.
Satellite 6.15 (pulp ansible 0.20.8) and Satellite 6.16 (pulp ansible 0.21.8 i think) ? |
Thank you. (So 0.20 and 0.21 branches...) |
This is my proposal for a fix. WDYT? |
Avoid "duplicate key value violates unique" error
when importing ansible collections.
fixes #1986