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()
|
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)
|
instance_ref = db.instance_create(self.context, self.test_instance)
|
||||||
|
|
||||||
# Start test
|
# Start test
|
||||||
@@ -488,6 +488,7 @@ class LibvirtConnTestCase(test.TestCase):
|
|||||||
conn = libvirt_conn.LibvirtConnection(False)
|
conn = libvirt_conn.LibvirtConnection(False)
|
||||||
conn.firewall_driver.setattr('setup_basic_filtering', fake_none)
|
conn.firewall_driver.setattr('setup_basic_filtering', fake_none)
|
||||||
conn.firewall_driver.setattr('prepare_instance_filter', 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,
|
conn.ensure_filtering_rules_for_instance(instance_ref,
|
||||||
time=fake_timer)
|
time=fake_timer)
|
||||||
except exception.Error, e:
|
except exception.Error, e:
|
||||||
|
|||||||
@@ -1404,18 +1404,13 @@ class LibvirtConnection(driver.ComputeDriver):
|
|||||||
# wait for completion
|
# wait for completion
|
||||||
timeout_count = range(FLAGS.live_migration_retry_count)
|
timeout_count = range(FLAGS.live_migration_retry_count)
|
||||||
while timeout_count:
|
while timeout_count:
|
||||||
try:
|
if self.firewall_driver.instance_filter_exists(instance_ref):
|
||||||
filter_name = 'nova-instance-%s' % instance_ref.name
|
|
||||||
self._conn.nwfilterLookupByName(filter_name)
|
|
||||||
break
|
break
|
||||||
except libvirt.libvirtError:
|
timeout_count.pop()
|
||||||
timeout_count.pop()
|
if len(timeout_count) == 0:
|
||||||
if len(timeout_count) == 0:
|
msg = _('Timeout migrating for %s. nwfilter not found.')
|
||||||
ec2_id = instance_ref['hostname']
|
raise exception.Error(msg % instance_ref.name)
|
||||||
iname = instance_ref.name
|
time.sleep(1)
|
||||||
msg = _('Timeout migrating for %(ec2_id)s(%(iname)s)')
|
|
||||||
raise exception.Error(msg % locals())
|
|
||||||
time.sleep(1)
|
|
||||||
|
|
||||||
def live_migration(self, ctxt, instance_ref, dest,
|
def live_migration(self, ctxt, instance_ref, dest,
|
||||||
post_method, recover_method):
|
post_method, recover_method):
|
||||||
@@ -1544,6 +1539,10 @@ class FirewallDriver(object):
|
|||||||
"""
|
"""
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
|
def instance_filter_exists(self, instance):
|
||||||
|
"""Check nova-instance-instance-xxx exists"""
|
||||||
|
raise NotImplementedError()
|
||||||
|
|
||||||
|
|
||||||
class NWFilterFirewall(FirewallDriver):
|
class NWFilterFirewall(FirewallDriver):
|
||||||
"""
|
"""
|
||||||
@@ -1851,6 +1850,21 @@ class NWFilterFirewall(FirewallDriver):
|
|||||||
return 'nova-instance-%s' % (instance['name'])
|
return 'nova-instance-%s' % (instance['name'])
|
||||||
return 'nova-instance-%s-%s' % (instance['name'], nic_id)
|
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):
|
class IptablesFirewallDriver(FirewallDriver):
|
||||||
def __init__(self, execute=None, **kwargs):
|
def __init__(self, execute=None, **kwargs):
|
||||||
@@ -2040,6 +2054,10 @@ class IptablesFirewallDriver(FirewallDriver):
|
|||||||
|
|
||||||
return ipv4_rules, ipv6_rules
|
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):
|
def refresh_security_group_members(self, security_group):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user