From 3b62ab5e40e949e4f2431d3db985c8f2c20d70b5 Mon Sep 17 00:00:00 2001 From: Nicolas Simonds Date: Mon, 6 Oct 2014 15:24:58 -0700 Subject: [PATCH] Make _get_instance_block_device_info preserve root_device_name On hard reboots, nova.compute.manager.ComputeManager._get_instance_block_device_info will faithfully reconstruct all of the block_device_info attributes that the instance needs, except for the root_device_name. This causes the instance to effectively lose its disk configurations on hard reboots. This patch set will preserve the root_device_name if it is defined for the instance. Conflicts: nova/tests/unit/compute/test_compute.py (cherry picked from commit ee435b4267b18eb910f7169792ea62244905733a) Closes-Bug: #1378132 Change-Id: Ia36b1d6170ad120f794aa16d41ed4275b4b11f22 --- nova/compute/manager.py | 3 +++ nova/tests/compute/test_compute.py | 11 +++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/nova/compute/manager.py b/nova/compute/manager.py index 8d444a98b0dd..f44273810712 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -1975,7 +1975,10 @@ class ComputeManager(manager.Manager): # Get swap out of the list swap = driver_block_device.get_swap(swap) + root_device_name = instance.get('root_device_name') + return {'swap': swap, + 'root_device_name': root_device_name, 'ephemerals': ephemerals, 'block_device_mapping': block_device_mapping} diff --git a/nova/tests/compute/test_compute.py b/nova/tests/compute/test_compute.py index 69563a5bd296..ca715268d13b 100644 --- a/nova/tests/compute/test_compute.py +++ b/nova/tests/compute/test_compute.py @@ -2793,6 +2793,7 @@ class ComputeTestCase(BaseTestCase): expected = { 'swap': None, 'ephemerals': [], + 'root_device_name': None, 'block_device_mapping': [{ 'connection_info': { 'driver_volume_type': 'rbd' @@ -2824,6 +2825,7 @@ class ComputeTestCase(BaseTestCase): expected = { 'swap': None, 'ephemerals': [], + 'root_device_name': None, 'block_device_mapping': [{ 'connection_info': { 'driver_volume_type': 'rbd' @@ -2888,7 +2890,8 @@ class ComputeTestCase(BaseTestCase): 'virtual_name': 'ephemeral0'}, {'device_name': '/dev/vdc', 'num': 1, 'size': 2, 'virtual_name': 'ephemeral1'}], - 'block_device_mapping': [] + 'block_device_mapping': [], + 'root_device_name': None } block_device_info = ( @@ -5423,6 +5426,7 @@ class ComputeTestCase(BaseTestCase): self.mox.StubOutWithMock(self.compute.driver, 'pre_live_migration') self.compute.driver.pre_live_migration(mox.IsA(c), mox.IsA(instance), {'swap': None, 'ephemerals': [], + 'root_device_name': None, 'block_device_mapping': []}, mox.IgnoreArg(), mox.IgnoreArg(), @@ -5492,7 +5496,8 @@ class ComputeTestCase(BaseTestCase): 'rollback_live_migration_at_destination') block_device_info = { - 'swap': None, 'ephemerals': [], 'block_device_mapping': []} + 'swap': None, 'ephemerals': [], 'block_device_mapping': [], + 'root_device_name': None} self.compute.driver.get_instance_disk_info( instance.name, block_device_info=block_device_info).AndReturn('fake_disk') @@ -5668,6 +5673,7 @@ class ComputeTestCase(BaseTestCase): post_live_migration.assert_has_calls([ mock.call(c, instance, {'swap': None, 'ephemerals': [], + 'root_device_name': None, 'block_device_mapping': []}, None)]) unfilter_instance.assert_has_calls([mock.call(instance, [])]) migration = {'source_compute': srchost, @@ -5826,6 +5832,7 @@ class ComputeTestCase(BaseTestCase): 'rollback_live_migration_at_destination') self.compute.driver.rollback_live_migration_at_destination(c, instance, [], {'swap': None, 'ephemerals': [], + 'root_device_name': None, 'block_device_mapping': []}, destroy_disks=True, migrate_data=None)