Note: This bug is displayed in read-only format because
the product is no longer active in Red Hat Bugzilla.
Red Hat Satellite engineering is moving the tracking of its product development work on Satellite to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "Satellite project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs will be migrated starting at the end of May. If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "Satellite project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/SAT-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Description of problem:
Having accidentally deleted a pulp repository of a custom product, an attempt to fix it via
foreman-rake katello:correct_repositories COMMIT=true
raises PG::UniqueViolation on "katello_contents_cpcid_orgid_uniq" constraint.
The reason is following:
1) the rake script spawns ::Actions::Katello::Repository::Create task (even though _katello_ repo is OK, just pulp repo is missing - but I understand the rationale)
2) the task calls in Finalize phase Actions::Katello::Product::ContentCreate (due to https://github.com/Katello/katello/blob/master/app/lib/actions/katello/product/content_create.rb#L54-L55)
3) BUT the content is already created and the above exception is raised.
Version-Release number of selected component (if applicable):
Sat 6.6.1 (but any older applies as well)
How reproducible:
100%
Steps to Reproduce:
1. Create a custom product and a repo
2. Identify pulp repo for it, e.g. via:
pulpAdminPassword=$(grep ^default_password /etc/pulp/server.conf | cut -d' ' -f2)
curl -k -u admin:$pulpAdminPassword "https://$(hostname -f)/pulp/api/v2/repositories/" | python -m json.tool > repos.json
grep -e display_name -e "\"id\"" repos.json | grep -A1 "\"YourRepoName\""
(the output will be like:
"display_name": "my_custom_repo_007",
"id": "e64c871d-a8b7-4c38-9409-ad8aeb7ce53d",
3. Delete it using repo id :
curl -k -u admin:$pulpAdminPassword -X DELETE "https://$(hostname -f)/pulp/api/v2/repositories/e64c871d-a8b7-4c38-9409-ad8aeb7ce53d/"
4. Run correct_repositories script:
foreman-rake katello:correct_repositories COMMIT=true
Actual results:
Processing Repository 1/2015: my_custom_repo_007 (1)
Repository 1 Missing
Recreating 1
rake aborted!
ForemanTasks::TaskError: Task 4eb47622-b266-4f59-b11e-12df6c40c57b: ActiveRecord::RecordNotUnique: PG::UniqueViolation: ERROR: duplicate key value violates unique constraint "katello_contents_cpcid_orgid_uniq"
DETAIL: Key (cp_content_id, organization_id)=(1578403469831, 1) already exists.
: INSERT INTO "katello_contents" ("cp_content_id", "content_type", "name", "label", "vendor", "content_url", "organization_id") VALUES ($1, $2, $3, $4, $5, $6, $7) RETURNING "id"
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-0.15.11.1/lib/foreman_tasks.rb:59:in `block in sync_task'
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-0.15.11.1/lib/foreman_tasks.rb:58:in `tap'
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-0.15.11.1/lib/foreman_tasks.rb:58:in `sync_task'
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.12.0.29/lib/katello/tasks/repository.rake:149:in `handle_missing_repo'
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.12.0.29/lib/katello/tasks/repository.rake:66:in `block (3 levels) in <top (required)>'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/relation/batches.rb:70:in `block (2 levels) in find_each'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/relation/batches.rb:70:in `each'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/relation/batches.rb:70:in `block in find_each'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/relation/batches.rb:136:in `block in find_in_batches'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/relation/batches.rb:238:in `block in in_batches'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/relation/batches.rb:222:in `loop'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/relation/batches.rb:222:in `in_batches'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/relation/batches.rb:135:in `find_in_batches'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/relation/batches.rb:69:in `find_each'
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.12.0.29/lib/katello/tasks/repository.rake:63:in `with_index'
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.12.0.29/lib/katello/tasks/repository.rake:63:in `block (2 levels) in <top (required)>'
/opt/rh/rh-ruby25/root/usr/share/gems/gems/rake-12.3.0/exe/rake:27:in `<top (required)>'
Tasks: TOP => katello:correct_repositories
(See full trace by running task with --trace)
Expected results:
No such error, repo properly created.
Additional info:
Workaround (just for the sake of running the rake script):
- in /opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.12.0.29/app/lib/actions/katello/product/content_create.rb , comment out the line 55:
# ::Katello::ProductContent.create!(product: root.product, content: content, enabled: true)
- either restart httpd and dynflow, or:
touch ~foreman/tmp/restart.txt
Upon review of our valid but aging backlog the Satellite Team has concluded that this Bugzilla does not meet the criteria for a resolution in the near term, and are planning to close in a month. This message may be a repeat of a previous update and the bug is again being considered to be closed. If you have any concerns about this, please contact your Red Hat Account team. Thank you.