Note: This is a public test instance of Red Hat Bugzilla. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback at
Bug 1089678 - rhnServerPath table gets updated every time client checks in
Summary: rhnServerPath table gets updated every time client checks in
Alias: None
Product: Spacewalk
Classification: Community
Component: Server
Version: 2.2
Hardware: All
OS: All
Target Milestone: ---
Assignee: Stephen Herr
QA Contact: Red Hat Satellite QA List
Depends On:
Blocks: space22 space23
TreeView+ depends on / blocked
Reported: 2014-04-21 14:21 UTC by Tasos Papaioannou
Modified: 2018-12-06 16:19 UTC (History)
4 users (show)

Fixed In Version: spacewalk-backend-2.2.22-1
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 1089680 (view as bug list)
Last Closed: 2014-07-17 08:41:04 UTC

Attachments (Terms of Use)

Description Tasos Papaioannou 2014-04-21 14:21:19 UTC
Description of problem:

store_client_route in ./backend/server/rhnServer/ updates the client's Proxy server information in rhnServerPath every time the client checks in, even though it should only update the information if it actually changed.

gets called every time a client checks in with the Spacewalk server. It's supposed to check whether the client's Proxy server information in rhnServerPath needs to be updated. It pulls the information 

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


How reproducible:


Steps to Reproduce:

1.) Register a system through a Spacewalk Proxy server.

2.) Verify that the client system appears in rhnServerPath:

rhnschema=# select * from rhnServerPath;

server_id  | proxy_server_id | position | hostname          | created | modified
1000032541 |      1000027585 |        0 | | 2014-04-04 08:49:56.143408-05 | 2014-04-04 08:49:56.143408-05

3.) Make the client check in or refresh its profile:

# rhn-profile-sync

4.) Verify that the created and modified times have been updated:

rhnschema=# select * from rhnServerPath;

server_id  | proxy_server_id | position | hostname          | created | modified
1000032541 |      1000027585 |        0 | | 2014-04-04 08:54:22.00102-05 | 2014-04-04 08:54:22.00102-05

Actual results:

rhnServerPath updated every time, even though contains code to update the table only when the information has changed.

Expected results:

rhnServerPath gets updated only when the client's Proxy path information has changed.

Additional info:

./backend/server/rhnServer/ expects oldRoute, which contains the client's proxy information pulled from rhnServerPath, to be a list of tuples (see the comment in the code below):

def store_client_route(server_id):
    """ Stores the route the client took to get to hosted or the Satellite """

    log_debug(5, server_id)

    # get the old routing information for this server_id
    # oldRoute in this format: [(id0, hostname0),  (id1, hostname1),  ...]
    #                           closest to client, ..., closest to server
    h = rhnSQL.prepare("""
        select position,
          from rhnServerPath
         where server_id = :server_id
        order by position
    oldRoute = h.fetchall_dict() or []
    newRoute = []

The list returned by h.fetchall_dict() is actually a list of dicts:

oldRoute = <type 'list'> [{'position': 0, 'hostname': '', 'proxy_server_id': 1000027585}]

whereas newRoute, constructed from the 'X-RHN-Proxy-Auth' http headers sent by the Proxy, is in the expected format:

newRoute = <type 'list'> [('1000027585', '')]

So, when oldRoute is compared to newRoute, the comparison always fails, and the server decides to update (with a delete from then an insert into) the table.

    if oldRoute == newRoute:
        # Nothing to do here
        # This also catches the case of no routes at all
    if oldRoute:
        # blow away table rhnServerPath entries for server_id
        log_debug(8, 'blow away route-info for %s' % server_id)
        h = rhnSQL.prepare("""
            delete from rhnServerPath where server_id = :server_id
    h = rhnSQL.prepare("""
        insert into rhnServerPath
               (server_id, proxy_server_id, position, hostname)
        values (:server_id, :proxy_server_id, :position, :hostname)

Comment 1 Tasos Papaioannou 2014-04-21 14:35:37 UTC
Proposed patch submitted on GitHub:

Comment 2 Jan Pazdziora 2014-04-22 07:04:21 UTC
Could this Spacewalk bugzilla be made public?

Comment 3 Tasos Papaioannou 2014-04-22 13:10:02 UTC
(In reply to Jan Pazdziora from comment #2)
> Could this Spacewalk bugzilla be made public?

Ok, done.

Comment 4 Stephen Herr 2014-04-24 18:30:56 UTC
Thanks for the patch and the great investigative work.

Committing to Spacewalk master:

Comment 5 Stephen Herr 2014-04-24 18:45:40 UTC
Correct commit hash for comment 4 is:

Ignore the hash in comment 4.

Comment 8 Milan Zázrivec 2014-07-17 08:41:04 UTC
Spacewalk 2.2 has been released:

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