Merge lp:~soren/nova/rpc-call-concurrency into lp:~hudson-openstack/nova/trunk

Proposed by Soren Hansen
Status: Merged
Approved by: Devin Carlen
Approved revision: 664
Merged at revision: 664
Proposed branch: lp:~soren/nova/rpc-call-concurrency
Merge into: lp:~hudson-openstack/nova/trunk
Diff against target: 39 lines (+4/-4)
1 file modified
nova/rpc.py (+4/-4)
To merge this branch: bzr merge lp:~soren/nova/rpc-call-concurrency
Reviewer Review Type Date Requested Status
Devin Carlen (community) Approve
Jay Pipes (community) Approve
Review via email: mp+49373@code.launchpad.net

Commit message

Create a new AMQP connection by default.

Description of the change

It turns out that rpc.call has the same problem as rpc.cast. This time I saw it
when two clients attempted to call GetConsoleOutput at the same time.

I changed new's default to True and changed everywhere else to rely on the default.

I left the code implementing the singleton in, so that if we switch to another amqp
library that deals better with this, we can just change the default again.

To post a comment you must log in.
Revision history for this message
Jay Pipes (jaypipes) wrote :

I'm not sure why there is even an option to set instance(False), but that's a separate gripe. This fixes the problem.

review: Approve
Revision history for this message
Devin Carlen (devcamcar) wrote :

lgtm

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'nova/rpc.py'
--- nova/rpc.py 2011-02-10 13:56:24 +0000
+++ nova/rpc.py 2011-02-11 11:40:08 +0000
@@ -46,7 +46,7 @@
46class Connection(carrot_connection.BrokerConnection):46class Connection(carrot_connection.BrokerConnection):
47 """Connection instance object"""47 """Connection instance object"""
48 @classmethod48 @classmethod
49 def instance(cls, new=False):49 def instance(cls, new=True):
50 """Returns the instance"""50 """Returns the instance"""
51 if new or not hasattr(cls, '_instance'):51 if new or not hasattr(cls, '_instance'):
52 params = dict(hostname=FLAGS.rabbit_host,52 params = dict(hostname=FLAGS.rabbit_host,
@@ -246,7 +246,7 @@
246 LOG.error(_("Returning exception %s to caller"), message)246 LOG.error(_("Returning exception %s to caller"), message)
247 LOG.error(tb)247 LOG.error(tb)
248 failure = (failure[0].__name__, str(failure[1]), tb)248 failure = (failure[0].__name__, str(failure[1]), tb)
249 conn = Connection.instance(True)249 conn = Connection.instance()
250 publisher = DirectPublisher(connection=conn, msg_id=msg_id)250 publisher = DirectPublisher(connection=conn, msg_id=msg_id)
251 try:251 try:
252 publisher.send({'result': reply, 'failure': failure})252 publisher.send({'result': reply, 'failure': failure})
@@ -319,7 +319,7 @@
319 self.result = data['result']319 self.result = data['result']
320320
321 wait_msg = WaitMessage()321 wait_msg = WaitMessage()
322 conn = Connection.instance(True)322 conn = Connection.instance()
323 consumer = DirectConsumer(connection=conn, msg_id=msg_id)323 consumer = DirectConsumer(connection=conn, msg_id=msg_id)
324 consumer.register_callback(wait_msg)324 consumer.register_callback(wait_msg)
325325
@@ -346,7 +346,7 @@
346 """Sends a message on a topic without waiting for a response"""346 """Sends a message on a topic without waiting for a response"""
347 LOG.debug(_("Making asynchronous cast..."))347 LOG.debug(_("Making asynchronous cast..."))
348 _pack_context(msg, context)348 _pack_context(msg, context)
349 conn = Connection.instance(True)349 conn = Connection.instance()
350 publisher = TopicPublisher(connection=conn, topic=topic)350 publisher = TopicPublisher(connection=conn, topic=topic)
351 publisher.send(msg)351 publisher.send(msg)
352 publisher.close()352 publisher.close()