Description of problem: SQL error when adding some puppet modules to CV: PG::UniqueViolation: ERROR: duplicate key value violates unique constraint "katello_cv_puppet_modules_name" Version-Release number of selected component (if applicable): satellite-6.4.0-9.beta.el7sat.noarch tfm-rubygem-hammer_cli-0.13.0-1.el7sat.noarch How reproducible: happens for about 20% of modules Steps to Reproduce: 1. Sync whole PuppetForge, create content view "MyCV" 2. # hammer --csv -u admin -p changeme puppet-module list \ > puppet-module-list.csv 3. # for u in $( cut -d ',' -f 5 puppet-module-list.csv ); do hammer -u admin -p changeme content-view puppet-module add \ --content-view "MyCV" --organization "Default Organization" \ --uuid "$u" done Actual results: Could not add the puppet module: PG::UniqueViolation: ERROR: duplicate key value violates unique constraint "katello_cv_puppet_modules_name" DETAIL: Key (name, content_view_id)=(sumo, 7) already exists. : INSERT INTO "katello_content_view_puppet_modules" ("content_view_id", "name", "author", "uuid", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5, $6) RETURNING "id" Expected results: Either should work or should provide some user friendly message
This feels more like server issue (database error is probably not related to CLI), moving to content views as the foreign key is probably added from there.
Created redmine issue http://projects.theforeman.org/issues/23945 from this bug
Many people can, for example, create a "motd" module. They are namespaced by author, so while "puppetlabs/motd" and "stbenjam/motd" are different modules, clients just reference 'motd' meaning they can only have 1 of that name available. In Katello, a repo can have many implementations of 'motd' but a content view can only have 1. A better reproducer than syncing all of puppet forge: 1. Create a puppet module repository 2. Upload the [puppetlabs](https://forge.puppet.com/v3/files/puppetlabs-motd-1.9.0.tar.gz) and [ericsson](https://forge.puppet.com/v3/files/ericsson-motd-1.0.3.tar.gz) implementations of 'motd', and get the UUID's with `hammer puppet-module list`: ``` 3 | motd | ericsson | 1.0.3 | 7ade8518-4314-49e9-a7ab-b6ed5cf2df59l 2 | motd | puppetlabs | 1.9.0 | 45b9a9a2-2a9e-48b1-8a2d-160ae0fec59c ``` 3. Create a content-view and try adding both modules: ``` $ hammer content-view puppet-module add --content-view-id 2 --organization-id=1 --uuid 7ade8518-4314-49e9-a7ab-b6ed5cf2df59 Puppet module added to content view $ hammer content-view puppet-module add --content-view-id 2 --organization-id=1 --uuid 45b9a9a2-2a9e-48b1-8a2d-160ae0fec59c ``` Previously you'd get this error: ``` Could not add the puppet module: PG::UniqueViolation: ERROR: duplicate key value violates unique constraint "katello_cv_puppet_modules_name" DETAIL: Key (name, content_view_id)=(motd, 2) already exists. : INSERT INTO "katello_content_view_puppet_modules" ("content_view_id", "name", "author", "uuid", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5, $6) RETURNING "id" ``` With this change, you'll get the more user friendly: ``` There is already a module named "motd" in this content view. ```
Upstream bug assigned to stbenjam
Moving this bug to POST for triage into Satellite 6 since the upstream issue http://projects.theforeman.org/issues/23945 has been resolved.
1) Create a puppet module repository 2) Upload the [puppetlabs](https://forge.puppet.com/v3/files/puppetlabs-motd-1.9.0.tar.gz) and [ericsson](https://forge.puppet.com/v3/files/ericsson-motd-1.0.3.tar.gz) implementations of 'motd', and get the UUID's with `hammer puppet-module list`: 3) ---|------|------------|---------|------------------------------------- ID | NAME | AUTHOR | VERSION | UUID ---|------|------------|---------|------------------------------------- 2 | motd | ericsson | 1.0.3 | 5d3b1bca-0138-4392-a7cf-c71c68eae748 1 | motd | puppetlabs | 1.9.0 | 555698ac-8ad3-47b0-8761-5b59161007c9 ---|------|------------|---------|------------------------------------- 4) # hammer content-view puppet-module add --content-view-id 3 --organization-id=1 --uuid 5d3b1bca-0138-4392-a7cf-c71c68eae748 Puppet module added to content view 5) # hammer content-view puppet-module add --content-view-id 3 --organization-id=1 --uuid 555698ac-8ad3-47b0-8761-5b59161007c9 Validation failed: Name There is already a module named "motd" in this content view. User friendly message was able to be generated with the above steps in sat6.4. This was verified in snap_6.4.0_22.0.
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://access.redhat.com/errata/RHSA-2018:2927