Bug #12441
closed
Duplicate entries in `nics` table
Added by Brandon Weeks almost 9 years ago.
Updated about 6 years ago.
Description
Foreman is inserting entires into the `nics` table during facts import/parse that have identical (host_id, identifier) columns as existing rows. This causes validation errors when trying to edit the host via the GUI.
foreman=# SELECT id,identifier,mac,attrs,created_at FROM nics WHERE host_id = 690 AND identifier = 'br_tun' ORDER BY identifier;
id | identifier | mac | attrs | created_at
--------+------------+-------------------+---------------------------------------------------------+----------------------------
125 | br_tun | 92:60:6f:d8:23:4c | --- !ruby/hash:ActiveSupport::HashWithIndifferentAccess+| 2015-03-31 21:45:41.582826
| | | mtu: '1500' +|
| | | |
220002 | br_tun | ea:e5:ed:bd:a8:4a | --- !ruby/hash:ActiveSupport::HashWithIndifferentAccess+| 2015-11-10 20:52:03.44866
| | | mtu: '1500' +|
| | | lldp_neighbor_portdesc: '' +|
| | | lldp_neighbor_portid: '' +|
| | | lldp_neighbor_sysname: '' +|
| | | lldp_neighbor_mngaddr_ipv4: '' +|
| | | lldp_neighbor_mngaddr_ipv6: '' +|
| | | lldp_neighbor_pvid: '' +|
| | | lldp_neighbor_mtu: '' +|
| | | |
(2 rows)
foreman=#
example bad data
host = Host::Managed.find(690)
macaddress_br_tun_fact_name = FactName.where(name: 'macaddress_br_tun').first
macaddress_br_tun_fact_value = FactValue.where(fact_name_id: macaddress_br_tun_fact_name, host_id: host).first
macaddress_br_tun_fact_value.value = 'aa:aa:aa:aa:aa:a1'
macaddress_br_tun_fact_value.save
host.populate_fields_from_facts
Test case to reproduce.
- Status changed from New to Ready For Testing
- Pull request https://github.com/theforeman/foreman/pull/2902 added
- Category changed from Database to Network
- Assignee set to Brandon Weeks
- Priority changed from Urgent to Normal
- Translation missing: en.field_release set to 71
- Status changed from Ready For Testing to Closed
- % Done changed from 0 to 100
- Related to Bug #15238: Multiple interfaces with empty identifier are marked as invalid added
Also available in: Atom
PDF