Bug 1314555 - System doesn't account for two devices with the same IP address
System doesn't account for two devices with the same IP address
Status: NEW
Product: Spacewalk
Classification: Community
Component: Server (Show other bugs)
All All
unspecified Severity medium
: ---
: ---
Assigned To: Tomáš Kašpárek
Red Hat Satellite QA List
Depends On:
  Show dependency treegraph
Reported: 2016-03-03 17:05 EST by Carl Thompson
Modified: 2016-11-06 08:22 EST (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed:
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

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

  None (edit)
Description Carl Thompson 2016-03-03 17:05:26 EST
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

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.

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