From 52f6981aa35e27c48587ad2320891db8364edd02 Mon Sep 17 00:00:00 2001 From: Kravchenko Pavel Date: Tue, 9 Apr 2013 10:57:53 +0300 Subject: Evacuated instance disk not deleted Adds disk cleanup in case instance is not on shared storage. Added new methods to compute.rpc and virt.driver interface to validate that instance files located on shared storage on remote compute node. Fixes bug 1156269 Change-Id: Ia4cc601d0d824ba04f595df96461cfa85ad3b90c --- nova/virt/driver.py | 27 +++++++++++++++++++++++++++ nova/virt/libvirt/driver.py | 19 +++++++++++++++++++ 2 files changed, 46 insertions(+) (limited to 'nova/virt') diff --git a/nova/virt/driver.py b/nova/virt/driver.py index 827a2b782..b3854aba0 100755 --- a/nova/virt/driver.py +++ b/nova/virt/driver.py @@ -487,6 +487,33 @@ class ComputeDriver(object): """ raise NotImplementedError() + def check_instance_shared_storage_local(self, ctxt, instance): + """Check if instance files located on shared storage. + + This runs check on the destination host, and then calls + back to the source host to check the results. + + :param ctxt: security context + :param instance: nova.db.sqlalchemy.models.Instance + """ + raise NotImplementedError() + + def check_instance_shared_storage_remote(self, ctxt, data): + """Check if instance files located on shared storage. + + :param context: security context + :param data: result of check_instance_shared_storage_local + """ + raise NotImplementedError() + + def check_instance_shared_storage_cleanup(self, ctxt, data): + """Do cleanup on host after check_instance_shared_storage calls + + :param ctxt: security context + :param data: result of check_instance_shared_storage_local + """ + pass + def check_can_live_migrate_destination(self, ctxt, instance_ref, src_compute_info, dst_compute_info, block_migration=False, diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py index 498ef1d82..4c1df80b8 100755 --- a/nova/virt/libvirt/driver.py +++ b/nova/virt/libvirt/driver.py @@ -2820,6 +2820,25 @@ class LibvirtDriver(driver.ComputeDriver): 'disk_available_least': _get_disk_available_least()} return dic + def check_instance_shared_storage_local(self, ctxt, instance): + dirpath = libvirt_utils.get_instance_path(instance) + + if not os.path.exists(dirpath): + return None + + fd, tmp_file = tempfile.mkstemp(dir=dirpath) + LOG.debug(_("Creating tmpfile %s to verify with other " + "compute node that the instance is on " + "the same shared storage.") % tmp_file) + os.close(fd) + return {"filename": tmp_file} + + def check_instance_shared_storage_remote(self, ctxt, data): + return os.path.exists(data['filename']) + + def check_instance_shared_storage_cleanup(self, ctxt, data): + utils.delete_if_exists(data["filename"]) + def check_can_live_migrate_destination(self, ctxt, instance_ref, src_compute_info, dst_compute_info, block_migration=False, -- cgit