summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoresubramanian <esubramanian@godaddy.com>2020-06-08 23:08:30 -0700
committerElancheran S <tsecheran@yahoo.com>2020-09-11 21:14:36 +0000
commit06df7cae31246e233dd5cf9b92c6484b519156de (patch)
treee7a835d08c42337b0cabd9845a13596eb550205c
parent5cebdb7b718bf7765de9257b49448868ba673af5 (diff)
downloadnova-06df7cae31246e233dd5cf9b92c6484b519156de.tar.gz
Removes the delta file once image is extracted
When creating a live snapshot of an instance, nova creates a copy of the instance disk using a QEMU shallow rebase. This copy - the delta file - is then extracted and uploaded. The delta file will eventually be deleted, when the temporary working directory nova is using for the live snapshot is discarded, however, until this happens, we will use 3x the size of the image of host disk space: the original disk, the delta file, and the extracted file. This can be problematic when concurrent snapshots of multiple instances are requested at once. The solution is simple: delete the delta file after it has been extracted and is no longer necessary. Change-Id: I15e9975fa516d81e7d34206e5a4069db5431caa9 Closes-Bug: #1881727 (cherry picked from commit d2af7ca7a5c862f53f18c00ac76fc85336fa79e6) (cherry picked from commit e51555b3f0324b8b72a2b3280a1c30e104b6d8ea)
-rw-r--r--nova/tests/unit/virt/libvirt/test_driver.py4
-rw-r--r--nova/virt/libvirt/driver.py4
2 files changed, 7 insertions, 1 deletions
diff --git a/nova/tests/unit/virt/libvirt/test_driver.py b/nova/tests/unit/virt/libvirt/test_driver.py
index 0b1f8961c5..ea9b6151fe 100644
--- a/nova/tests/unit/virt/libvirt/test_driver.py
+++ b/nova/tests/unit/virt/libvirt/test_driver.py
@@ -19142,10 +19142,11 @@ class LibvirtConnTestCase(test.NoDBTestCase,
disconnect_volume.assert_called_once_with(self.context,
mock.sentinel.new_connection_info, instance)
+ @mock.patch.object(fileutils, 'delete_if_exists')
@mock.patch('nova.virt.libvirt.guest.BlockDevice.is_job_complete')
@mock.patch('nova.privsep.path.chown')
def _test_live_snapshot(
- self, mock_chown, mock_is_job_complete,
+ self, mock_chown, mock_is_job_complete, mock_delete,
can_quiesce=False, require_quiesce=False):
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI())
mock_dom = mock.MagicMock()
@@ -19203,6 +19204,7 @@ class LibvirtConnTestCase(test.NoDBTestCase,
mock_chown.assert_called_once_with(dltfile, uid=os.getuid())
mock_snapshot.assert_called_once_with(dltfile, "qcow2",
dstfile, "qcow2")
+ mock_delete.assert_called_once_with(dltfile)
mock_define.assert_called_once_with(xmldoc)
mock_quiesce.assert_any_call(mock.ANY, self.test_instance,
mock.ANY, True)
diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py
index 5043589073..6a120629c2 100644
--- a/nova/virt/libvirt/driver.py
+++ b/nova/virt/libvirt/driver.py
@@ -2621,6 +2621,10 @@ class LibvirtDriver(driver.ComputeDriver):
libvirt_utils.extract_snapshot(disk_delta, 'qcow2',
out_path, image_format)
+ # Remove the disk_delta file once the snapshot extracted, so that
+ # it doesn't hang around till the snapshot gets uploaded
+ fileutils.delete_if_exists(disk_delta)
+
def _volume_snapshot_update_status(self, context, snapshot_id, status):
"""Send a snapshot status update to Cinder.