Merge lp:~nttdata/nova/lp746821 into lp:~hudson-openstack/nova/trunk

Proposed by Kei Masumoto
Status: Merged
Approved by: Vish Ishaya
Approved revision: 944
Merged at revision: 956
Proposed branch: lp:~nttdata/nova/lp746821
Merge into: lp:~hudson-openstack/nova/trunk
Diff against target: 92 lines (+31/-12)
2 files modified
nova/tests/test_virt.py (+2/-1)
nova/virt/libvirt_conn.py (+29/-11)
To merge this branch: bzr merge lp:~nttdata/nova/lp746821
Reviewer Review Type Date Requested Status
Brian Lamar (community) Approve
Vish Ishaya (community) Approve
Cory Wright (community) Approve
Brian Waldon (community) Approve
Review via email: mp+56322@code.launchpad.net

Description of the change

This branch is a patch for fixing below issue.
> Bug #746821: live_migration failing due to network filter not found Link a bug report

To post a comment you must log in.
Revision history for this message
Brian Lamar (blamar) wrote :

Good stuff Kei! Just a few really minor nitpicks:

Line 67 -- might be considered unnecessary spacing.

Line 74 -- I'd suggest a LOG.debug in there for the libvirt error, just in case someone needs to know exactly what is failing. I've been bitten by that in the past.

review: Needs Fixing
Revision history for this message
Brian Waldon (bcwaldon) wrote :

Looks good!

review: Approve
Revision history for this message
Cory Wright (corywright) wrote :

I believe your docstrings are incorrectly referencing nova-instance-instance-xxx instead of nova-instance-xxx:

   """Check nova-instance-instance-xxx exists"""

Otherwise, lgtm.

review: Approve
Revision history for this message
Vish Ishaya (vishvananda) wrote :

lgtm.

IIRC, the filters actually do have two instances. nova-instance is the prefix, and the name of each instance is instance-xxx

review: Approve
Revision history for this message
Brian Lamar (blamar) :
review: Approve
Revision history for this message
OpenStack Infra (hudson-openstack) wrote :
Download full text (46.1 KiB)

The attempt to merge lp:~nttdata/nova/lp746821 into lp:nova failed. Below is the output from the failed tests.

AccountsTest
    test_account_create OK
    test_account_delete OK
    test_account_update OK
    test_get_account OK
AdminAPITest
    test_admin_disabled OK
    test_admin_enabled OK
APITest
    test_exceptions_are_converted_to_faults OK
Test
    test_authorize_token OK
    test_authorize_user OK
    test_bad_token OK
    test_bad_user_bad_key OK
    test_bad_user_good_key OK
    test_no_user OK
    test_token_expiry OK
TestFunctional
    test_token_doesnotexist OK
    test_token_expiry OK
TestLimiter
    test_authorize_token OK
LimiterTest
    test_limiter_custom_max_limit OK
    test_limiter_limit_and_offset OK
    test_limiter_limit_medium OK
    test_limiter_limit_over_max OK
    test_limiter_limit_zero OK
    test_limiter_negative_limit OK
    test_limiter_negative_offset OK
    test_limiter_nothing OK
    test_limiter_offset_bad OK
    test_limiter_offset_blank OK
    test_limiter_offset_medium OK
    test_limiter_offset_over_max OK
    test_limiter_offset_zero OK
ActionExtensionTest
    test_extended_action OK
    test_invalid_action OK
    test_invalid_action_body OK
ExtensionControllerTest
    test_get_by_alias OK
    test_index OK
ExtensionManagerTest
    test_get_resources OK
ResourceExtensionTest
    test_get_resources OK
    test_get_resources_with_controller OK
    test_no_extension_present OK
ResponseExtensionTest
    test_get_resources_with_mgr OK
    test_get_resources_with_stub_mgr OK
TestFaults
    test_400_fault_json OK
    test_400_fault_xml OK
    test_...

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'nova/tests/test_virt.py'
2--- nova/tests/test_virt.py 2011-04-04 20:17:04 +0000
3+++ nova/tests/test_virt.py 2011-04-07 21:34:25 +0000
4@@ -479,7 +479,7 @@
5
6 fake_timer = FakeTime()
7
8- self.create_fake_libvirt_mock(nwfilterLookupByName=fake_raise)
9+ self.create_fake_libvirt_mock()
10 instance_ref = db.instance_create(self.context, self.test_instance)
11
12 # Start test
13@@ -488,6 +488,7 @@
14 conn = libvirt_conn.LibvirtConnection(False)
15 conn.firewall_driver.setattr('setup_basic_filtering', fake_none)
16 conn.firewall_driver.setattr('prepare_instance_filter', fake_none)
17+ conn.firewall_driver.setattr('instance_filter_exists', fake_none)
18 conn.ensure_filtering_rules_for_instance(instance_ref,
19 time=fake_timer)
20 except exception.Error, e:
21
22=== modified file 'nova/virt/libvirt_conn.py'
23--- nova/virt/libvirt_conn.py 2011-04-07 21:08:16 +0000
24+++ nova/virt/libvirt_conn.py 2011-04-07 21:34:25 +0000
25@@ -1404,18 +1404,13 @@
26 # wait for completion
27 timeout_count = range(FLAGS.live_migration_retry_count)
28 while timeout_count:
29- try:
30- filter_name = 'nova-instance-%s' % instance_ref.name
31- self._conn.nwfilterLookupByName(filter_name)
32+ if self.firewall_driver.instance_filter_exists(instance_ref):
33 break
34- except libvirt.libvirtError:
35- timeout_count.pop()
36- if len(timeout_count) == 0:
37- ec2_id = instance_ref['hostname']
38- iname = instance_ref.name
39- msg = _('Timeout migrating for %(ec2_id)s(%(iname)s)')
40- raise exception.Error(msg % locals())
41- time.sleep(1)
42+ timeout_count.pop()
43+ if len(timeout_count) == 0:
44+ msg = _('Timeout migrating for %s. nwfilter not found.')
45+ raise exception.Error(msg % instance_ref.name)
46+ time.sleep(1)
47
48 def live_migration(self, ctxt, instance_ref, dest,
49 post_method, recover_method):
50@@ -1544,6 +1539,10 @@
51 """
52 raise NotImplementedError()
53
54+ def instance_filter_exists(self, instance):
55+ """Check nova-instance-instance-xxx exists"""
56+ raise NotImplementedError()
57+
58
59 class NWFilterFirewall(FirewallDriver):
60 """
61@@ -1851,6 +1850,21 @@
62 return 'nova-instance-%s' % (instance['name'])
63 return 'nova-instance-%s-%s' % (instance['name'], nic_id)
64
65+ def instance_filter_exists(self, instance):
66+ """Check nova-instance-instance-xxx exists"""
67+ network_info = _get_network_info(instance)
68+ for (network, mapping) in network_info:
69+ nic_id = mapping['mac'].replace(':', '')
70+ instance_filter_name = self._instance_filter_name(instance, nic_id)
71+ try:
72+ self._conn.nwfilterLookupByName(instance_filter_name)
73+ except libvirt.libvirtError:
74+ name = instance.name
75+ LOG.debug(_('The nwfilter(%(instance_filter_name)s) for'
76+ '%(name)s is not found.') % locals())
77+ return False
78+ return True
79+
80
81 class IptablesFirewallDriver(FirewallDriver):
82 def __init__(self, execute=None, **kwargs):
83@@ -2040,6 +2054,10 @@
84
85 return ipv4_rules, ipv6_rules
86
87+ def instance_filter_exists(self, instance):
88+ """Check nova-instance-instance-xxx exists"""
89+ return self.nwfilter.instance_filter_exists(instance)
90+
91 def refresh_security_group_members(self, security_group):
92 pass
93