Bug 1103321 - Second Host Group creation fails with no UI notification and "Failed to save: Name has already been taken" in back-end
Summary: Second Host Group creation fails with no UI notification and "Failed to save:...
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Satellite 6
Classification: Red Hat
Component: WebUI
Version: 6.0.3
Hardware: Unspecified
OS: Unspecified
unspecified
high vote
Target Milestone: Unspecified
Assignee: jmagen@redhat.com
QA Contact: Kedar Bidarkar
URL: http://projects.theforeman.org/issues...
Whiteboard:
Keywords: Triaged
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-05-30 18:03 UTC by Erik M Jacobs
Modified: 2016-04-22 16:14 UTC (History)
8 users (show)

(edit)
Clone Of:
(edit)
Last Closed: 2014-07-02 14:07:37 UTC


Attachments (Terms of Use)


External Trackers
Tracker ID Priority Status Summary Last Updated
Foreman Issue Tracker 5129 None None None 2016-04-22 16:14 UTC

Description Erik M Jacobs 2014-05-30 18:03:41 UTC
Description of problem:
If you attempt to create a Host Group (eg: SOE Web) that has the same name as a content view (eg: SOE Web), the UI won't let you submit, but shows no errors.

The Foreman /var/log/foreman/production.log shows:
Failed to save: Name has already been taken

Version-Release number of selected component (if applicable):
foreman-1.6.0.13-1.el6sat.noarch
foreman-compute-1.6.0.13-1.el6sat.noarch
foreman-gce-1.6.0.13-1.el6sat.noarch
foreman-libvirt-1.6.0.13-1.el6sat.noarch
foreman-ovirt-1.6.0.13-1.el6sat.noarch
foreman-postgresql-1.6.0.13-1.el6sat.noarch
foreman-proxy-1.6.0.6-1.el6sat.noarch
foreman-vmware-1.6.0.13-1.el6sat.noarch
katello-1.5.0-25.el6sat.noarch
katello-ca-1.0-1.noarch
katello-certs-tools-1.5.5-1.el6sat.noarch
katello-installer-0.0.44-1.el6sat.noarch
pulp-katello-plugins-0.3-1.el6sat.noarch
ruby193-rubygem-foreman_bootdisk-2.0.6-1.1.el6sat.noarch
ruby193-rubygem-foreman_discovery-1.3.0-0.1.rc2.el6sat.noarch
ruby193-rubygem-foreman_hooks-0.3.5-2.el6sat.noarch
ruby193-rubygem-foreman-redhat_access-0.0.4-1.el6sat.noarch
ruby193-rubygem-foreman-tasks-0.5.7-2.el6sat.noarch
ruby193-rubygem-katello-1.5.0-51.el6sat.noarch
rubygem-hammer_cli_foreman-0.1.1-5.el6sat.noarch
rubygem-hammer_cli_foreman_tasks-0.0.3-2.el6sat.noarch
rubygem-hammer_cli_katello-0.0.4-4.el6sat.noarch

Comment 1 Erik M Jacobs 2014-05-30 18:05:22 UTC
Actually, I just tested this with a different name, and got the same error:

  Parameters: {"utf8"=>"✓", "authenticity_token"=>"JmqrITggh5fKTK25c0uJTWHsdjeDL24FR0T5InxcnKU=", "hostgr
oup"=>{"parent_id"=>"1", "name"=>"LAMP Wordpress", "environment_id"=>"6", "puppet_ca_proxy_id"=>"", "pupp
et_proxy_id"=>"", "puppetclass_ids"=>["", "36"], "domain_id"=>"1", "subnet_id"=>"1", "realm_id"=>"", "arc
hitecture_id"=>"1", "operatingsystem_id"=>"1", "medium_id"=>"11", "ptable_id"=>"7", "root_pass"=>"[FILTER
ED]", "group_parameters_attributes"=>{"1401473078862"=>{"name"=>"kt_activation_keys", "value"=>"[FILTERED
]", "_destroy"=>"kt_activation_keys", "nested"=>""}, "1401473078878"=>{"name"=>"kt_org", "value"=>"[FILTE
RED]", "_destroy"=>"kt_org", "nested"=>""}, "1401473078889"=>{"name"=>"kt_env", "value"=>"[FILTERED]", "_
destroy"=>"kt_env", "nested"=>""}, "1401473078902"=>{"name"=>"kt_cv", "value"=>"[FILTERED]", "_destroy"=>
"kt_cv", "nested"=>""}}, "location_ids"=>["2", ""], "organization_ids"=>["1", ""]}, "kt_environment_id"=>
"ACME_Corporation/Development", "kt_activation_keys"=>"SA2-SOE,Wordpress", "commit"=>"Submit"}
Failed to save: Name has already been taken
  Rendered puppetclasses/_selectedClasses.html.erb (1.3ms)
  Rendered puppetclasses/_classes_in_groups.html.erb (0.0ms)
  Rendered puppetclasses/_classes.html.erb (179.4ms)
  Rendered puppetclasses/_class_selection.html.erb (277.5ms)
  Rendered common/_domain.html.erb (10.5ms)
  Rendered common/_domain_subnet.html.erb (17.8ms)
  Rendered common/os_selection/_architecture.html.erb (3.9ms)
  Rendered common/os_selection/_operatingsystem.html.erb (19.9ms)
  Rendered common/os_selection/_initial.html.erb (26.8ms)
  Rendered puppetclasses/_class_parameters.html.erb (29.6ms)
  Rendered puppetclasses/_classes_parameters.html.erb (42.5ms)
  Rendered common_parameters/_puppetclass_parameter.html.erb (1.6ms)
  Rendered common_parameters/_puppetclasses_parameters.html.erb (2.6ms)
  Rendered common_parameters/_parameter.html.erb (1.5ms)
  Rendered common_parameters/_parameter.html.erb (1.2ms)
  Rendered common_parameters/_parameter.html.erb (1.0ms)
  Rendered common_parameters/_parameter.html.erb (1.0ms)
  Rendered common_parameters/_parameter.html.erb (0.9ms)
  Rendered common_parameters/_parameters.html.erb (8.7ms)
  Rendered taxonomies/_loc_org_tabs.html.erb (7.1ms)
  Rendered hostgroups/_form.html.erb (592.0ms)
  Rendered hostgroups/new.html.erb within layouts/application (592.4ms)
  Rendered home/_submenu.html.erb (4.0ms)
  Rendered home/_user_dropdown.html.erb (1.2ms)
Read fragment views/tabs_and_title_records-1 (0.1ms)
  Rendered home/_topbar.html.erb (160.9ms)
  Rendered layouts/base.html.erb (161.9ms)
Completed 200 OK in 806ms (Views: 740.2ms | ActiveRecord: 21.0ms)
Processing by Katello::Api::V2::ActivationKeysController#index as */*
  Parameters: {"content_view_id"=>"4", "api_version"=>"v2", "environment_id"=>"2"}
  Rendered /opt/rh/ruby193/root/usr/share/gems/gems/katello-1.5.0/app/views/katello/api/v2/activation_key
s/index.json.rabl within katello/api/v2/layouts/collection (212.5ms)
Completed 200 OK in 231ms (Views: 210.7ms | ActiveRecord: 4.1ms)

Comment 2 Erik M Jacobs 2014-05-30 18:09:28 UTC
I did some more digging, and it appears that *any* host group creation will fail now.

Processing by HostgroupsController#create as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"JmqrITggh5fKTK25c0uJTWHsdjeDL24FR0T5InxcnKU=", "hostgroup"=>{"parent_id"=>"", "name"=>"abcdef", "environment_id"=>"2", "puppet_ca_proxy_id"=>"1", "puppet_proxy_id"=>"1", "puppetclass_ids"=>[""], "domain_id"=>"", "realm_id"=>"", "architecture_id"=>"", "root_pass"=>"[FILTERED]", "group_parameters_attributes"=>{"1401473354349"=>{"name"=>"kt_org", "value"=>"[FILTERED]", "_destroy"=>"kt_org", "nested"=>""}, "1401473354354"=>{"name"=>"kt_env", "value"=>"[FILTERED]", "_destroy"=>"kt_env", "nested"=>""}, "1401473354358"=>{"name"=>"kt_cv", "value"=>"[FILTERED]", "_destroy"=>"kt_cv", "nested"=>""}}, "location_ids"=>["", "2"], "organization_ids"=>["", "1"]}, "kt_environment_id"=>"ACME_Corporation/Library", "kt_activation_keys"=>"", "commit"=>"Submit"}
Failed to save: Name has already been taken
  Rendered puppetclasses/_selectedClasses.html.erb (0.0ms)
  Rendered puppetclasses/_classes_in_groups.html.erb (0.0ms)
  Rendered puppetclasses/_classes.html.erb (8.1ms)
  Rendered puppetclasses/_class_selection.html.erb (31.2ms)
  Rendered common/_domain.html.erb (1.8ms)
  Rendered common/_domain_subnet.html.erb (6.2ms)
  Rendered common/os_selection/_architecture.html.erb (1.4ms)
  Rendered common/os_selection/_operatingsystem.html.erb (3.5ms)
  Rendered common/os_selection/_initial.html.erb (7.2ms)
  Rendered puppetclasses/_class_parameters.html.erb (0.0ms)
  Rendered puppetclasses/_classes_parameters.html.erb (9.8ms)
  Rendered common_parameters/_puppetclass_parameter.html.erb (2.3ms)
  Rendered common_parameters/_puppetclasses_parameters.html.erb (4.2ms)
  Rendered common_parameters/_parameter.html.erb (2.8ms)
  Rendered common_parameters/_parameter.html.erb (1.4ms)
  Rendered common_parameters/_parameter.html.erb (1.4ms)
  Rendered common_parameters/_parameter.html.erb (1.1ms)
  Rendered common_parameters/_parameters.html.erb (10.8ms)
  Rendered taxonomies/_loc_org_tabs.html.erb (169.5ms)
  Rendered hostgroups/_form.html.erb (275.9ms)
  Rendered hostgroups/new.html.erb within layouts/application (276.2ms)
  Rendered home/_submenu.html.erb (3.0ms)
  Rendered home/_user_dropdown.html.erb (1.0ms)
Read fragment views/tabs_and_title_records-1 (0.1ms)
  Rendered home/_topbar.html.erb (5.1ms)
  Rendered layouts/base.html.erb (6.1ms)
Completed 200 OK in 316ms (Views: 276.7ms | ActiveRecord: 11.0ms)
Processing by Katello::Api::V2::ActivationKeysController#index as */*
  Parameters: {"content_view_id"=>"2", "api_version"=>"v2", "environment_id"=>"1"}
  Rendered /opt/rh/ruby193/root/usr/share/gems/gems/katello-1.5.0/app/views/katello/api/v2/activation_keys/index.json.rabl within katello/api/v2/layouts/collection (2.1ms)
Completed 200 OK in 18ms (Views: 3.1ms | ActiveRecord: 1.0ms)

Comment 3 Justin Sherrill 2014-05-30 18:20:11 UTC
Original downstream issue  http://projects.theforeman.org/issues/5129

Comment 5 Mike McCune 2014-05-30 19:09:34 UTC
There was a short term patch proposed here:

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

Comment 6 jmagen@redhat.com 2014-06-01 11:59:05 UTC
is this still open. I could not duplicate with Rails 3.2.8

Comment 7 Justin Sherrill 2014-06-02 00:04:52 UTC
Joseph,

I was just able to reproduce in development on rails 3.2.8.  Easiest way to reproduce:

From a fresh database:

1.  Create a host group with name 'test1' and paramter 'foo', value 'bar' 
2.  Create a 2nd host group with name 'test'2 and parameter 'foo', value 'bar2'

2 will fail.  The parameters must be set from the creation screens, (not aftewards).  

I'm not sure if any of this matters, but:

* Was using postgresql (not sqlite)
* Orgs were enabled
* locations were enabled
* An org and 'any location' was selected

Comment 8 Og Maciel 2014-06-02 13:30:24 UTC
I also saw this error this last Friday, May 30th, but I already had 2 HGs using different content views, activation keys, etc. When I tried to create a third one using the same information as one of the existing HGs... that's when I started seeing this BZ

Comment 9 Justin Sherrill 2014-06-02 14:55:29 UTC
Was able to reproduce again with just foreman.  Will upload a youtube video of reproducing.

Comment 10 jmagen@redhat.com 2014-06-02 14:58:33 UTC
ok, I haven't been able to reproduce with just foreman. Running into problems with katello though ..

Comment 11 Justin Sherrill 2014-06-02 15:09:25 UTC
showing reproduction: 

https://www.youtube.com/watch?v=6HKsIj_jDNc#t=231

Comment 12 jmagen@redhat.com 2014-06-03 09:11:26 UTC
still no success in reproducing this bug. I can't see what Justin is doing differently on the youtube demo

Comment 13 jmagen@redhat.com 2014-06-10 07:31:03 UTC
https://github.com/theforeman/foreman/pull/1504

Comment 14 Bryan Kearney 2014-06-17 12:04:10 UTC
Moving to POST since upstream bug http://projects.theforeman.org/issues/5129 has been closed

Comment 17 Kedar Bidarkar 2014-06-19 16:35:24 UTC
Steps to reproduce

Important Notes:- 
1)To reproduce this issue, takeup a newly installed setup and make sure **No previous Host Group" was ever deleted on the setup.
2)While trying on a setup where a "host Group" has been deleted this fails to reproduce.

1) Create a "Host group" with any name any value and save.
2) Create another "Host group" with any name and any value.
3) Host group creation fails.
4) Now, without canceling move to "Parameters Tab" for which the Host group creation failed to notice the "Name has been taken" message.
5) I think the above 4) point could be the clue, to figuring out the exact issue.

Workaround which works for me is:
1) Create a "Host group" 
2) creating second "Host group" fails
3) Delete the 1) "Host group" 

4) Now we don't face this issue upon creating the second "Host Group"

But not sure whether this workaround would have any side effects, but looks to be working for me, for now in creating multiple "host groups"

Comment 18 jmagen@redhat.com 2014-06-19 18:45:11 UTC
Kedar, are you sure that you have you are own a system with commit 691f0a1

Comment 19 Kedar Bidarkar 2014-06-20 09:20:00 UTC
I am not aware whether the commit exists, but I am sure that I am using SNAP10, which is said to contain the fix.

Comment 20 jmagen@redhat.com 2014-06-20 15:01:16 UTC
Can you please send me the foreman server log file or set up a reproducer system where I can debug it.

Comment 21 jmagen@redhat.com 2014-06-22 11:10:46 UTC
I checked out on gitlab branch SATELLITE-6.0.3 and don't see the changes to parameter.rb

-  after_initialize :set_priority
+  after_initialize :set_priority, :ensure_reference_nil
 
+
+  # hack fix for Rails 3.2.8. Not needed for 3.2.18.
+  def ensure_reference_nil
+    self.reference_id = nil if self.new_record? && self.reference_id == 1
+  end
+

Comment 24 Kedar Bidarkar 2014-06-26 17:50:03 UTC
verified with SNAP11

Now while creating 2nd Host group we no longer face this issue.

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


Note You need to log in before you can comment on or make changes to this bug.