Bug 1314555

Summary: System doesn't account for two devices with the same IP address
Product: [Community] Spacewalk Reporter: Carl Thompson <fedora>
Component: ServerAssignee: Tomáš Kašpárek <tkasparek>
Status: CLOSED CURRENTRELEASE QA Contact: Red Hat Satellite QA List <satqe-list>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 2.4CC: fbaligant, mmraka
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: All   
Whiteboard:
Fixed In Version: spacewalk-backend-2.7.48-1 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 1661434 (view as bug list) Environment:
Last Closed: 2019-01-28 09:36:00 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1661434    
Attachments:
Description Flags
patch for registration.py none

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