This branch is a patch for fixing below issue.
> Bug #746821: live_migration failing due to network filter not found Link a bug report
This commit is contained in:
@@ -479,7 +479,7 @@ class LibvirtConnTestCase(test.TestCase):
|
||||
|
||||
fake_timer = FakeTime()
|
||||
|
||||
self.create_fake_libvirt_mock(nwfilterLookupByName=fake_raise)
|
||||
self.create_fake_libvirt_mock()
|
||||
instance_ref = db.instance_create(self.context, self.test_instance)
|
||||
|
||||
# Start test
|
||||
@@ -488,6 +488,7 @@ class LibvirtConnTestCase(test.TestCase):
|
||||
conn = libvirt_conn.LibvirtConnection(False)
|
||||
conn.firewall_driver.setattr('setup_basic_filtering', fake_none)
|
||||
conn.firewall_driver.setattr('prepare_instance_filter', fake_none)
|
||||
conn.firewall_driver.setattr('instance_filter_exists', fake_none)
|
||||
conn.ensure_filtering_rules_for_instance(instance_ref,
|
||||
time=fake_timer)
|
||||
except exception.Error, e:
|
||||
|
||||
@@ -1404,18 +1404,13 @@ class LibvirtConnection(driver.ComputeDriver):
|
||||
# wait for completion
|
||||
timeout_count = range(FLAGS.live_migration_retry_count)
|
||||
while timeout_count:
|
||||
try:
|
||||
filter_name = 'nova-instance-%s' % instance_ref.name
|
||||
self._conn.nwfilterLookupByName(filter_name)
|
||||
if self.firewall_driver.instance_filter_exists(instance_ref):
|
||||
break
|
||||
except libvirt.libvirtError:
|
||||
timeout_count.pop()
|
||||
if len(timeout_count) == 0:
|
||||
ec2_id = instance_ref['hostname']
|
||||
iname = instance_ref.name
|
||||
msg = _('Timeout migrating for %(ec2_id)s(%(iname)s)')
|
||||
raise exception.Error(msg % locals())
|
||||
time.sleep(1)
|
||||
timeout_count.pop()
|
||||
if len(timeout_count) == 0:
|
||||
msg = _('Timeout migrating for %s. nwfilter not found.')
|
||||
raise exception.Error(msg % instance_ref.name)
|
||||
time.sleep(1)
|
||||
|
||||
def live_migration(self, ctxt, instance_ref, dest,
|
||||
post_method, recover_method):
|
||||
@@ -1544,6 +1539,10 @@ class FirewallDriver(object):
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def instance_filter_exists(self, instance):
|
||||
"""Check nova-instance-instance-xxx exists"""
|
||||
raise NotImplementedError()
|
||||
|
||||
|
||||
class NWFilterFirewall(FirewallDriver):
|
||||
"""
|
||||
@@ -1851,6 +1850,21 @@ class NWFilterFirewall(FirewallDriver):
|
||||
return 'nova-instance-%s' % (instance['name'])
|
||||
return 'nova-instance-%s-%s' % (instance['name'], nic_id)
|
||||
|
||||
def instance_filter_exists(self, instance):
|
||||
"""Check nova-instance-instance-xxx exists"""
|
||||
network_info = _get_network_info(instance)
|
||||
for (network, mapping) in network_info:
|
||||
nic_id = mapping['mac'].replace(':', '')
|
||||
instance_filter_name = self._instance_filter_name(instance, nic_id)
|
||||
try:
|
||||
self._conn.nwfilterLookupByName(instance_filter_name)
|
||||
except libvirt.libvirtError:
|
||||
name = instance.name
|
||||
LOG.debug(_('The nwfilter(%(instance_filter_name)s) for'
|
||||
'%(name)s is not found.') % locals())
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
class IptablesFirewallDriver(FirewallDriver):
|
||||
def __init__(self, execute=None, **kwargs):
|
||||
@@ -2040,6 +2054,10 @@ class IptablesFirewallDriver(FirewallDriver):
|
||||
|
||||
return ipv4_rules, ipv6_rules
|
||||
|
||||
def instance_filter_exists(self, instance):
|
||||
"""Check nova-instance-instance-xxx exists"""
|
||||
return self.nwfilter.instance_filter_exists(instance)
|
||||
|
||||
def refresh_security_group_members(self, security_group):
|
||||
pass
|
||||
|
||||
|
||||
Reference in New Issue
Block a user