From fa90a277b95671270c14e6a7c55f4925e74715a3 Mon Sep 17 00:00:00 2001 From: zhufl Date: Thu, 29 Aug 2019 11:08:45 +0800 Subject: [PATCH] [Trivial]Remove unused helper should_switch_to_postcopy Helper should_switch_to_postcopy is no longer used after 4c3698c0b63ef0a5298cd94a8f23f87605bfc0f5, this is to remove it. Change-Id: I3128b9f39a41bfb147596a43d0ae8e699cd2b02f --- .../tests/unit/virt/libvirt/test_migration.py | 20 ----------- nova/virt/libvirt/migration.py | 33 ------------------- 2 files changed, 53 deletions(-) diff --git a/nova/tests/unit/virt/libvirt/test_migration.py b/nova/tests/unit/virt/libvirt/test_migration.py index b4d8536b5248..0d18132663c0 100644 --- a/nova/tests/unit/virt/libvirt/test_migration.py +++ b/nova/tests/unit/virt/libvirt/test_migration.py @@ -988,26 +988,6 @@ class MigrationMonitorTestCase(test.NoDBTestCase): self.assertFalse(migration.should_trigger_timeout_action( self.instance, 4500, 9000, "running")) - def test_live_migration_postcopy_switch(self): - # Migration progress is not fast enough - self.assertTrue(migration.should_switch_to_postcopy( - 2, 100, 105, "running")) - - def test_live_migration_postcopy_switch_already_switched(self): - # Migration already running in postcopy mode - self.assertFalse(migration.should_switch_to_postcopy( - 2, 100, 105, "running (post-copy)")) - - def test_live_migration_postcopy_switch_too_soon(self): - # First memory iteration not completed yet - self.assertFalse(migration.should_switch_to_postcopy( - 1, 100, 105, "running")) - - def test_live_migration_postcopy_switch_fast_progress(self): - # Migration progress is good - self.assertFalse(migration.should_switch_to_postcopy( - 2, 100, 155, "running")) - @mock.patch.object(libvirt_guest.Guest, "migrate_configure_max_downtime") def test_live_migration_update_downtime_no_steps(self, mock_dt): diff --git a/nova/virt/libvirt/migration.py b/nova/virt/libvirt/migration.py index 85ecac9acd6a..b436942201f5 100644 --- a/nova/virt/libvirt/migration.py +++ b/nova/virt/libvirt/migration.py @@ -408,39 +408,6 @@ def should_trigger_timeout_action(instance, elapsed, completion_timeout, return False -def should_switch_to_postcopy(memory_iteration, current_data_remaining, - previous_data_remaining, migration_status): - """Determine if the migration should be switched to postcopy mode - - :param memory_iteration: Number of memory iterations during the migration - :param current_data_remaining: amount of memory to be transferred - :param previous_data_remaining: previous memory to be transferred - :param migration_status: current status of the migration - - Check the progress after the first memory iteration to determine if the - migration should be switched to post-copy mode - - Avoid post-copy switch if already running in post-copy mode - - :returns: True if migration should be switched to postcopy mode, - False otherwise - """ - if (migration_status == 'running (post-copy)' or - previous_data_remaining <= 0): - return False - - if memory_iteration > 1: - progress_percentage = round((previous_data_remaining - - current_data_remaining) * - 100 / previous_data_remaining) - # If migration progress is less than 10% per iteration after the - # first memory page copying pass, the migration is switched to - # postcopy mode - if progress_percentage < 10: - return True - return False - - def update_downtime(guest, instance, olddowntime, downtime_steps, elapsed):