Comment 2 for bug 1626230

Revision history for this message
Paul Carlton (paul-carlton2) wrote :

Looking at this further I think there is a way to fix the immediate issue with evacuate by catching the exception raised by spawn in the compute manager and calling the driver again to destroy the instance and delete the files (if they are not on shared storage). This can be achieved by passing the on_shared_storage setting to _rebuild_default_impl in the compute manager and catching the spawn error and cleaning up if it is an evacuate as follows

            try:
                self.driver.spawn(context, instance, image_meta, injected_files,
                                  admin_password, network_info=network_info,
                                  block_device_info=new_block_device_info)
            except exception as e:
                if recreate:
                    driver.destory(context, instance, network_info,
                                   new_block_device_info,
                                   destroy_disks=not on_shared_storage)
                raise e

Changing the libvirt driver to clean up instances when spawn fails will not work. Trouble is driver spawn doesn't know if it is part of a rebuild for evacuate or normal rebuild, boot or unshelve and worse still it doesn't know if the instance files are on shared storage. Also, libvirt users are currently used to a failed boot/rebuild leaving the instance partially booted. A valid operator action is to deal with the instance being in error state following a spawn failure by looking at the compute manager log and if the instance is defined but not running try and start it, in the past I've found this has helped me to work out why it failed to spawn.