Bug 1314555 - System doesn't account for two devices with the same IP address
Summary: System doesn't account for two devices with the same IP address
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Spacewalk
Classification: Community
Component: Server
Version: 2.4
Hardware: All
OS: All
unspecified
medium
Target Milestone: ---
Assignee: Tomáš Kašpárek
QA Contact: Red Hat Satellite QA List
URL:
Whiteboard:
Depends On:
Blocks: 1661434
TreeView+ depends on / blocked
 
Reported: 2016-03-03 22:05 UTC by Carl Thompson
Modified: 2019-01-28 09:36 UTC (History)
2 users (show)

Fixed In Version: spacewalk-backend-2.7.48-1
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 1661434 (view as bug list)
Environment:
Last Closed: 2019-01-28 09:36:00 UTC
Embargoed:


Attachments (Terms of Use)
patch for registration.py (1.35 KB, patch)
2016-03-03 22:05 UTC, Carl Thompson
no flags Details | Diff

Description Carl Thompson 2016-03-03 22:05:26 UTC
Created attachment 1132916 [details]
patch for registration.py

Description of problem:


Version-Release number of selected component (if applicable):


How reproducible:
Every time, easily repeatable


Steps to Reproduce:
1. Register a server with specific IP
2. Register another server with same IP
3.

Actual results:
[Thu Mar 03 12:25:17 2016] [error] Exception Handler Information
[Thu Mar 03 12:25:17 2016] [error] Traceback (most recent call last):
[Thu Mar 03 12:25:17 2016] [error]   File "/usr/lib/python2.6/site-packages/spacewalk/server/apacheRequest.py", line 129, in call_function
[Thu Mar 03 12:25:17 2016] [error]     response = func(*params)
[Thu Mar 03 12:25:17 2016] [error]   File "/usr/share/rhn/server/handlers/xmlrpc/registration.py", line 1034, in add_hw_profile
[Thu Mar 03 12:25:17 2016] [error]     h.execute(id=primif)
[Thu Mar 03 12:25:17 2016] [error]   File "/usr/lib/python2.6/site-packages/spacewalk/server/rhnSQL/sql_base.py", line 151, in execute
[Thu Mar 03 12:25:17 2016] [error]     return self._execute_wrapper(self._execute, *p, **kw)
[Thu Mar 03 12:25:17 2016] [error]   File "/usr/lib/python2.6/site-packages/spacewalk/server/rhnSQL/driver_cx_Oracle.py", line 110, in _execute_wrapper
[Thu Mar 03 12:25:17 2016] [error]     retval = function(*p, **kw)
[Thu Mar 03 12:25:17 2016] [error]   File "/usr/lib/python2.6/site-packages/spacewalk/server/rhnSQL/sql_base.py", line 205, in _execute
[Thu Mar 03 12:25:17 2016] [error]     return self._execute_(args, kwargs)
[Thu Mar 03 12:25:17 2016] [error]   File "/usr/lib/python2.6/site-packages/spacewalk/server/rhnSQL/driver_cx_Oracle.py", line 163, in _execute_
[Thu Mar 03 12:25:17 2016] [error]     self._real_cursor.execute(*(None, ), **params)
[Thu Mar 03 12:25:17 2016] [error] SQLError: (1, 'ORA-00001: unique constraint (SPACEWALK.RHN_SRV_NET_IFACE_PRIM_IFACE) violated\\n', "update rhnservernetinterface set is_primary = 'Y' where id = :id")

Expected results:
System should register, not cause internal server error when setting the primary interface in the hardware profile

Additional info:
When the registration.py attempts to set the primary interface for the hardware profile information in RHNSERVERNETINTERFACE it is attempting to do so based off of the IP address set in either RHNSERVERNETADDRESS4 or RHNSERVERNETADDRESS6 tables with no relation to the server_id of the device being registered.

Since you can have the same ip on multiple devices (due to private ip space and static maps in firewalls) when you attempt to register a device with an ip identical to another device the row from RHNSERVERNET INTERFACE is not selected properly.

I have attached a patch that improves the query against the database to ensure you get the proper row back from RHNSERVERNETINTERFACE table.

Comment 1 Michael Mráka 2019-01-28 09:35:34 UTC
The patch has been already applied as

commit 36a6df01615b4ff8e54d9712a2eae74dc9597c22
Fix: selection of primary interface


Note You need to log in before you can comment on or make changes to this bug.