Bug 518336 - Registration fails during kickstart because dbus/hal is not enabled
Summary: Registration fails during kickstart because dbus/hal is not enabled
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Spacewalk
Classification: Community
Component: Clients
Version: 0.5
Hardware: All
OS: Linux
low
medium
Target Milestone: ---
Assignee: Miroslav Suchý
QA Contact: Red Hat Satellite QA List
URL:
Whiteboard:
Depends On:
Blocks: space07
TreeView+ depends on / blocked
 
Reported: 2009-08-19 22:07 UTC by Justin Sherrill
Modified: 2012-03-06 09:02 UTC (History)
9 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2010-01-13 12:31:05 UTC
Embargoed:


Attachments (Terms of Use)
rhnreg.py patch to manage Dbus exception (1.11 KB, patch)
2009-08-20 08:43 UTC, Marco Giunta
no flags Details | Diff
Alternative patch (1.07 KB, patch)
2009-08-20 16:04 UTC, Mark Chappell
no flags Details | Diff
Fix TypeError "cannot marshal None" (1004 bytes, patch)
2009-08-24 10:46 UTC, Mark Chappell
no flags Details | Diff
Fix TypeError "cannot marshal None" (2.62 KB, patch)
2009-08-24 11:00 UTC, Mark Chappell
no flags Details | Diff

Description Justin Sherrill 2009-08-19 22:07:44 UTC
rhnreg_ks command executed in %post fails with :
Error reading hardware information: dbus_bindings.DBusException
Error reading DMI information: dbus_bindings.DBusException

Under %post :
dbus-daemon is stopped
hald is stopped

we need to fix this in master and backport it to spacewalk 0.6

Comment 1 Marco Giunta 2009-08-20 08:43:00 UTC
Created attachment 358053 [details]
rhnreg.py patch to manage Dbus exception

Hi,
I've used the same code of hardware.py to manage exception, when it tries to get SMBIOS information and hal/dbus aren't running ...

    Marco Giunta

Comment 2 Mark Chappell 2009-08-20 16:04:11 UTC
Created attachment 358125 [details]
Alternative patch

Since other failures to read smbios info only result in a log message, seems reasonable that a failure to connect to HAL/DBUS should only result in a log message

Comment 4 Marco Giunta 2009-08-24 09:08:04 UTC
After the commit of the patch (08/20/09 17:47:37), now there is another problem:

if I try to register a pc during kickstart, appears another error message:

Traceback (most recent call last):
  File "/usr/sbin/rhnreg_ks", line 216, in ?
    cli.run()
  File "/usr/share/rhn/up2date_client/rhncli.py", line 65, in run
    sys.exit(self.main() or 0)
  File "/usr/sbin/rhnreg_ks", line 145, in main
    other = other)
  File "/usr/share/rhn/up2date_client/rhnreg.py", line 431, in registerSystem
    ret = s.registration.new_system(auth_dict)
  File "/usr/share/rhn/up2date_client/rhnserver.py", line 50, in __call__
    return rpcServer.doCall(method, *args, **kwargs)
  File "/usr/share/rhn/up2date_client/rpcServer.py", line 199, in doCall
    ret = method(*args, **kwargs)
  File "/usr/lib/python2.4/xmlrpclib.py", line 1096, in __call__
    return self.__send(self.__name, args)
  File "/usr/share/rhn/up2date_client/rpcServer.py", line 38, in _request1
    ret = self._request(methodname, params)
  File "/usr/lib/python2.4/site-packages/rhn/rpclib.py", line 318, in _request
    request = self._req_body(params, methodname)
  File "/usr/lib/python2.4/site-packages/rhn/rpclib.py", line 222, in _req_body
    return xmlrpclib.dumps(params, methodname, encoding=self._encoding)
  File "/usr/lib/python2.4/xmlrpclib.py", line 1029, in dumps
    data = m.dumps(params)
  File "/usr/lib/python2.4/xmlrpclib.py", line 603, in dumps
    dump(v, write)
  File "/usr/lib/python2.4/xmlrpclib.py", line 615, in __dump
    f(self, value, write)
  File "/usr/lib/python2.4/xmlrpclib.py", line 696, in dump_struct
    dump(v, write)
  File "/usr/lib/python2.4/xmlrpclib.py", line 615, in __dump
    f(self, value, write)
  File "/usr/lib/python2.4/xmlrpclib.py", line 619, in dump_nil
    raise TypeError, "cannot marshal None unless allow_none is enabled"
exceptions.TypeError: cannot marshal None unless allow_none is enabled

This error appears because when the function get_hal_smbios() in hardware.py  raise the exception, doesn't return an empty smbios{} dict, but return nothing. Instead of a 'return', set an empty props{} dict, so the function can end with a empty smbios{} dict:

def get_hal_smbios():
    try:
        computer = get_hal_computer()
        props = computer.GetAllProperties()
    except:
        log = up2dateLog.initLog()
        msg = "Error reading smbios information: %s\n" % (sys.exc_type)
        log.log_debug(msg)
#        return
        props = {} <<<<<<<------------
    smbios = {}

Comment 5 Mark Chappell 2009-08-24 10:46:37 UTC
Created attachment 358436 [details]
Fix TypeError "cannot marshal None"

Returning None seems, fine, but we shouldn't then be adding it to the hashmap

Comment 6 Mark Chappell 2009-08-24 11:00:04 UTC
Looks like actually this will show up in multiple places

Comment 7 Mark Chappell 2009-08-24 11:00:55 UTC
Created attachment 358440 [details]
Fix TypeError "cannot marshal None"

Comment 8 Mark Chappell 2009-08-24 14:48:34 UTC
Pradeep,

While it looks like we're going to try to ensure HAL/DBUS is running https://bugzilla.redhat.com/show_bug.cgi?id=518342, I stil think my patch is worth applyint... The reason it covers more than one function is that get_hal_smbios, *may* return None, which will then cause a TypeException, which will be a real PITA to diagnose.  

Either get_hal_smbios should throw an exception, or we need to trap the Nones before they get into the RPC calls.

Comment 9 Pradeep Kilambi 2009-08-24 14:53:34 UTC
I'll look into this. Don't think I can today though but hopefully sometime this week.

Comment 10 Pradeep Kilambi 2009-08-25 21:16:33 UTC
Fixed! commit 4575224ad3f7bf8293e3d77eccf4a0415f356603

So Mark, I reviewed you're patch and don't see any major issues with it. But in comment#4 the cause is due to xmlrpc's restriction on None values in the hash while sending across. So instead of checking and skipping smbios from the dictionary and making separate rpc call I just did,

diff --git a/client/rhel/rhn-client-tools/src/up2date_client/hardware.py b/client/rhel/rhn-cl
index 4dff5c9..115bce8 100644
--- a/client/rhel/rhn-client-tools/src/up2date_client/hardware.py
+++ b/client/rhel/rhn-client-tools/src/up2date_client/hardware.py
@@ -865,7 +865,7 @@ def get_hal_system_and_smbios():
         log = up2dateLog.initLog()
         msg = "Error reading system and smbios information: %s\n" % (sys.exc_type)
         log.log_debug(msg)
-        return 
+        return {}
     system_and_smbios = {}
 
     for key in props:
@@ -882,7 +882,7 @@ def get_hal_smbios():
         log = up2dateLog.initLog()
         msg = "Error reading smbios information: %s\n" % (sys.exc_type)
         log.log_debug(msg)
-        return
+        return {}
     smbios = {}
     for key in props:
         if key.startswith('smbios'):

with fix:

$ rhnreg_ks --server http://localhost/XMLRPC --user admin --pass xxxxx --force
ZZZZZZZZZZZZZZZZ {'username': 'admin', 'release_name': 'redhat-release', 'profile_name': 'localhost', 'architecture': 'i686-redhat-linux', 'os_release': '5Server', 'smbios': {}, 'password': 'xxxxx'}
$

so smbios instead of being 'None' would now be an empty dict which is what its suppose to be if it could not get that info.

Comment 11 Marcus Moeller 2009-09-10 07:15:58 UTC
Same issue occurs on rhn-setup-0.4.20-9.el5.noarch.rpm (RHEL 5.4 final) while trying to execute rhnreg_ks during kickstart process.

Best Regards
Marcus

Comment 12 Henry Robertson 2009-10-28 00:59:03 UTC
(In reply to comment #11)
> Same issue occurs on rhn-setup-0.4.20-9.el5.noarch.rpm (RHEL 5.4 final) while
> trying to execute rhnreg_ks during kickstart process.
> 
> Best Regards
> Marcus  

Should using the --nohardware flag for rhnreg_ks sidestep  this problem? It doesn't seem to have an effect.

Comment 13 Miroslav Suchý 2010-01-13 12:31:05 UTC
#11 - that has been fixed under BZ 495680
This should be fixed now.


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