Project

General

Profile

Bug #9815

HostGroup Clone doesn't work if the hostgroup has parameters

Added by Tommy McNeely over 4 years ago. Updated about 1 year ago.

Status:
Closed
Priority:
Normal
Category:
Host groups
Target version:
Difficulty:
Triaged:
Bugzilla link:
Team Backlog:
Fixed in Releases:
Found in Releases:

Description

I ran into an issue trying to clone a HostGroup in Foreman 1.7.3. it goes to a 404 page. Here is a demo video: https://docs.google.com/a/lark-it.com/file/d/0Bw8r1SqN6Yt_TGVDa0YxQkFGY3c/edit?usp=drivesdk

It seems to only affect hostgroups that have parameters. I am able to clone hostgroups that do not have any parameters, even if they are nested several levels deep, with parent parameters.

Here is the difference between a "create" operation and a "clone" operation in logs:

  • Create {code}
    Started POST "/hostgroups" for 67.176.44.123 at 2015-03-18 12:55:11 -0400
    Processing by HostgroupsController#create as HTML
    Parameters: {"utf8"=>"✓", "authenticity_token"=>"(redacted)", "hostgroup"=>{"parent_id"=>"", "name"=>"CloneMe", "environment_id"=>"2", "compute_profile_id"=>"1", "puppet_ca_proxy_id"=>"1", "puppet_proxy_id"=>"1", "puppetclass_ids"=>[""], "domain_id"=>"2", "realm_id"=>"1", "architecture_id"=>"1", "operatingsystem_id"=>"1", "medium_id"=>"1", "ptable_id"=>"7", "root_pass"=>"[FILTERED]", "group_parameters_attributes"=>{"1426697695990"=>{"name"=>"MyParameter", "value"=>"[FILTERED]", "hidden_value"=>"[FILTERED]", "_destroy"=>"false", "nested"=>""}}, "organization_ids"=>[""], "id"=>""}, "commit"=>"Submit"}
    Redirected to https://foreman.lark-it.com/hostgroups
    Completed 302 Found in 174ms (ActiveRecord: 34.6ms) {code}

*Clone {code}
Started POST "/hostgroups" for 67.176.44.123 at 2015-03-18 12:55:45 -0400
Processing by HostgroupsController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"(redacted)", "hostgroup"=>{"parent_id"=>"", "name"=>"ClonedGroup", "environment_id"=>"2", "compute_profile_id"=>"1", "puppet_ca_proxy_id"=>"1", "puppet_proxy_id"=>"1", "puppetclass_ids"=>[""], "domain_id"=>"2", "realm_id"=>"1", "architecture_id"=>"1", "operatingsystem_id"=>"1", "medium_id"=>"1", "ptable_id"=>"7", "root_pass"=>"[FILTERED]", "group_parameters_attributes"=>{"0"=>{"name"=>"MyParameter", "value"=>"[FILTERED]", "hidden_value"=>"[FILTERED]", "_destroy"=>"false", "nested"=>"", "id"=>"22"}}, "organization_ids"=>[""], "id"=>""}, "commit"=>"Submit"}
Rendered common/404.html.erb within layouts/application (3.3ms)
Rendered layouts/base.html.erb (3.4ms)
Completed 404 Not Found in 53ms (Views: 10.7ms | ActiveRecord: 5.6ms) {code}

The difference appears to be: {code}
"group_parameters_attributes"=>{"0"=>{"name"=>"MyParameter", "value"=>"[FILTERED]", "hidden_value"=>"[FILTERED]", "_destroy"=>"false", "nested"=>"", "id"=>"22"}} {code}

Hope this helps ;)


Related issues

Related to Foreman - Bug #8521: Host clone should include associated Puppet classesClosed2014-11-26
Related to Foreman - Bug #9820: API: Hostgroup Clone does not clone parametersClosed2015-03-18
Related to Foreman - Bug #12566: New Host API changed host_parameters_attributes behaviorClosed2015-11-23
Has duplicate Foreman - Bug #11218: Cloning hostgroup containing (a/any) parameter failsDuplicate2015-07-27
Has duplicate Foreman - Bug #11404: UI throws 'Host group Not Found' on cloning a existing hostgroupDuplicate2015-08-18

Associated revisions

Revision 04fa19de (diff)
Added by Christine Fouant almost 4 years ago

fixes #9815 - Corrects group parameter cloning on hostgroup

History

#1 Updated by Tommy McNeely over 4 years ago

Sorry, my formatting above sucked, been using JIRA too much :)

The key difference is the `"id"=>"22"` in the `group_parameters_attributes` section.

#2 Updated by Tommy McNeely over 4 years ago

This may be as simple as changing "param.clone" to "param.dup"

https://gist.github.com/ericsaboia/994614

#3 Updated by Tommy McNeely over 4 years ago

Confirmed in "develop" (1.8) .. and in debug mode, it also confirms that its crapping out on the group_parameter.

2015-03-18 11:56:46 [I] Started POST "/hostgroups" for 10.250.251.1 at 2015-03-18 11:56:46 -0600
2015-03-18 11:56:46 [I] Processing by HostgroupsController#create as HTML
2015-03-18 11:56:46 [I]   Parameters: {"utf8"=>"✓", "authenticity_token"=>"Y5APgFaxM+tTlwuDK7Dk7J9c4PG1EThzagazKfMX8V0=", "hostgroup"=>{"parent_id"=>"", "name"=>"Cloned", "environment_id"=>"1", "compute_profile_id"=>"1", "puppetclass_ids"=>[""], "domain_id"=>"1", "realm_id"=>"", "architecture_id"=>"1", "operatingsystem_id"=>"1", "medium_id"=>"1", "ptable_id"=>"7", "root_pass"=>"[FILTERED]", "group_parameters_attributes"=>{"0"=>{"name"=>"TestParam1", "value"=>"[FILTERED]", "hidden_value"=>"[FILTERED]", "_destroy"=>"false", "nested"=>"", "id"=>"1"}}, "location_ids"=>["", "1"], "organization_ids"=>["", "2"], "id"=>""}, "commit"=>"Submit"}
2015-03-18 11:56:46 [D]   User Load (0.1ms)  SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1  [["id", 3]]
2015-03-18 11:56:46 [D] Setting current user thread-local variable to admin
2015-03-18 11:56:46 [D]    (0.1ms)  SELECT COUNT(*) FROM "taxonomies" WHERE "taxonomies"."type" IN ('Organization')
2015-03-18 11:56:46 [D] Setting current organization thread-local variable to none
2015-03-18 11:56:46 [D]    (0.1ms)  SELECT COUNT(*) FROM "taxonomies" WHERE "taxonomies"."type" IN ('Location')
2015-03-18 11:56:46 [D] Setting current location thread-local variable to none
2015-03-18 11:56:46 [D]   AuthSource Load (0.4ms)  SELECT "auth_sources".* FROM "auth_sources" WHERE "auth_sources"."id" = 1 LIMIT 1
2015-03-18 11:56:46 [D]    (0.1ms)  SELECT id FROM "taxonomies" WHERE "taxonomies"."type" IN ('Location') LIMIT 1
2015-03-18 11:56:46 [D]    (0.1ms)  SELECT id FROM "taxonomies" WHERE "taxonomies"."type" IN ('Organization') LIMIT 1
2015-03-18 11:56:46 [D]   Taxonomy Load (0.1ms)  SELECT "taxonomies".* FROM "taxonomies" WHERE "taxonomies"."id" = ? ORDER BY title LIMIT 1  [["id", 1]]
2015-03-18 11:56:46 [D]   Taxonomy Load (0.1ms)  SELECT "taxonomies".* FROM "taxonomies" WHERE "taxonomies"."id" = ? ORDER BY title LIMIT 1  [["id", 2]]
2015-03-18 11:56:46 [D]   GroupParameter Load (0.2ms)  SELECT "parameters".* FROM "parameters" WHERE "parameters"."type" IN ('GroupParameter') AND "parameters"."reference_id" IS NULL AND "parameters"."id" IN (1) ORDER BY parameters.name
2015-03-18 11:56:46 [D] not found: Couldn't find GroupParameter with ID=1 for Hostgroup with ID=
2015-03-18 11:56:46 [I]   Rendered common/404.html.erb within layouts/application (1.8ms)
2015-03-18 11:56:46 [I]   Rendered layouts/base.html.erb (112.9ms)
2015-03-18 11:56:46 [I] Completed 404 Not Found in 135.5ms (Views: 117.5ms | ActiveRecord: 1.4ms)

#4 Updated by The Foreman Bot over 4 years ago

  • Status changed from New to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/2243 added
  • Pull request deleted ()

#5 Updated by Tommy McNeely over 4 years ago

  • Blocked by Bug #9820: API: Hostgroup Clone does not clone parameters added

#6 Updated by Dominic Cleal about 4 years ago

  • Has duplicate Bug #11218: Cloning hostgroup containing (a/any) parameter fails added

#7 Updated by Dominic Cleal about 4 years ago

  • Has duplicate Bug #11404: UI throws 'Host group Not Found' on cloning a existing hostgroup added

#8 Updated by Dominic Cleal about 4 years ago

  • Pull request https://github.com/theforeman/foreman/pull/2563 added
  • Pull request deleted (https://github.com/theforeman/foreman/pull/2243)

#9 Updated by Dominic Cleal about 4 years ago

  • Related to Bug #8521: Host clone should include associated Puppet classes added

#10 Updated by Marek Hulán almost 4 years ago

  • Pull request https://github.com/theforeman/foreman/pull/2661 added
  • Pull request deleted (https://github.com/theforeman/foreman/pull/2563)

#11 Updated by Christine Fouant almost 4 years ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100

#12 Updated by Dominic Cleal almost 4 years ago

  • Blocked by deleted (Bug #9820: API: Hostgroup Clone does not clone parameters)

#13 Updated by Dominic Cleal almost 4 years ago

  • Assignee set to Christine Fouant
  • Legacy Backlogs Release (now unused) set to 63

#14 Updated by Dominic Cleal almost 4 years ago

  • Related to Bug #9820: API: Hostgroup Clone does not clone parameters added

#15 Updated by Dominic Cleal over 3 years ago

  • Related to Bug #12566: New Host API changed host_parameters_attributes behavior added

Also available in: Atom PDF