[ckan-dev] Hackaround: kombu patches for ckanext-archiver and ckanext-qa
Florian May
florian.wendelin.mayer at gmail.com
Tue Nov 25 09:35:03 UTC 2014
Hi all,
I just found a hackaround to a problem with an outdated kombu version
(calling a non-existing msgpack method), which however is required by
ckanext-archiver and ckanext-qa. As this problem was frustrating enough to
fix while not being a direct problem with any CKAN related code I thought
I'd share this here.
Environment:
Ubuntu 14.10 LTS on Amazon EC2 t2.medium
Apacke 2.4.7 mod_wsgi behind nginx
celeryd running via supervisor
ckan source install from branch master, 2.3a (24 Nov 2014 , commit
https://github.com/ckan/ckan/commit/b955aff981e95b24c41e5bf39cbd9dc91c446bd5
)
ckanext-archiver source install (17 Sept 2014, commit
de57522441bae34984f8f15186d1cd95481e0acf)
(requires kombu==2.1.3)
ckanext-qa source install (from my pull request 25 Nov 2014
https://github.com/ckan/ckanext-qa/pull/8)
(also requires kombu==2.1.3)
Actions:
Plugins ckanext-spatial, -archiver, and -qa and their dependencies are set
up.
Add a resource of type WMS (from ckanext-spatial's WMS preview example) to
a dataset.
QA will piggy-back onto the resource creation, create a task, send that to
the celery daemon, which uses the kombu serializer to write a msgpack
message.
The following error is thrown:
(Note my CKAN installation lives in /mnt/ckan/, diverging from the standard
/usr/lib/ckan/ location)
==> /var/log/apache2/ckan_private.error.log <==
[Tue Nov 25 16:26:50.693361 2014] [:error] [pid 20265] 2014-11-25
16:26:50,693 ERROR [ckan.model.modification] 'module' object has no
attribute 'packs'
[Tue Nov 25 16:26:50.693398 2014] [:error] [pid 20265] Traceback (most
recent call last):
[Tue Nov 25 16:26:50.693404 2014] [:error] [pid 20265] File "/mnt/ckan
/default/src/ckan/ckan/model/modification.py", line 84, in notify
[Tue Nov 25 16:26:50.693408 2014] [:error] [pid 20265]
observer.notify(entity, operation)
[Tue Nov 25 16:26:50.693411 2014] [:error] [pid 20265] File
"/mnt/ckan/default/src/ckanext-qa/ckanext/qa/plugin.py",
line 105, in notify
[Tue Nov 25 16:26:50.693415 2014] [:error] [pid 20265]
self._create_task(entity)
[Tue Nov 25 16:26:50.693418 2014] [:error] [pid 20265] File
"/mnt/ckan/default/src/ckanext-qa/ckanext/qa/plugin.py",
line 144, in _create_task
[Tue Nov 25 16:26:50.693421 2014] [:error] [pid 20265]
send_task('qa.update', args=[context, data], task_id=task_id)
[Tue Nov 25 16:26:50.693425 2014] [:error] [pid 20265] File
"/mnt/ckan/default/lib/python2.7/site-packages/celery/app/base.py",
line 201, in send_task
[Tue Nov 25 16:26:50.693444 2014] [:error] [pid 20265] router =
self.amqp.Router(queues)
[Tue Nov 25 16:26:50.693447 2014] [:error] [pid 20265] File
"/mnt/ckan/default/lib/python2.7/site-packages/kombu/utils/__init__.py",
line 229, in __get__
[Tue Nov 25 16:26:50.693450 2014] [:error] [pid 20265] value =
obj.__dict__[self.__name__] = self.__get(obj)
[Tue Nov 25 16:26:50.693453 2014] [:error] [pid 20265] File
"/mnt/ckan/default/lib/python2.7/site-packages/celery/app/base.py",
line 377, in amqp
[Tue Nov 25 16:26:50.693456 2014] [:error] [pid 20265] return
instantiate(self.amqp_cls, app=self)
[Tue Nov 25 16:26:50.693459 2014] [:error] [pid 20265] File
"/mnt/ckan/default/lib/python2.7/site-packages/celery/utils/__init__.py",
line 357, in instantiate
[Tue Nov 25 16:26:50.693462 2014] [:error] [pid 20265] return
get_cls_by_name(name)(*args, **kwargs)
[Tue Nov 25 16:26:50.693464 2014] [:error] [pid 20265] File
"/mnt/ckan/default/lib/python2.7/site-packages/celery/utils/__init__.py",
line 343, in get_cls_by_name
[Tue Nov 25 16:26:50.693467 2014] [:error] [pid 20265] module =
imp(module_name, package=package, **kwargs)
[Tue Nov 25 16:26:50.693470 2014] [:error] [pid 20265] File
"/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
[Tue Nov 25 16:26:50.693472 2014] [:error] [pid 20265] __import__(name)
[Tue Nov 25 16:26:50.693475 2014] [:error] [pid 20265] File
"/mnt/ckan/default/lib/python2.7/site-packages/celery/app/amqp.py",
line 17, in <module>
[Tue Nov 25 16:26:50.693478 2014] [:error] [pid 20265] from kombu
import compat as messaging
[Tue Nov 25 16:26:50.693480 2014] [:error] [pid 20265] File
"/mnt/ckan/default/lib/python2.7/site-packages/kombu/compat.py",
line 18, in <module>
[Tue Nov 25 16:26:50.693483 2014] [:error] [pid 20265] from . import
messaging
[Tue Nov 25 16:26:50.693485 2014] [:error] [pid 20265] File
"/mnt/ckan/default/lib/python2.7/site-packages/kombu/messaging.py",
line 17, in <module>
[Tue Nov 25 16:26:50.693488 2014] [:error] [pid 20265] from
.serialization import encode
[Tue Nov 25 16:26:50.693490 2014] [:error] [pid 20265] File
"/mnt/ckan/default/lib/python2.7/site-packages/kombu/serialization.py",
line 332, in <module>
[Tue Nov 25 16:26:50.693493 2014] [:error] [pid 20265]
register_msgpack()
[Tue Nov 25 16:26:50.693496 2014] [:error] [pid 20265] File
"/mnt/ckan/default/lib/python2.7/site-packages/kombu/serialization.py",
line 314, in register_msgpack
The problem lies in the kombu.serializer, which (fixed in contemporary
kombu versions) tries to use msgpack.packs instead of msgpack.packb and
.unpacks instead of unpackb.
As not to mess with ckanext-archiver and -qa's fixed celery and kombu
versions, the minimum hack to fix this error is:
pip install u-msgpack-python
into ckan's virtualenv, and to change line 314 of the installed
kombu.serializer at
/var/lib/ckan/default/lib/python2.7/site-packages/kombu/serialization.py
from registry.register('msgpack', msgpack.packs, msgpack.unpacks,
to registry.register('msgpack', msgpack.packb, msgpack.unpackb,
followed by a restart of your web server.
This hack will at least fix the Internal Server Error thrown by ckanext-qa
on creating a WMS resource (untested: other resource types). Be aware it
will be overwritten as soon as ckan or any plugin installs a newer kombu
version.
Did anyone else run into that problem so far?
Cheers,
Florian
Dept Parks & Wildlife, Western Australia
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20141125/c597bec8/attachment-0002.html>
More information about the ckan-dev
mailing list