#84 Searching for device by IP can sometimes return a device with a different IP to that searched

fixed
Bug (50)
2014-02-02
2014-01-15
Robert Kerr
No

To replicate this:

  • configure a switch with IP address A
  • configure DNS to map hostname H to IP address A
  • discover the device
  • re-configure the switch to have a new IP address B
  • re-configure DNS to map hostname H to IP address B
  • discover the device

There are now two entries for the device in the database - one with IP address A and one with IP address B - both with hostname H.

If you search for IP address A or IP address B netdisco will show you the entry for the device with IP address A.

If you search for hostname H netdisco will show you there are two devices with that hostname and provide clickable links for each device. Both links display the device with IP address A when clicked.

The netdisco 1 web interface can view either device.

However there is possibly a secondary issue here in that I believe the netdisco 1 discovery process would have overwritten IP address A with IP address B rather than creating 2 devices in this case. I'm not sure how that logic recognised the 2 devices as being the same - serial number perhaps?

Discussion

  • Oliver Gorwits

    Oliver Gorwits - 2014-01-19
    • status: new --> closed
    • assigned_to: Oliver Gorwits
     
  • Oliver Gorwits

    Oliver Gorwits - 2014-01-19

    Thanks for the email. I've seen this myself, in the past, as well.

    I think the current ND2 behaviour is correct - it sees a device with an unknown IP and so treats it as a new device. If a device has changed IP, then the user can either delete the old device, or let it expire, or use the (unimplemented) device change-IP feature.

    I'd prefer not to use anything magical such as matching on serial number. There might be cases where this causes overwriting of a legitimate separate device, or doesn't work anyway (e.g. stack master change).

     
  • Robert Kerr

    Robert Kerr - 2014-01-20

    Treating it as a new device is fine - it's different to ND1 behaviour, but understandable.

    Not being able to access the new device in any way however seems like a bug to me? If I search for IP address B I expect to see that device not a different device with the same hostname.

    To restate the bug - if there are two devices with the same hostname but differing IP addresses you can only view the older of the two. Even if you search by IP netdisco appears to convert this to a hostname internally somewhere and show you the first device with that hostname

     
  • Oliver Gorwits

    Oliver Gorwits - 2014-01-20
    • status: closed --> taken
     
  • Oliver Gorwits

    Oliver Gorwits - 2014-01-20

    OK thanks for restating - it wasn't clear to me the first time around. I've reopened the ticket.

     
  • Oliver Gorwits

    Oliver Gorwits - 2014-01-22

    Hi Robert,

    Please would you be able to grab some records from your database for me, so I can confirm something about this bug? If you don't wish to paste the data here, you can email it to oliver (at) cpan (dot) org.

    psql> select ip, alias from device_ip where ip in ('<IP-A>','<IP-B>');

    That is, I'd like to see the root ip and aliases for the old and new device.

    regards,
    oliver.

     
  • Oliver Gorwits

    Oliver Gorwits - 2014-01-22

    er, OK, damn sourceforge ate some of the text. the ('','') should actually contain the IP of the old and new device (make sure it's the IP Netdisco thinks is the management IP).

     
  • Oliver Gorwits

    Oliver Gorwits - 2014-01-30

    Hi again,

    I wrote a fix for this in a branch "og-devicenaming2" and it would be awesome if you could test this, please.

    What the fix does is:

    1. always use device IP in hyperlinks in templates
    2. check whether device can be referred to by dns or ip. if the dns is unique then that is used and the UI will show dns name always. if dns is not unique, the UI will show ip.

    A nice way to see this in action is a device with a unique dns being the neighbour of a device with a non-unique dns. When you jump back and forward between the devices either in device ports neighbour link, or the network map, you'll see sometimes the dns name and sometimes the IP being used in the web UI.

    I guess the only(?) drawback of this fix is that each time the app loads information on a device it needs to check for the uniqueness of the dns field. I doubt this slows anything down.

    Please let me know how you get on.

     
  • Oliver Gorwits

    Oliver Gorwits - 2014-01-30

    Oh, and if you use the navbar search and enter a device dns name which is not unique, you'll go to the device search page (I think this was already the case), but also the links on that page will take you to the correct device details pages.

    On that search page I added "Last Discovered" timestamp so it's easy to see the newer and the older device (and then follow the link to the older device to delete it, if you want).

     
  • Eric A. Miller

    Eric A. Miller - 2014-02-01

    Tested the og-devicenaming2 branch and it works for scenario initially described in the ticket.

    However, this does not fix cases where there are duplicate devices in the database and IP addresses have not been changed. Netdisco 2 uses the alias column of the device_ip table. If an IP address is duplicated in the alias column we stop at the first and return the associated ip column identifying the device. As a result, although two entries may exist in the device table and a search returns both, clicking on the IP address for the link will only return one or the other depending upon which device's alias is returned first.

    Test case for this scenario was to manually modify the contact field of the duplicate devices to something unique, search for the device, and then click on the address or name of each.

    It appears that on subsequent runs, only one device is updated which is the one always returned by the search.

    I have yet to identify how duplicates entered the database in the first place since I believe the same methodology is used during discovery, search on the alias to see if the device already exists in the database and if so use that device's IP address. Maybe during the parallel discovery?

    All of this assumes we will not have duplicate IP addresses in the alias column. This should be a safe assumption since a database schema change would be required to handle overlapping IP address space.

    I vote to merge the og-devicenaming2 branch. Ticket [#27] is open for overlapping address space. If the root cause of duplicates entering the database can be identified as something in one of the Netdisco process we can open a new ticket for resolution.

     
    • Oliver Gorwits

      Oliver Gorwits - 2014-02-02

      Just to add some scenarios:

      In Robert's example it was a switch with only one IP, which changed IP, so the alias col wasn't used.

      I've also seen before, where a new loopback was added to a device and then the device would be rediscovered with that root_ip. Seeing as the new IP was not any alias before, get_device() doesn't return any existing device from the DB.

       
  • Oliver Gorwits

    Oliver Gorwits - 2014-02-02

    Is fixed in the next release.

     
  • Oliver Gorwits

    Oliver Gorwits - 2014-02-02
    • status: taken --> fixed
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks