From 96e047c6c8b45d3f76cdbab9d10405f046ade271 Mon Sep 17 00:00:00 2001 From: Arik Hadas Date: Tue, 4 Jul 2023 13:55:06 +0300 Subject: [PATCH] Teardown replica when replication fails When disk replication fails during live storage migration, we detect it properly, fail the operation and remove the disk from the destination storage domain. However, we didn't tear down the replica on the host that executes the replication and therefore, if the removal of the destination disk was done on a different host, we had leftovers remaining on the host that executed the replication. This patch changes the diskReplicateFinish function to tear down the replicate when the corresponding block job doesn't exist in order to prevent this scenario of having leftovers on the host that could lead to data corruption later on. Bug-Url: https://bugzilla.redhat.com/2193392 Signed-off-by: Arik Hadas --- lib/vdsm/virt/vm.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/vdsm/virt/vm.py b/lib/vdsm/virt/vm.py index 0ffa8a7c0..4cfe89a01 100644 --- a/lib/vdsm/virt/vm.py +++ b/lib/vdsm/virt/vm.py @@ -4443,6 +4443,13 @@ def diskReplicateFinish(self, srcDisk, dstDisk): "srcDisk: %r, job: %r)", drive.name, srcDisk, blkJobInfo) + # best-effort attempt to tear down the replica + try: + self.cif.teardownVolumePath(drive.diskReplicate) + except Exception as e: + self.log.exception("Failed to teardown replica of %s: %s", + drive, e) + # Making sure that we don't have any stale information self._delDiskReplica(drive) return response.error('replicaErr')