Project

General

Profile

Actions

Bug #10212

closed

Foreman allows multiple nics to have the same fqdn during provisioning

Added by David Patterson almost 9 years ago. Updated almost 6 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Host creation
Target version:
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

Description

When I create a new host on vSphere 5.1.x with:

eth0: static, primary, name = servername
eth1: dhcp, managed, provision, name = servername

Foreman builds the new host just fine:

Started POST "/hosts" for 7.252.136.32 at 2015-04-20 13:12:12 -0700
2015-04-20 13:12:12 [I] Processing by HostsController#create as */*
2015-04-20 13:12:12 [I]   Parameters: {"utf8"=>"✓", "authenticity_token"=>"jIQECaYV7hZclakSTE7zrSN/TgmGeHFQxMN1TBpZO9M=", "host"=>{"name"=>"servername", "location_id"=>"1", "hostgroup_id"=>"6",
 "compute_resource_id"=>"2", "compute_profile_id"=>"4", "environment_id"=>"1", "puppet_ca_proxy_id"=>"1", "puppet_proxy_id"=>"1", "config_group_ids"=>[""], "puppetclass_ids"=>[""], "managed"=>"t",
 "progress_report_id"=>"[FILTERED]", "type"=>"Host::Managed", "compute_attributes"=>{"cpus"=>"8", "corespersocket"=>"8", "memory_mb"=>"8192", "cluster"=>"Non-Prod/RP-DEV-AG-C01", 
"path"=>"/Datacenters/RP-ApolloGlobal-POD/vm/Discovered virtual machine", "guest_id"=>"rhel6_64Guest", "hardware_version"=>"Default", "start"=>"1", "volumes_attributes"=>{"new_volumes"=>
{"_delete"=>"", "datastore"=>"Migration_Lun", "name"=>"Hard disk", "size_gb"=>"10", "thin"=>"true", "eager_zero"=>"false"}, "0"=>{"_delete"=>"", "datastore"=>"rp_dev_ag_c01_asm_c0:t0:l086", 
"name"=>"Hard disk", "size_gb"=>"14", "thin"=>"true", "eager_zero"=>"false"}, "1"=>{"_delete"=>"", "datastore"=>"rp_dev_ag_c01_asm_c0:t0:l086", "name"=>"u01", "size_gb"=>"16", "thin"=>"true", 
"eager_zero"=>"false"}}, "image_id"=>""}, "interfaces_attributes"=>{"0"=>{"_destroy"=>"0", "type"=>"Nic::Managed", "mac"=>"", "identifier"=>"eth0", "name"=>"servername", "domain_id"=>"1", 
"subnet_id"=>"1", "ip"=>"7.252.84.184", "managed"=>"0", "primary"=>"1", "provision"=>"0", "virtual"=>"0", "tag"=>"", "attached_to"=>"", "compute_attributes"=>{"type"=>"VirtualVmxnet3", "network"=>"141"}},
 "1"=>{"_destroy"=>"0", "type"=>"Nic::Managed", "mac"=>"", "identifier"=>"eth1", "name"=>"servername", "domain_id"=>"1", "subnet_id"=>"2", "ip"=>"7.252.188.58", "managed"=>"1", "primary"=>"0", 
"provision"=>"1", "virtual"=>"0", "tag"=>"", "attached_to"=>"", "compute_attributes"=>{"type"=>"VirtualVmxnet3", "network"=>"193"}}, "new_interfaces"=>{"_destroy"=>"1", "type"=>"Nic::Managed", "mac"=>"",
 "identifier"=>"", "name"=>"", "domain_id"=>"", "subnet_id"=>"", "ip"=>"", "managed"=>"1", "primary"=>"0", "provision"=>"0", "virtual"=>"0", "tag"=>"", "attached_to"=>"admin", "compute_attributes"=>
{"type"=>"VirtualE1000", "network"=>"101"}}}, "architecture_id"=>"1", "operatingsystem_id"=>"1", "provision_method"=>"build", "build"=>"1", "medium_id"=>"7", "ptable_id"=>"6", "disk"=>"", "root_pass"=>"[FILTERED]",
 "host_parameters_attributes"=>{"0"=>{"name"=>"auth_type", "value"=>"[FILTERED]", "hidden_value"=>"[FILTERED]", "_destroy"=>"false", "nested"=>""}, "1"=>{"name"=>"vmware_tools_version", 
"value"=>"[FILTERED]", "hidden_value"=>"[FILTERED]", "_destroy"=>"false", "nested"=>""}}, "is_owned_by"=>"1-Users", "enabled"=>"1", "comment"=>"", "overwrite"=>"false"}, "capabilities"=>"build image",
 "provider"=>"Vmware"}
2015-04-20 13:12:13 [I] Adding Compute instance for servername.domain.com
2015-04-20 13:12:13 [I] Successfully decrypted field for Foreman::Model::Vmware POD_Dev
2015-04-20 13:12:13 [I] Successfully decrypted field for Foreman::Model::Vmware POD_Dev
2015-04-20 13:12:14 [I] 

However, after the host is built, if I try to edit anything on the host, I get this error:

Started GET "/hosts/servername.domain.com/edit" for 7.252.136.32 at 2015-04-20 13:39:36 -0700
2015-04-20 13:39:36 [I] Processing by HostsController#edit as HTML
2015-04-20 13:39:36 [I]   Parameters: {"id"=>"servername.domain.com"}
2015-04-20 13:39:36 [I]   Rendered hosts/_progress.html.erb (0.1ms)
2015-04-20 13:39:36 [I] Import facts for 'servername.domain.com' completed. Added: 149, Updated: 0, Deleted 0 facts
2015-04-20 13:39:36 [I]   Rendered config_groups/_config_group.html.erb (43.3ms)
2015-04-20 13:39:36 [W] Saving eth0 NIC for host servername.domain.com failed, skipping because:
2015-04-20 13:39:36 [W]  Name has already been taken
2015-04-20 13:39:36 [W] No PXELinux templates were found for this host, make sure you define at least one in your RedHat 6.6 settings
2015-04-20 13:39:36 [W] Saving eth1 NIC for host servername.domain.com failed, skipping because:
2015-04-20 13:39:36 [W]  IP address can't be blank
2015-04-20 13:39:36 [W]  Name has already been taken
2015-04-20 13:39:36 [W]  No PXELinux templates were found for this host, make sure you define at least one in your RedHat 6.6 settings
2015-04-20 13:39:36 [I] Completed 422 Unprocessable Entity in 687ms (Views: 0.4ms | ActiveRecord: 241.6ms)
2015-04-20 13:39:36 [I]   Rendered config_groups/_config_group.html.erb (159.2ms)
Started PUT "/hosts/servername.domain.com 7.252.136.32 at 2015-04-20 13:41:08 -0700
2015-04-20 13:41:08 [I] Processing by HostsController#update as */*
2015-04-20 13:41:08 [I]   Parameters: {"utf8"=>"", "authenticity_token"=>"jIQECaYV7hZclakSTE7zrSN/TgmGeHFQxMN1TBpZO9M=", "host"=>{"name"=>"servername", "hostgroup_id"=>"6", 
"environment_id"=>"1", "puppet_ca_proxy_id"=>"1", "puppet_proxy_id"=>"1", "config_group_ids"=>[""], "puppetclass_ids"=>[""], "managed"=>"t", "progress_report_id"=>"[FILTERED]", "compute_attributes"=>
{"volumes_attributes"=>{"new_volumes"=>{"thin"=>"false", "eager_zero"=>"false"}, "0"=>{"thin"=>"false", "eager_zero"=>"false"}, "1"=>{"thin"=>"false", "eager_zero"=>"false"}}}, "interfaces_attributes"=>{"0"=>
{"_destroy"=>"0", "mac"=>"00:50:56:93:5a:d2", "name"=>"servername", "domain_id"=>"1", "subnet_id"=>"1", "ip"=>"7.252.84.184", "managed"=>"0", "primary"=>"1", "provision"=>"0", "tag"=>"", 
"attached_to"=>"", "compute_attributes"=>{"type"=>"VirtualVmxnet3", "network"=>"141"}, "id"=>"89"}, "1"=>{"_destroy"=>"0", "mac"=>"00:50:56:93:70:08", "name"=>"servername", "domain_id"=>"1", 
"subnet_id"=>"2", "ip"=>"7.252.188.58", "managed"=>"1", "primary"=>"0", "provision"=>"1", "tag"=>"", "attached_to"=>"", "compute_attributes"=>{"type"=>"VirtualVmxnet3", "network"=>"193"}, "id"=>"90"},
 "new_interfaces"=>{"_destroy"=>"1", "type"=>"Nic::Managed", "mac"=>"", "identifier"=>"", "name"=>"", "domain_id"=>"", "subnet_id"=>"", "ip"=>"", "managed"=>"1", "primary"=>"0", "provision"=>"0", 
"virtual"=>"0", "tag"=>"", "attached_to"=>"admin", "compute_attributes"=>{"type"=>"VirtualE1000", "network"=>"101"}}}, "architecture_id"=>"1", "operatingsystem_id"=>"1", "medium_id"=>"7", 
"ptable_id"=>"6", "disk"=>"", "root_pass"=>"[FILTERED]", "host_parameters_attributes"=>{"0"=>{"name"=>"auth_type", "value"=>"[FILTERED]", "hidden_value"=>"[FILTERED]", "_destroy"=>"false", 
"nested"=>"", "id"=>"98"}, "1"=>{"name"=>"vmware_tools_version", "value"=>"[FILTERED]", "hidden_value"=>"[FILTERED]", "_destroy"=>"1", "nested"=>"", "id"=>"99"}}, "is_owned_by"=>"1-Users", 
"enabled"=>"1", "comment"=>"", "overwrite"=>"false"}, "capabilities"=>"build image", "provider"=>"Vmware", "id"=>"servername.domain.com"}
2015-04-20 13:41:09 [I] Failed to save: Name has already been taken

And in the Web UI, which highlights both provisioned nics:

Some of the interfaces are invalid. Please check the table below. 
Actions #1

Updated by Dominic Cleal almost 9 years ago

  • Category changed from Unattended installations to Host creation
  • translation missing: en.field_release set to 28

It should be failing to validate the duplicate hostname when the host is initially submitted, I'd say, I don't think it's intended to be supported.

Actions #2

Updated by Dominic Cleal almost 9 years ago

  • translation missing: en.field_release changed from 28 to 50
Actions #3

Updated by Marek Hulán almost 9 years ago

  • Status changed from New to Assigned
  • Assignee set to Marek Hulán

This might be provider specific, on my libvirt in such scenario I'm getting error from my proxy that prevents record creation and hence the provisioning. On the other hand I don't get any validation error even though there's a validation https://github.com/theforeman/foreman/blob/develop/app/models/nic/interface.rb#L17, probably because uniqueness validation happens before the transaction is committed. I supposed we'll have to implement our own "validation" for new records on host object.

Actions #4

Updated by The Foreman Bot almost 9 years ago

  • Status changed from Assigned to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/2372 added
  • Pull request deleted ()
Actions #5

Updated by Marek Hulán almost 9 years ago

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

Also available in: Atom PDF