Merge "Add Workaround to Disable Live Migration Pre-check"

This commit is contained in:
Zuul
2025-10-27 21:40:56 +00:00
committed by Gerrit Code Review
4 changed files with 86 additions and 3 deletions

View File

@@ -183,6 +183,40 @@ options:
homedir - user's home directory
username - username
.
skip_cpu_compare_at_startup:
type: boolean
default: False
description: |
This will skip the CPU comparison call at the startup of Compute service
and lets libvirt handle it.
.
This is a workaround to avoid live migration erroneous failures in the
Nova pre-migration check, which is caused by mixed usage of different
libvirt APIs. If the hypervisors are incompatible, libvirt detects the
the incompatibility and rollsback the migration. There is a marginal
performance hit in this case since the libvirt check comes later than the
pre-migration check
.
# NOTE: This can be removed when https://launchpad.net/nova/+bug/2039803
# is fixed
skip_cpu_compare_on_dest:
type: boolean
default: False
description: |
With the libvirt driver, during live migration, skip comparing guest CPU
with the destination host. When using QEMU >= 2.9 and libvirt >= 4.4.0,
libvirt will do the correct thing with respect to checking CPU
compatibility on the destination host during live migration.
.
This is a workaround to avoid live migration erroneous failures in the
Nova pre-migration check, which is caused by mixed usage of different
libvirt APIs. If the hypervisors are incompatible, libvirt detects the
the incompatibility and rollsback the migration. There is a marginal
performance hit in this case since the libvirt check comes later than the
pre-migration check
.
# NOTE: This can be removed when https://launchpad.net/nova/+bug/2039803
# is fixed
instances-path:
type: string
default:

View File

@@ -257,6 +257,10 @@ class NovaComputeLibvirtContext(context.OSContextGenerator):
config('live-migration-permit-post-copy')
ctxt['live_migration_permit_auto_converge'] = \
config('live-migration-permit-auto-converge')
ctxt['skip_cpu_compare_at_startup'] = \
config('skip_cpu_compare_at_startup')
ctxt['skip_cpu_compare_on_dest'] = \
config('skip_cpu_compare_on_dest')
if config('instances-path') is not None:
ctxt['instances_path'] = config('instances-path')

View File

@@ -369,6 +369,12 @@ disable_libvirt_livesnapshot = False
{% if ensure_libvirt_rbd_instance_dir_cleanup -%}
ensure_libvirt_rbd_instance_dir_cleanup = {{ ensure_libvirt_rbd_instance_dir_cleanup }}
{% endif -%}
{% if skip_cpu_compare_at_startup -%}
skip_cpu_compare_at_startup = {{ skip_cpu_compare_at_startup }}
{% endif -%}
{% if skip_cpu_compare_on_dest -%}
skip_cpu_compare_on_dest = {{ skip_cpu_compare_on_dest }}
{% endif -%}
{% include "parts/section-ephemeral" %}

View File

@@ -565,7 +565,9 @@ class NovaComputeContextTests(CharmTestCase):
'inject_partition': -2,
'block_device_allocate_retries': 300,
'reserved_host_disk': 0,
'reserved_host_memory': 512}, libvirt())
'reserved_host_memory': 512,
'skip_cpu_compare_at_startup': False,
'skip_cpu_compare_on_dest': False}, libvirt())
def test_libvirt_context_without_migration_network(self):
self.kv.return_value = FakeUnitdata(**{'host_uuid': self.host_uuid})
@@ -629,7 +631,9 @@ class NovaComputeContextTests(CharmTestCase):
'block_device_allocate_retries': 300,
'default_ephemeral_format': 'ext4',
'reserved_host_disk': 0,
'reserved_host_memory': 512}, libvirt())
'reserved_host_memory': 512,
'skip_cpu_compare_at_startup': False,
'skip_cpu_compare_on_dest': False}, libvirt())
def test_libvirt_bin_context_migration_tcp_listen_with_post_copy(self):
self.kv.return_value = FakeUnitdata(**{'host_uuid': self.host_uuid})
@@ -659,7 +663,42 @@ class NovaComputeContextTests(CharmTestCase):
'inject_partition': -2,
'block_device_allocate_retries': 300,
'reserved_host_disk': 0,
'reserved_host_memory': 512}, libvirt())
'reserved_host_memory': 512,
'skip_cpu_compare_at_startup': False,
'skip_cpu_compare_on_dest': False}, libvirt())
def test_libvirt_skip_cpu_compare(self):
self.kv.return_value = FakeUnitdata(**{'host_uuid': self.host_uuid})
self.lsb_release.return_value = {'DISTRIB_CODENAME': 'lucid'}
self.test_config.set('enable-live-migration', True)
self.test_config.set('skip_cpu_compare_at_startup', True)
self.test_config.set('skip_cpu_compare_on_dest', True)
libvirt = context.NovaComputeLibvirtContext()
self.assertEqual(
{'libvirtd_opts': '-d -l',
'libvirt_user': 'libvirtd',
'arch': platform.machine(),
'ksm': 'AUTO',
'kvm_hugepages': 0,
'listen_tls': 0,
'host_uuid': self.host_uuid,
'live_migration_uri': 'qemu+ssh://%s/system',
'live_migration_completion_timeout': 800,
'live_migration_downtime': 500,
'live_migration_downtime_delay': 75,
'live_migration_downtime_steps': 10,
'live_migration_permit_auto_converge': False,
'live_migration_permit_post_copy': False,
'default_ephemeral_format': 'ext4',
'force_raw_images': True,
'inject_password': False,
'inject_partition': -2,
'block_device_allocate_retries': 300,
'reserved_host_disk': 0,
'reserved_host_memory': 512,
'skip_cpu_compare_at_startup': True,
'skip_cpu_compare_on_dest': True}, libvirt())
def test_libvirt_disk_cachemodes(self):
self.kv.return_value = FakeUnitdata(**{'host_uuid': self.host_uuid})