summaryrefslogtreecommitdiffstats
path: root/nova/compute
diff options
context:
space:
mode:
authorRick Harris <rconradharris@gmail.com>2012-11-06 19:09:06 +0000
committerRick Harris <rconradharris@gmail.com>2012-11-12 16:21:45 -0600
commit9f59d4af0dd06f8a70e2a647c5932472e0bf0f3a (patch)
treeed9477cffec3e208f8abb971fc35400bb9717f41 /nova/compute
parent24e86f40f7230544666ef99650353da76a1b9297 (diff)
Use base image for rescue instance.
Rescue mode was using the instance's current image when building the rescue VM. This is a problem because that image may be broken, hence the need for the rescue operation. Rescue should use the 'base' image instead. Fixes bug 1075701 Change-Id: Ie3e65cc75c4710f7b6391d5111cb096755e600d4
Diffstat (limited to 'nova/compute')
-rw-r--r--nova/compute/manager.py31
1 files changed, 28 insertions, 3 deletions
diff --git a/nova/compute/manager.py b/nova/compute/manager.py
index 235ecd7fa..8790ff1a4 100644
--- a/nova/compute/manager.py
+++ b/nova/compute/manager.py
@@ -1450,6 +1450,27 @@ class ComputeManager(manager.SchedulerDependentManager):
instance=instance)
self.driver.inject_file(instance, path, file_contents)
+ def _get_rescue_image_ref(self, context, instance):
+ """Determine what image should be used to boot the rescue VM. """
+ system_meta = self.db.instance_system_metadata_get(
+ context, instance['uuid'])
+
+ rescue_image_ref = system_meta.get('image_base_image_ref')
+
+ # 1. First try to use base image associated with instance's current
+ # image.
+ #
+ # The idea here is to provide the customer with a rescue environment
+ # which they are familiar with. So, if they built their instance off of
+ # a Debian image, their rescue VM wil also be Debian.
+ if rescue_image_ref:
+ return rescue_image_ref
+
+ # 2. As a last resort, use instance's current image
+ LOG.warn(_('Unable to find a different image to use for rescue VM,'
+ ' using instance\'s current image'))
+ return instance['image_ref']
+
@exception.wrap_exception(notifier=notifier, publisher_id=publisher_id())
@reverts_task_state
@wrap_instance_fault
@@ -1465,12 +1486,16 @@ class ComputeManager(manager.SchedulerDependentManager):
utils.generate_password(CONF.password_length))
network_info = self._get_instance_nw_info(context, instance)
- image_meta = _get_image_meta(context, instance['image_ref'])
+
+ # Boot the instance using the 'base' image instead of the user's
+ # current (possibly broken) image
+ rescue_image_ref = self._get_rescue_image_ref(context, instance)
+ rescue_image_meta = _get_image_meta(context, rescue_image_ref)
with self._error_out_instance_on_exception(context, instance['uuid']):
self.driver.rescue(context, instance,
- self._legacy_nw_info(network_info), image_meta,
- admin_password)
+ self._legacy_nw_info(network_info),
+ rescue_image_meta, admin_password)
current_power_state = self._get_power_state(context, instance)
self._instance_update(context,