Navigation Menu

Skip to content

Commit

Permalink
Convert remaining network API casts to calls
Browse files Browse the repository at this point in the history
Fix for Bug 1021340

During compute/terminate_instance networking is de-allocated by a call to
network/api/deallocate_for_instance(), which is implemented as an rpc.cast to
the network manager. This in turn will eventually call
network/manager/deallocate_fixed_ip(), which in turn call the compute API to
trigger a security group refresh, which will get the instance from the database

However because original call to the network manager is a cast there is a chance
that the compute manager will delete the instance record in the DB before the
compute API (in the network manager) tries to retrieve the instance. At this
point the security group refresh fails (leaving rules in place which are a
security risk when the IP is reused), and potentially stopping otheraspects
of the network deallocation from completing.

Changing this from rpc.call to rpc.cast will fix this issue.

Aside from this specific use of a cast there are 4 other casts in the
network API:
  add_fixed_ip_to_instance
  remove_fixed_ip_from_instance
  add_network_to_project
  release_floating_ip

and to avoid other timing issues these will also be converted to calls.

Change-Id: I5cdcc628293d3e7cf165c5ffe4883f138783f73f
(cherry picked from commit 34f9d7e)
  • Loading branch information
Phil Day authored and vishvananda committed Jul 27, 2012
1 parent bb89acc commit 219c5ca
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions Authors
Expand Up @@ -157,6 +157,7 @@ Ollie Leahy <oliver.leahy@hp.com>
Pádraig Brady <pbrady@redhat.com>
Paul Voccio <paul@openstack.org>
Peng Yong <ppyy@pubyun.com>
Phil Day <philip.day@hp.com>
Philip Knouff <philip.knouff@mailtrust.com>
Ralf Haferkamp <rhafer@suse.de>
Renuka Apte <renuka.apte@citrix.com>
Expand Down
10 changes: 5 additions & 5 deletions nova/network/api.py
Expand Up @@ -126,7 +126,7 @@ def allocate_floating_ip(self, context, pool=None):
def release_floating_ip(self, context, address,
affect_auto_assigned=False):
"""Removes floating ip with address from a project. (deallocates)"""
rpc.cast(context,
rpc.call(context,
FLAGS.network_topic,
{'method': 'deallocate_floating_ip',
'args': {'address': address,
Expand Down Expand Up @@ -185,7 +185,7 @@ def deallocate_for_instance(self, context, instance, **kwargs):
args['instance_id'] = instance['id']
args['project_id'] = instance['project_id']
args['host'] = instance['host']
rpc.cast(context, FLAGS.network_topic,
rpc.call(context, FLAGS.network_topic,
{'method': 'deallocate_for_instance',
'args': args})

Expand All @@ -194,7 +194,7 @@ def add_fixed_ip_to_instance(self, context, instance, network_id):
args = {'instance_id': instance['id'],
'host': instance['host'],
'network_id': network_id}
rpc.cast(context, FLAGS.network_topic,
rpc.call(context, FLAGS.network_topic,
{'method': 'add_fixed_ip_to_instance',
'args': args})

Expand All @@ -204,13 +204,13 @@ def remove_fixed_ip_from_instance(self, context, instance, address):
args = {'instance_id': instance['id'],
'host': instance['host'],
'address': address}
rpc.cast(context, FLAGS.network_topic,
rpc.call(context, FLAGS.network_topic,
{'method': 'remove_fixed_ip_from_instance',
'args': args})

def add_network_to_project(self, context, project_id):
"""Force adds another network to a project."""
rpc.cast(context, FLAGS.network_topic,
rpc.call(context, FLAGS.network_topic,
{'method': 'add_network_to_project',
'args': {'project_id': project_id}})

Expand Down

0 comments on commit 219c5ca

Please sign in to comment.