[AAP-73644 ] Fix adjust_roles to use update_or_create for LOCKED_ROLES#7757
Open
jerabekjiri wants to merge 2 commits into
Open
[AAP-73644 ] Fix adjust_roles to use update_or_create for LOCKED_ROLES#7757jerabekjiri wants to merge 2 commits into
adjust_roles to use update_or_create for LOCKED_ROLES#7757jerabekjiri wants to merge 2 commits into
Conversation
3e78c9f to
c3e6e9a
Compare
Closes: AAP-73644 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
c3e6e9a to
245d576
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes: AAP-73644
Hub
pulpcore-manager migratefails withsycopg.errors.UniqueViolation: duplicate key value violates unique constraint "core_role_name_key"when locked roles already exist in the database withlocked=False. This happens becauseget_or_createlooks up by both name andlocked=True, misses the existing role, and then tries to insert a duplicate.How to reproduce locally
pulpcore-manager shell_pluspulpcore-manager migrateUniqueViolationabove because get_or_create(name=..., locked=True) doesn't findthe existing role (it has locked=False) and tries to insert a duplicate. The crash happens in pulpcore/app/apps.py during the post_migrate signal when adjust_roles runs.
Fix
Switched to
update_or_createwith lookup by name only so that existing roles get correctedlocked=Trueinstead of crashing.📜 Checklist
See: Pull Request Walkthrough