Bug 1079999

Summary: Creating a new puppet environment fails
Product: Red Hat Satellite Reporter: Lukáš Hellebrandt <lhellebr>
Component: WebUIAssignee: Ohad Levy <ohadlevy>
Status: CLOSED CURRENTRELEASE QA Contact: Elyézer Rezende <erezende>
Severity: high Docs Contact:
Priority: unspecified    
Version: NightlyCC: cwelton, dcleal, erezende, jmagen, jsherril, tlestach
Target Milestone: UnspecifiedKeywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
URL: http://projects.theforeman.org/issues/4731
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-07-02 14:08:12 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Lukáš Hellebrandt 2014-03-24 13:36:09 UTC
Description of a problem:
Creating a new puppet environment fails with the following info:

Warning!
ERROR: duplicate key value violates unique constraint "environments_pkey"

PGError
ERROR: duplicate key value violates unique constraint "environments_pkey"
app/controllers/environments_controller.rb:17:in `create'
app/models/concerns/foreman/thread_session.rb:33:in `clear_thread'
lib/middleware/catch_json_parse_errors.rb:9:in `call' 


How reproducible:
Always

Steps to Reproduce:
1. Configure->Environments
2. New Puppet Environment
3. Set some unique name: "unique_5859598563525652"

Actual results:
Warning as shown in the description

Expected results:
A new puppet environment should be created

Comment 2 jmagen@redhat.com 2014-03-30 08:37:50 UTC
This can be fixed when a user runs a rake task 

rake db:sequences:reset

https://github.com/theforeman/foreman/pull/1337

I think went data is migrated to a database using COPY rather than INSERT, then the sequence is not updated.

Comment 3 Justin Sherrill 2014-03-30 16:20:45 UTC
Moving back to ASSIGNED as the rake task does not solve the issue, nor is the fix actually committed to the internal repo.

Comment 4 Dominic Cleal 2014-03-31 11:55:18 UTC
*** Bug 1082581 has been marked as a duplicate of this bug. ***

Comment 5 Bryan Kearney 2014-03-31 14:50:53 UTC
Moving to POST since upstream bug http://projects.theforeman.org/issues/4731 has been closed

Comment 7 Elyézer Rezende 2014-05-12 19:27:22 UTC
Verified:

1. Gone to Configure > Environments
2. Clicked on New Puppet Environment
3. Entered a unique name as "unique_5859598563525652"
4. Clicked on "Submit"
5. The puppet environments list is showed

Log when doing the create request:

# tail -f /var/log/{katello,pulp,candlepin,foreman*,headpin,thumbslug,signo,tomcat6}/{*.log,*.out}
Processing by EnvironmentsController#create as */*
  Parameters: {"utf8"=>"✓", "search"=>"", "authenticity_token"=>"509Y7NxFVNnJau9svXvTWFaW9lXn3hSl0/AH0GctkvA=", "environment"=>{"name"=>"unique_5859598563525653", "location_ids"=>[""], "organization_ids"=>[""]}}
Redirected to https://qetello02.usersys.redhat.com/environments
Completed 302 Found in 22ms (ActiveRecord: 10.0ms)
Processing by EnvironmentsController#index as */*
  Rendered environments/index.html.erb within layouts/application (274.4ms)
  Rendered common/_searchbar.html.erb (3.1ms)
  Rendered home/_submenu.html.erb (4.7ms)
  Rendered home/_user_dropdown.html.erb (1.6ms)
Read fragment views/tabs_and_title_records-1 (0.2ms)
  Rendered home/_topbar.html.erb (8.2ms)
  Rendered layouts/base.html.erb (9.9ms)
Completed 200 OK in 301ms (Views: 288.3ms | ActiveRecord: 2.8ms)

Environment:

# for i in `rpm -qa | grep -iE "^rubygem-hammer|^katello|^pulp|^candlepin|^foreman|^headpin|^thumbslug|^elasticsearch|ldap|signo|ruby193-rubygem-runcible" | sort`; do echo "* $i"; do
* apr-util-ldap-1.3.9-3.el6_0.1.x86_64
* candlepin-0.9.7-1.el6_5.noarch
* candlepin-scl-1-5.el6_4.noarch
* candlepin-scl-quartz-2.1.5-5.el6_4.noarch
* candlepin-scl-rhino-1.7R3-1.el6_4.noarch
* candlepin-scl-runtime-1-5.el6_4.noarch
* candlepin-selinux-0.9.7-1.el6_5.noarch
* candlepin-tomcat6-0.9.7-1.el6_5.noarch
* elasticsearch-0.90.10-4.el6sat.noarch
* foreman-1.6.0.7-1.el6sat.noarch
* foreman-compute-1.6.0.7-1.el6sat.noarch
* foreman-gce-1.6.0.7-1.el6sat.noarch
* foreman-libvirt-1.6.0.7-1.el6sat.noarch
* foreman-ovirt-1.6.0.7-1.el6sat.noarch
* foreman-postgresql-1.6.0.7-1.el6sat.noarch
* foreman-proxy-1.6.0.4-1.el6sat.noarch
* foreman-selinux-1.5.0-0.develop.el6sat.noarch
* foreman-vmware-1.6.0.7-1.el6sat.noarch
* katello-1.5.0-22.el6sat.noarch
* katello-ca-1.0-1.noarch
* katello-certs-tools-1.5.5-1.el6sat.noarch
* katello-installer-0.0.37-1.el6sat.noarch
* openldap-2.4.23-31.el6.x86_64
* pulp-katello-plugins-0.2-1.el6sat.noarch
* pulp-nodes-common-2.3.1-0.4.beta.el6sat.noarch
* pulp-nodes-parent-2.3.1-0.4.beta.el6sat.noarch
* pulp-puppet-plugins-2.3.1-0.4.beta.el6sat.noarch
* pulp-rpm-plugins-2.3.1-0.4.beta.el6sat.noarch
* pulp-selinux-2.3.1-0.4.beta.el6sat.noarch
* pulp-server-2.3.1-0.4.beta.el6sat.noarch
* python-ldap-2.3.10-1.el6.x86_64
* ruby193-rubygem-ldap_fluff-0.2.2-2.el6sat.noarch
* ruby193-rubygem-net-ldap-0.3.1-3.el6sat.noarch
* ruby193-rubygem-runcible-1.0.8-1.el6sat.noarch
* rubygem-hammer_cli-0.1.0-12.el6sat.noarch
* rubygem-hammer_cli_foreman-0.1.0-12.el6sat.noarch
* rubygem-hammer_cli_foreman_tasks-0.0.2-5.el6sat.noarch
* rubygem-hammer_cli_katello-0.0.3-22.el6sat.noarch

Comment 8 Bryan Kearney 2014-07-02 14:08:12 UTC
This was delivered with 6.0.3, which is the Satellite 6 Beta.

Comment 9 Bryan Kearney 2014-07-02 14:09:31 UTC
This was delivered in 6.0.3, the Beta version of Satellite 6.0