Red Hat Bugzilla – 1585408 – SQL error when adding some puppet modules to CV: PG::UniqueViolation: ERROR: duplicate key value violates unique constraint "katello_cv_puppet_modules_name"
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.
SQL error when adding some puppet modules to CV: PG::UniqueViolation: ERROR: duplicate key value violates unique constraint "katello_cv_puppet_modules_name"
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.
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.
```
Comment 5Satellite Program
2018-06-14 18:24:38 UTC
Upstream bug assigned to stbenjam
Comment 6Satellite Program
2018-06-14 18:24:43 UTC
Upstream bug assigned to stbenjam
Comment 7Satellite Program
2018-06-15 16:24:25 UTC
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
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