Bug 661721 - pulp-migrate/pulp-server init fails on RHEL5
Summary: pulp-migrate/pulp-server init fails on RHEL5
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Pulp
Classification: Retired
Component: z_other
Version: unspecified
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: ---
: ---
Assignee: Jeff Ortel
QA Contact: Preethi Thomas
URL:
Whiteboard:
Depends On:
Blocks: verified-to-close
TreeView+ depends on / blocked
 
Reported: 2010-12-09 14:08 UTC by Preethi Thomas
Modified: 2011-08-16 14:01 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2011-08-16 14:01:51 UTC
Embargoed:


Attachments (Terms of Use)

Description Preethi Thomas 2010-12-09 14:08:50 UTC
Description of problem:


[root@10 ~]# rpm -q pulp
pulp-0.0.112-1
[root@10 ~]# cat /etc/redhat-release 
Red Hat Enterprise Linux Server release 5.5 (Tikanga)
[root@10 ~]# 



[root@10 ~]# service pulp-server restart
Stopping httpd:                                            [FAILED]
Stopping Qpid AMQP daemon:                                 [FAILED]
Stopping mongod:                                           [  OK  ]
Pulp database not initialized, please run: /etc/init.d/pulp-server init
[root@10 ~]# service pulp-server init
Starting mongod:                                           [  OK  ]
Traceback (most recent call last):
  File "/usr/bin/pulp-migrate", line 19, in ?
    from pulp.server.db.migrate import script
  File "/usr/lib/python2.4/site-packages/pulp/server/db/migrate/script.py", line 21, in ?
    from pulp.server import auditing
  File "/usr/lib/python2.4/site-packages/pulp/server/auditing.py", line 18, in ?
    import functools
ImportError: No module named functools
[root@10 ~]#  pulp-migrate
Traceback (most recent call last):
  File "/usr/bin/pulp-migrate", line 19, in ?
    from pulp.server.db.migrate import script
  File "/usr/lib/python2.4/site-packages/pulp/server/db/migrate/script.py", line 21, in ?
    from pulp.server import auditing
  File "/usr/lib/python2.4/site-packages/pulp/server/auditing.py", line 18, in ?
    import functools
ImportError: No module named functools

Comment 1 Jeff Ortel 2010-12-13 14:25:07 UTC
functools was not added until python 2.5.  I don't see any reason we can't remove the use of this package but, I want to discuss with Jason Connor first.

Comment 2 Jeff Ortel 2010-12-13 22:37:06 UTC
Commented out references to functools and got:

[root@unused ~]#  service pulp-server init
Starting mongod:                                           [  OK  ]
Traceback (most recent call last):
  File "/usr/bin/pulp-migrate", line 19, in ?
    from pulp.server.db.migrate import script
  File "/usr/lib/python2.4/site-packages/pulp/server/db/migrate/script.py", line 21, in ?
    from pulp.server import auditing
  File "/usr/lib/python2.4/site-packages/pulp/server/auditing.py", line 32, in ?
    from pulp.server.api.base import BaseApi
  File "/usr/lib/python2.4/site-packages/pulp/server/api/base.py", line 16, in ?
    from pulp.server import async
  File "/usr/lib/python2.4/site-packages/pulp/server/async.py", line 17, in ?
    from pulp.server.tasking.queue.fifo import FIFOTaskQueue
  File "/usr/lib/python2.4/site-packages/pulp/server/tasking/queue/fifo.py", line 23, in ?
    from pulp.server.tasking.queue.base import TaskQueue
  File "/usr/lib/python2.4/site-packages/pulp/server/tasking/queue/base.py", line 17, in ?
    import pulp.server.tasking.task
  File "/usr/lib/python2.4/site-packages/pulp/server/tasking/task.py", line 24, in ?
    from pulp.server.tasking.queue.thread import TimeoutException, CancelException
  File "/usr/lib/python2.4/site-packages/pulp/server/tasking/queue/thread.py", line 17, in ?
    import ctypes
ImportError: No module named ctypes

Comment 3 Jeff Ortel 2010-12-13 22:40:26 UTC
python-ctypes is in the Requires list so after fixing the %if for RHEL, this should be taken care of.  So, I installed (yum install python-ctypes) and now getting this:

[root@unused ~]#  service pulp-server init
Starting mongod:                                           [  OK  ]
Traceback (most recent call last):
  File "/usr/bin/pulp-migrate", line 19, in ?
    from pulp.server.db.migrate import script
  File "/usr/lib/python2.4/site-packages/pulp/server/db/migrate/script.py", line 21, in ?
    from pulp.server import auditing
  File "/usr/lib/python2.4/site-packages/pulp/server/auditing.py", line 32, in ?
    from pulp.server.api.base import BaseApi
  File "/usr/lib/python2.4/site-packages/pulp/server/api/base.py", line 16, in ?
    from pulp.server import async
  File "/usr/lib/python2.4/site-packages/pulp/server/async.py", line 29, in ?
    _queue = FIFOTaskQueue()
  File "/usr/lib/python2.4/site-packages/pulp/server/tasking/queue/fifo.py", line 65, in __init__
    self.__dispatcher.start()
  File "/usr/lib/python2.4/site-packages/pulp/server/tasking/queue/thread.py", line 82, in start
    parent = threading.current_thread()
AttributeError: 'module' object has no attribute 'current_thread'

Comment 4 Jeff Ortel 2010-12-13 22:45:18 UTC
Looks like this should be threading.currentThread() for backwards compat.  Fixing in code.

Comment 5 Jeff Ortel 2010-12-13 22:58:50 UTC
Fixed threading.current_thread() in site-packages and now getting:

[root@unused ~]#  service pulp-server init
Starting mongod:                                           [  OK  ]
Traceback (most recent call last):
  File "/usr/bin/pulp-migrate", line 23, in ?
    sys.exit(script.main())
  File "/usr/lib/python2.4/site-packages/pulp/server/db/migrate/script.py", line 80, in main
    errors = validate()
  File "/usr/lib/python2.4/site-packages/pulp/server/db/migrate/validate.py", line 277, in validate
    num_errors += _validate_user()
  File "/usr/lib/python2.4/site-packages/pulp/server/db/migrate/validate.py", line 253, in _validate_user
    objectdb = user.UserApi()._getcollection()
  File "/usr/lib/python2.4/site-packages/pulp/server/api/user.py", line 35, in __init__
    self._ensure_default_admin()
  File "/usr/lib/python2.4/site-packages/pulp/server/api/user.py", line 46, in _ensure_default_admin
    self.create(self.default_login, password=default_password)
  File "/usr/lib/python2.4/site-packages/pulp/server/auditing.py", line 199, in _audit
    param_values)
  File "/usr/lib/python2.4/site-packages/pulp/server/db/model.py", line 199, in __init__
    self.principal_type = unicode(type(principal))
TypeError: unbound method __unicode__() must be called with SystemPrincipal instance as first argument (got nothing instead)

Comment 6 Jeff Ortel 2010-12-14 14:43:56 UTC
(In reply to comment #5)
>     self.principal_type = unicode(type(principal))
> TypeError: unbound method __unicode__() must be called with SystemPrincipal
> instance as first argument (got nothing instead)

This seems to be a bug in python 2.4.  I did a simple test and it can be reproduced as follows:

class A:
  def __unicode__(self):
    return 'A'

unicode(A)

So, I changed in the code:
from:
  self.principal_type = unicode(type(principal))
to:
  self.principal_type = str(type(principal)).encode('utf-8')

Moving on ...

Comment 7 Jeff Ortel 2010-12-14 14:49:38 UTC
Correction, I changed to:
  self.principal_type = str(type(principal))

and added:

class User:
  ...
  def __str__(self):
    return unicode(self).encode('utf-8')
  ...

Comment 8 Jeff Ortel 2010-12-14 14:51:19 UTC
Now getting:

[root@unused ~]# pulp-migrate --auto --log-level=debug
data model in use matches the current version
principal(SYSTEM)
Traceback (most recent call last):
  File "/usr/bin/pulp-migrate", line 23, in ?
    sys.exit(script.main())
  File "/usr/lib/python2.4/site-packages/pulp/server/db/migrate/script.py", line 80, in main
    errors = validate()
  File "/usr/lib/python2.4/site-packages/pulp/server/db/migrate/validate.py", line 277, in validate
    num_errors += _validate_user()
  File "/usr/lib/python2.4/site-packages/pulp/server/db/migrate/validate.py", line 253, in _validate_user
    objectdb = user.UserApi()._getcollection()
  File "/usr/lib/python2.4/site-packages/pulp/server/api/user.py", line 35, in __init__
    self._ensure_default_admin()
  File "/usr/lib/python2.4/site-packages/pulp/server/api/user.py", line 46, in _ensure_default_admin
    self.create(self.default_login, password=default_password)
  File "/usr/lib/python2.4/site-packages/pulp/server/auditing.py", line 204, in _audit
    result = method(*args, **kwargs)
  File "/usr/lib/python2.4/site-packages/pulp/server/api/user.py", line 57, in create
    hashed_password = password_util.hash_password(password)
  File "/usr/lib/python2.4/site-packages/pulp/server/auth/password_util.py", line 41, in hash_password
    hashed_password = pbkdf_sha256(str(plain_password), salt, NUM_ITERATIONS)
  File "/usr/lib/python2.4/site-packages/pulp/server/auth/password_util.py", line 35, in pbkdf_sha256
    result = HMAC(result, salt, sha256).digest() # use HMAC to apply the salt
  File "/usr/lib64/python2.4/hmac.py", line 42, in __init__
    self.outer = digestmod.new()
AttributeError: 'builtin_function_or_method' object has no attribute 'new'

Comment 9 Jeff Ortel 2010-12-14 15:07:39 UTC
This appears to be a bug in the hmac or incompatability with the sha256 function in hashlib package and can be reproduced as follows:

>>> from hmac import HMAC
>>> from hashlib import sha256
>>> HMAC('foo', 'bar', sha256)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/usr/lib64/python2.4/hmac.py", line 42, in __init__
    self.outer = digestmod.new()
AttributeError: 'builtin_function_or_method' object has no attribute 'new'

hashlib is new in python 2.5 and the rpm on this box: python-hashlib-20081119-4.el5 was installed from EPEL. It appears to be incompatible with python 2.4 function objects passed as the digest function.

Looking for workaround.

Comment 10 Jeff Ortel 2010-12-14 16:50:20 UTC
Code updated to use sha1 on < python 2.5 and hashlib.sha256 on python 2.5+.

Comment 11 Jeff Ortel 2010-12-14 21:23:26 UTC
pulp-migrate script hangs on exit.  It's actually hanging in/usr/lib/python2.4/site-packages/pulp/server/db/migrate/script.py on exit.  The main() completes but something in the module namespace is preventing the interpreter from exiting.

I've reduced to the following:

[root@unused ~]# python
Python 2.4.3 (#1, Jun 11 2009, 14:09:37) 
[GCC 4.1.2 20080704 (Red Hat 4.1.2-44)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from pulp.server.db.migrate.validate import validate
>>> from pulp.server.db.version import (
...     VERSION, get_version_in_use, is_validated, set_validated)
>>>
>>> ^D

<hangs>

Comment 12 Jeff Ortel 2010-12-16 15:35:33 UTC
Actually just this:

[root@unused ~]# python
Python 2.4.3 (#1, Jun 11 2009, 14:09:37) 
[GCC 4.1.2 20080704 (Red Hat 4.1.2-44)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>  from pulp.server.db.migrate.validate import validate
> ^D

<hangs>

Comment 13 Jeff Ortel 2010-12-16 16:52:05 UTC
I traced the imports back to async.py with instantiates the FIFOTaskQueue which starts are worker thread.  Looks like thread.daemon does not do the same thing as thread.setDaemon() (at least on python2.4).  Changed to use setDaemon(True) and no longer hangs.

Moving on.

Comment 14 Jeff Ortel 2011-01-11 18:54:47 UTC
Running pulp_migrate is fixed but as you can see by all the comments, this bug includes a lot of issues around installing/running pulp on RHEL 5.  The issues mentioned have been fix on the test box and replicated in the code but not tested on a clean install.  Once installed, the pulp_migrate script should work.

Comment 15 Jay Dobies 2011-01-12 19:37:02 UTC
Fixed in build 0.123.

Comment 16 Preethi Thomas 2011-03-11 15:20:14 UTC
[root@hp-ml370g4-01 ~]# service pulp-server init
Starting mongod: [  OK  ]
database migration to version 4 complete

root@hp-ml370g4-01 ~]# pulp-migrate
data model in use matches the current version
database migration to version 4 complete

Comment 17 Preethi Thomas 2011-03-11 15:30:31 UTC
[root@hp-ml370g4-01 ~]# service pulp-server restart
Stopping httpd: [  OK  ]
Stopping Qpid AMQP daemon: [  OK  ]
Stopping mongod: [  OK  ]
Starting mongod: [  OK  ]
Starting Qpid AMQP daemon: [  OK  ]
Starting httpd: [  OK  ]

Comment 18 Preethi Thomas 2011-03-11 15:31:17 UTC
verified


[root@hp-ml370g4-01 ~]# rpm -q pulp
pulp-0.0.147-1
[root@hp-ml370g4-01 ~]# cat /etc/redhat-release 
Red Hat Enterprise Linux Server release 5.5 (Tikanga)

Comment 19 Preethi Thomas 2011-08-16 14:01:51 UTC
Closing with Community Release 15

pulp-0.0.223-4.


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