Bug 675359 - "Modified" attribute may not exist when diffing files
Summary: "Modified" attribute may not exist when diffing files
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Spacewalk
Classification: Community
Component: Server
Version: 1.3
Hardware: x86_64
OS: Linux
unspecified
medium
Target Milestone: ---
Assignee: Michael Mráka
QA Contact: Red Hat Satellite QA List
URL:
Whiteboard:
Depends On:
Blocks: space14
TreeView+ depends on / blocked
 
Reported: 2011-02-05 04:15 UTC by Zach Carlson
Modified: 2011-04-26 09:11 UTC (History)
2 users (show)

Fixed In Version: spacewalk-backend-1.4.4-1
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2011-04-26 09:11:06 UTC
Embargoed:


Attachments (Terms of Use)

Description Zach Carlson 2011-02-05 04:15:36 UTC
Description of problem:

When a spacewalk client is reporting the result of a scheduled diff back to the spacewalk server, the 'row' variable (presumably derived from what the client reports but possibly from the server's data) may not always have the 'modified' key set; this would cause an error every time the client tries to rhn_check (which would subsequently fail and keep retrying until the task is unscheduled, causing lots of messages).

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

1.3

How reproducible:

Always that I saw.

Steps to Reproduce:
1. Schedule a diff between a machine's config file and the config file on a configuration channel managed by the spacewalk server.
2. Wait for the diff to be executed (or run rhn_check on the spacewalk client)
3. Receive messages about a KeyError exception being raised.
  
Actual results:
The diff is reported properly to the server without issue.

Expected results:
The server doesn't accept the report but leaves the task scheduled. 

Additional info:

Exception Handler Information
Traceback (most recent call last):
  File "/usr/lib/python2.4/site-packages/spacewalk/server/apacheRequest.py", line 118, in call_function
    response = apply(func, params)
  File "/usr/share/rhn/server/handlers/xmlrpc/queue.py", line 326, in get
    ret = self.__getV2(action)
  File "/usr/share/rhn/server/handlers/xmlrpc/queue.py", line 84, in __getV2
    result = method(self.server_id, action['id'], dry_run)
  File "/usr/lib/python2.4/site-packages/spacewalk/server/action/configfiles.py", line 111, in diff
    return _get_files(server_id, action_id)
  File "/usr/lib/python2.4/site-packages/spacewalk/server/action/configfiles.py", line 168, in _get_files
    files.append(format_file_results(row, server=server))
  File "/usr/lib/python2.4/site-packages/spacewalk/server/configFilesHandler.py", line 535, in format_file_results
    if row.has_key('modified'):
KeyError: 'modified'

row = <type 'dict'> {'config_channel': 'deniro-base', 'username': 'root', 'checksum': '1d12c5ff935de2ce12031e4a67bd3552', 'delim_start': '{|', 'delim_end': '|}', 'symlink': None, 'label': 'file', 'groupname': 'root', 'file_contents': <cx_Oracle.LOB object at 0x2b87d54e2bd0>, 'filemode': 644, 'checksum_type': 'md5', 'path': '/etc/rsyslog.conf', 'selinux_ctx': None, 'is_binary': 'N', 'revision': 2}

I was able to fix it by modifying the file /usr/lib/python2.4/site-packages/spacewalk/server/configFilesHandler.py at line 535, just as indicated in the traceback, to read as follows:

    if row.has_key('modified'):
            if row['modified']:
                m_date = xmlrpclib.DateTime(str(row['modified']))
            else:
                m_date = ''
    else:
        m_date = ''

(previously it read:

    if row['modified']:
        m_date = xmlrpclib.DateTime(str(row['modified']))
    else:
        m_date = ''

)

Sorry I didn't get an actual diff. 

Please let me know if you require any further information.

Comment 1 Zach Carlson 2011-02-05 04:20:04 UTC
(In reply to comment #0)
> Description of problem:
> 
> When a spacewalk client is reporting the result of a scheduled diff back to the
> spacewalk server, the 'row' variable (presumably derived from what the client
> reports but possibly from the server's data) may not always have the 'modified'
> key set; this would cause an error every time the client tries to rhn_check
> (which would subsequently fail and keep retrying until the task is unscheduled,
> causing lots of messages).
> 
> Version-Release number of selected component (if applicable):
> 
> 1.3
> 
> How reproducible:
> 
> Always that I saw.
> 
> Steps to Reproduce:
> 1. Schedule a diff between a machine's config file and the config file on a
> configuration channel managed by the spacewalk server.
> 2. Wait for the diff to be executed (or run rhn_check on the spacewalk client)
> 3. Receive messages about a KeyError exception being raised.
> 
> Actual results:
> The diff is reported properly to the server without issue.
> 
> Expected results:
> The server doesn't accept the report but leaves the task scheduled. 
> 
> Additional info:
> 
> Exception Handler Information
> Traceback (most recent call last):
>   File "/usr/lib/python2.4/site-packages/spacewalk/server/apacheRequest.py",
> line 118, in call_function
>     response = apply(func, params)
>   File "/usr/share/rhn/server/handlers/xmlrpc/queue.py", line 326, in get
>     ret = self.__getV2(action)
>   File "/usr/share/rhn/server/handlers/xmlrpc/queue.py", line 84, in __getV2
>     result = method(self.server_id, action['id'], dry_run)
>   File
> "/usr/lib/python2.4/site-packages/spacewalk/server/action/configfiles.py", line
> 111, in diff
>     return _get_files(server_id, action_id)
>   File
> "/usr/lib/python2.4/site-packages/spacewalk/server/action/configfiles.py", line
> 168, in _get_files
>     files.append(format_file_results(row, server=server))
>   File
> "/usr/lib/python2.4/site-packages/spacewalk/server/configFilesHandler.py", line
> 535, in format_file_results
>     if row.has_key('modified'):
> KeyError: 'modified'
> 
> row = <type 'dict'> {'config_channel': 'deniro-base', 'username': 'root',
> 'checksum': '1d12c5ff935de2ce12031e4a67bd3552', 'delim_start': '{|',
> 'delim_end': '|}', 'symlink': None, 'label': 'file', 'groupname': 'root',
> 'file_contents': <cx_Oracle.LOB object at 0x2b87d54e2bd0>, 'filemode': 644,
> 'checksum_type': 'md5', 'path': '/etc/rsyslog.conf', 'selinux_ctx': None,
> 'is_binary': 'N', 'revision': 2}
> 
> I was able to fix it by modifying the file
> /usr/lib/python2.4/site-packages/spacewalk/server/configFilesHandler.py at line
> 535, just as indicated in the traceback, to read as follows:
> 
>     if row.has_key('modified'):
>             if row['modified']:
>                 m_date = xmlrpclib.DateTime(str(row['modified']))
>             else:
>                 m_date = ''
>     else:
>         m_date = ''
> 
> (previously it read:
> 
>     if row['modified']:
>         m_date = xmlrpclib.DateTime(str(row['modified']))
>     else:
>         m_date = ''
> 
> )
> 
> Sorry I didn't get an actual diff. 
> 
> Please let me know if you require any further information.

(oh, I also had to restart spacewalk after I made that change, in case it wasn't clear)

Comment 2 Michael Mráka 2011-02-07 09:13:20 UTC
Fixed by
commit 71504cda14cd9d6c9f81434dbed7871d3842dad2
    675359 - modified attribute is not always present

Comment 3 Michael Mráka 2011-02-07 14:03:32 UTC
Fixed package spacewalk-backend-1.4.4-1

Comment 4 Miroslav Suchý 2011-04-11 07:45:24 UTC
Mass moving to ON_QA before release of Spacewalk 1.4

Comment 5 Miroslav Suchý 2011-04-26 09:11:06 UTC
Spacewalk 1.4 has been released


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