How to create a empty topic in rabbitmq queue list for nova components

asked 2012-03-30 13:21:53 -0600

sateesh-bodla gravatar image

Hi,

I want to create an empty topic queue as well as exchange in the Rabbitmq queue using kombu. I have seen the code in nova impl_kombu.py of rpc module, but it is implementing the consumers. I need to create a empty queue so that if any service (nova scheduler, compute, network) is not yet started and the queue doesn't exist in the rabbitmq list_queue then the message will be dropped. So in order to not to drop the messages, I will create a empty queue for the service before there is any rpc.call / cast call for the component.

Regards, Sateesh B.

edit retag flag offensive close merge delete

9 answers

Sort by ยป oldest newest most voted
0

answered 2012-04-02 14:41:10 -0600

I added a timeout to rpc.call a while back for bug 843200.

edit flag offensive delete link more
0

answered 2012-03-30 15:09:29 -0600

johngarbutt gravatar image

Currently the queues are created (if they are not already there) when each service starts. The code for that, used to be in the manager base class.

However, the queue is created before the service is registered in the database (as far as I can tell).

What problem are you seeing / trying to solve?

edit flag offensive delete link more
0

answered 2012-03-30 20:52:31 -0600

Take a look at the code for the NotifyPublisher in impl_kombu.py. This code does exactly what you're talking about. It is making sure a queue exists before it sends a message.

https://github.com/openstack/nova/blo...

edit flag offensive delete link more
0

answered 2012-04-03 05:21:21 -0600

sateesh-bodla gravatar image

Hi Russel,

I have gone through the bug 843200 and it is related to the restarting of the service while processing the request message. But the bug 919835 is that the message has not been queued for the service, since there is no queue for that service in rabbitmq list_queues.

In order to not to drop that message we need to create an empty queue for that service call/cast request.

Please correct me if I am wrong and let me know your comments.

Thanks in advance, Sateesh B.

edit flag offensive delete link more
0

answered 2012-04-02 05:53:48 -0600

sateesh-bodla gravatar image

Hi,

I am trying to resolve the bug 919835. To resolve that we need to create a empty queue for the component in rabbitmq to hold the message. As there will be no queue created before any service is started. Please let me know how to call that reconnect method from the call / cast method in impl_kombu.py file.

I have written following code for that. Created a new function named create_empty_queue in Class Connection of impl_kombu.py.

def create_empty_queue(self, topic):
    options = {'durable': FLAGS.rabbit_durable_queues,
            'auto_delete': False,
            'exclusive': False}
    topic_exchange = kombu.entity.Exchange(
            name=FLAGS.control_exchange,
            type='topic',
            durable=options['durable'],
            auto_delete=options['auto_delete'])
    LOG.info(_("from create_empty_queue"))
    self.channel = self.connection.channel()

    queue = kombu.entity.Queue(channel=self.channel,
            exchange=topic_exchange,
            name=topic,
            routing_key=topic)
    queue.declare()

Calling this empty queue function in function "def call" and "def cast" as follows:

conn = rpc.create_connection(new=True)
conn.create_empty_queue(topic)
node_topic = '%s.%s' % (self.topic, self.host)
conn.create_empty_queue(node_topic)

But I am getting some exceptions:

2012-04-02 16:44:24 ERROR nova.rpc.common [-] Exception during message handling (nova.rpc.common): TRACE: Traceback (most recent call last): (nova.rpc.common): TRACE: File "/usr/lib/python2.7/dist-packages/nova/rpc/amqp.py", line 250, in _process_data (nova.rpc.common): TRACE: rval = node_func(context=ctxt, *node_args) (nova.rpc.common): TRACE: File "/usr/lib/python2.7/dist-packages/nova/exception.py", line 112, in wrapped (nova.rpc.common): TRACE: return f(args, *kw) (nova.rpc.common): TRACE: File "/usr/lib/python2.7/dist-packages/nova/compute/manager.py", line 156, in decorated_function (nova.rpc.common): TRACE: function(self, context, instance_uuid, *args, *kwargs) (nova.rpc.common): TRACE: File "/usr/lib/python2.7/dist-packages/nova/compute/manager.py", line 180, in decorated_function (nova.rpc.common): TRACE: sys.exc_info()) (nova.rpc.common): TRACE: File "/usr/lib/python2.7/contextlib.py", line 24, in __exit__ (nova.rpc.common): TRACE: self.gen.next() (nova.rpc.common): TRACE: File "/usr/lib/python2.7/dist-packages/nova/compute/manager.py", line 174, in decorated_function (nova.rpc.common): TRACE: return function(self, context, instance_uuid, args, *kwargs) (nova.rpc.common): TRACE: File "/usr/lib/python2.7/dist-packages/nova/compute/manager.py", line 736, in terminate_instance (nova.rpc.common): TRACE: self._delete_instance(context, instance) (nova.rpc.common): TRACE: File "/usr/lib/python2.7/dist-packages/nova/compute/manager.py", line 716, in _delete_instance (nova.rpc.common): TRACE: self._shutdown_instance(context, instance, 'Terminating') (nova.rpc.common): TRACE: File "/usr/lib/python2.7/dist-packages/nova/compute/manager.py", line 671, in _shutdown_instance (nova.rpc.common): TRACE: network_info = self._get_instance_nw_info(context, instance) (nova.rpc.common): TRACE: File "/usr/lib/python2.7/dist-packages/nova/compute/manager.py", line 312, in _get_instance_nw_info (nova.rpc.common): TRACE: instance) (nova.rpc.common): TRACE: File "/usr/lib/python2.7/dist-packages/nova/network/api.py", line 216, in get_instance_nw_info (nova.rpc.common): TRACE: 'args': args}) (nova.rpc.common): TRACE: File "/usr/lib/python2.7/dist-packages/nova/rpc/__init__.py", line 69, in call (nova.rpc.common): TRACE: return _get_impl().call(context, topic, msg, timeout ... (more)

edit flag offensive delete link more
0

answered 2012-04-02 06:56:15 -0600

sateesh-bodla gravatar image

Hi John,

An empty queue will be created when any service is started, but what if the service is not yet started and there is no empty queue created in rabbitmq. When a rpc call/cast is called for that service there will be no empty queue for that service to send the message. Thus the message will be dropped.

So, I need to create an empty queue in rpc call/cast for a service, when ever there is no queue created for that service in rabbitmq list_queues.

Please let me know any pointers on how to create empty queues in the call/cast methods of impl_kombu.py file.

Thanks in advance, Sateesh B.

edit flag offensive delete link more
0

answered 2012-04-02 13:26:35 -0600

This doesn't really sound like a bug in the code to me. It sounds like a bug in the deployment, not the code. It seems reasonable to expect that the services will get started before another service tries to use them.

Is this something you actually had a problem with? If so, shouldn't this just be resolved by properly updating whatever you are using to start all the services to start them in the proper order?

edit flag offensive delete link more
0

answered 2012-04-02 14:33:38 -0600

johngarbutt gravatar image

OK, I see you are trying to work on this bug: https://bugs.launchpad.net/nova/+bug/919835 (https://bugs.launchpad.net/nova/+bug/...)

Bit of a edge case, but an annoying one. As Russell points out, you shouldn't normally see this issue if you start the services in the correct order.

It might a better fix be doing something like adding a timeout to rpc.call so you don't get the "wait for ever" problem. Don't know if there is another bug for that already, and there may be a reason there is no timeout.

I assume you have seen the developer docs on this stuff: http://nova.openstack.org/devref/rabbit.html (http://nova.openstack.org/devref/rabb...)

I don't know the code that well, but you should find the common entry points here: nova/rpc/__init__.py

And the default implementation here: nova/rpc/impl_kombu.py (take a look at multicall)

Hope that helps.

edit flag offensive delete link more
0

answered 2012-04-03 12:33:03 -0600

I think both John and I understand what you're trying to do, just not why you're trying to do it. I get that you're trying to get the code to create the queue ... but what we're saying is that this should never be a problem, unless the services are starting in the wrong order. In that case, starting the services in the wrong order is the problem, not this code.

edit flag offensive delete link more

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower

Stats

Asked: 2012-03-30 13:21:53 -0600

Seen: 114 times

Last updated: Apr 03 '12