Project

General

Profile

Bug #12441

Duplicate entries in `nics` table

Added by Brandon Weeks almost 4 years ago. Updated about 1 year ago.

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

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.


Related issues

Related to Foreman - Bug #15238: Multiple interfaces with empty identifier are marked as invalidClosed2016-05-31

Associated revisions

Revision fedf3791 (diff)
Added by Brandon Weeks almost 4 years ago

Fixes #12441 - validate uniqueness for nic identifier and host

History

#1 Updated by Brandon Weeks almost 4 years ago

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

#2 Updated by Brandon Weeks almost 4 years ago

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.

#3 Updated by The Foreman Bot almost 4 years ago

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

#4 Updated by Dominic Cleal almost 4 years ago

  • Category changed from Database to Network
  • Assignee set to Brandon Weeks
  • Priority changed from Urgent to Normal
  • Legacy Backlogs Release (now unused) set to 71

#5 Updated by Brandon Weeks almost 4 years ago

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

#6 Updated by Marek Hulán about 3 years ago

  • Related to Bug #15238: Multiple interfaces with empty identifier are marked as invalid added

Also available in: Atom PDF