Nova crashes when added new RPC interface

Bug #1790444 reported by donchen
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Invalid
Undecided
Unassigned

Bug Description

For some reason I need to add a RPC interface to nova-compute. When I tested the new interface, I got this error:

2018-09-03 02:23:56.870 70765 ERROR oslo_messaging.rpc.server [req-ff6e2750-98a2-4c13-95d0-548d9f66101d 3ff71b27e1e9446c8972c423e1b0d81e 123a456966664881a8380faa009e752f - default default] Exception during message handling: AttributeError: 'SchedulerReportClient' object has no attribute 'obj_to_primitive'
2018-09-03 02:23:56.870 70765 ERROR oslo_messaging.rpc.server Traceback (most recent call last):
2018-09-03 02:23:56.870 70765 ERROR oslo_messaging.rpc.server File "/usr/lib/python2.7/site-packages/oslo_messaging/rpc/server.py", line 163, in _process_incoming
2018-09-03 02:23:56.870 70765 ERROR oslo_messaging.rpc.server res = self.dispatcher.dispatch(message)
2018-09-03 02:23:56.870 70765 ERROR oslo_messaging.rpc.server File "/usr/lib/python2.7/site-packages/oslo_messaging/rpc/dispatcher.py", line 268, in dispatch
2018-09-03 02:23:56.870 70765 ERROR oslo_messaging.rpc.server return self._do_dispatch(endpoint, method, ctxt, args)
2018-09-03 02:23:56.870 70765 ERROR oslo_messaging.rpc.server File "/usr/lib/python2.7/site-packages/oslo_messaging/rpc/dispatcher.py", line 195, in _do_dispatch
2018-09-03 02:23:56.870 70765 ERROR oslo_messaging.rpc.server return self.serializer.serialize_entity(ctxt, result)
2018-09-03 02:23:56.870 70765 ERROR oslo_messaging.rpc.server File "/openstack/lib/python2.7/site-packages/nova/rpc.py", line 130, in serialize_entity
2018-09-03 02:23:56.870 70765 ERROR oslo_messaging.rpc.server return self._base.serialize_entity(context, entity)
2018-09-03 02:23:56.870 70765 ERROR oslo_messaging.rpc.server File "/openstack/lib/python2.7/site-packages/nova/objects/base.py", line 237, in serialize_entity
2018-09-03 02:23:56.870 70765 ERROR oslo_messaging.rpc.server entity)
2018-09-03 02:23:56.870 70765 ERROR oslo_messaging.rpc.server File "/openstack/lib/python2.7/site-packages/nova/objects/base.py", line 223, in _process_iterable
2018-09-03 02:23:56.870 70765 ERROR oslo_messaging.rpc.server for k, v in values.items()})
2018-09-03 02:23:56.870 70765 ERROR oslo_messaging.rpc.server File "/openstack/lib/python2.7/site-packages/nova/objects/base.py", line 223, in <dictcomp>
2018-09-03 02:23:56.870 70765 ERROR oslo_messaging.rpc.server for k, v in values.items()})
2018-09-03 02:23:56.870 70765 ERROR oslo_messaging.rpc.server File "/openstack/lib/python2.7/site-packages/nova/objects/base.py", line 240, in serialize_entity
2018-09-03 02:23:56.870 70765 ERROR oslo_messaging.rpc.server entity = entity.obj_to_primitive()
2018-09-03 02:23:56.870 70765 ERROR oslo_messaging.rpc.server File "/openstack/lib/python2.7/site-packages/nova/scheduler/client/__init__.py", line 39, in __run_method
2018-09-03 02:23:56.870 70765 ERROR oslo_messaging.rpc.server return getattr(self.instance, __name)(*args, **kwargs)
2018-09-03 02:23:56.870 70765 ERROR oslo_messaging.rpc.server AttributeError: 'SchedulerReportClient' object has no attribute 'obj_to_primitive'
2018-09-03 02:23:56.870 70765 ERROR oslo_messaging.rpc.server

The function`serialize_entity` in nova/nova/objects/base.py is:

    def serialize_entity(self, context, entity):
        if isinstance(entity, (tuple, list, set, dict)):
            entity = self._process_iterable(context, self.serialize_entity,
                                            entity)
        elif (hasattr(entity, 'obj_to_primitive') and
              callable(entity.obj_to_primitive)):
            entity = entity.obj_to_primitive()
        return entity

hasattr(entity, 'obj_to_primitive') and callable(entity.obj_to_primitive) always return true because entity is a LazyLoader class and it implemented `__getattr__`.

donchen (qishiyexu2)
description: updated
Revision history for this message
Matt Riedemann (mriedem) wrote :

I'm going to mark this as invalid. If you want some help debugging your code, you can post it to gerrit and get some help there to identify what is wrong in your change, but it looks like you're trying to send the SchedulerReportClient over RPC and that object is not serializable.

Changed in nova:
status: New → Invalid
Revision history for this message
donchen (qishiyexu2) wrote :

I know it is a bug of my code which leads to this exception but this issue is not about that bug.

What I'm going to say is,the elif condition hasattr(entity, 'obj_to_primitive') and callable(entity.obj_to_primitive) always return true, so it's useless.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.