Merge lp:~soren/nova/avoid-zombie-chains into lp:~hudson-openstack/nova/trunk

Proposed by Soren Hansen
Status: Merged
Approved by: Rick Harris
Approved revision: 735
Merged at revision: 792
Proposed branch: lp:~soren/nova/avoid-zombie-chains
Merge into: lp:~hudson-openstack/nova/trunk
Diff against target: 36 lines (+7/-8)
1 file modified
nova/virt/libvirt_conn.py (+7/-8)
To merge this branch: bzr merge lp:~soren/nova/avoid-zombie-chains
Reviewer Review Type Date Requested Status
Rick Harris (community) Approve
Devin Carlen (community) Approve
Review via email: mp+53074@code.launchpad.net

Commit message

Remove race condition when refreshing security groups and destroying instances at the same time.

Description of the change

See the linked bug report for the full explanation of the problem.

To post a comment you must log in.
Revision history for this message
Devin Carlen (devcamcar) wrote :

lgtm

review: Approve
Revision history for this message
Rick Harris (rconradharris) wrote :

Just some really really minor nits:

> 10 + if self.instances.pop(instance['id'], False):

Since instance['id'] isn't a bool, the fallback should probably be None.

> 15 - 'filtered'), instance['id'])
> 6 + 'filtered'), instance['id'])

Any reason to include this in the final patch?

Revision history for this message
Soren Hansen (soren) wrote :

2011/3/11 Rick Harris <email address hidden>:
>> 10    +        if self.instances.pop(instance['id'], False):
> Since instance['id'] isn't a bool, the fallback should probably be None.

Fixed.

>> 15    -                       'filtered'), instance['id'])
>> 6     +                   'filtered'), instance['id'])
> Any reason to include this in the final patch?

Um, yes, but not like that :) I wanted to align it with the outer
paren, but somehow I managed to screw that up. Fixed.

--
Soren Hansen        | http://linux2go.dk/
Ubuntu Developer    | http://www.ubuntu.com/
OpenStack Developer | http://www.openstack.org/

lp:~soren/nova/avoid-zombie-chains updated
734. By Soren Hansen

Indentation adjustment (cosmetical).

735. By Soren Hansen

Make the fallback value None instead of False

Revision history for this message
Rick Harris (rconradharris) wrote :

lgtm

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'nova/virt/libvirt_conn.py'
2--- nova/virt/libvirt_conn.py 2011-03-10 20:40:19 +0000
3+++ nova/virt/libvirt_conn.py 2011-03-11 22:43:43 +0000
4@@ -1238,13 +1238,12 @@
5 pass
6
7 def unfilter_instance(self, instance):
8- if instance['id'] in self.instances:
9- del self.instances[instance['id']]
10+ if self.instances.pop(instance['id'], None):
11 self.remove_filters_for_instance(instance)
12 self.iptables.apply()
13 else:
14 LOG.info(_('Attempted to unfilter instance %s which is not '
15- 'filtered'), instance['id'])
16+ 'filtered'), instance['id'])
17
18 def prepare_instance_filter(self, instance):
19 self.instances[instance['id']] = instance
20@@ -1387,11 +1386,11 @@
21 pass
22
23 def refresh_security_group_rules(self, security_group):
24- for instance in self.instances.values():
25- # We use the semaphore to make sure noone applies the rule set
26- # after we've yanked the existing rules but before we've put in
27- # the new ones.
28- with self.iptables.semaphore:
29+ # We use the semaphore to make sure noone applies the rule set
30+ # after we've yanked the existing rules but before we've put in
31+ # the new ones.
32+ with self.iptables.semaphore:
33+ for instance in self.instances.values():
34 self.remove_filters_for_instance(instance)
35 self.add_filters_for_instance(instance)
36 self.iptables.apply()