[lxc-devel] [lxd/master] lxd/storage/drivers/driver/zfs/volumes: Delete volume on error in CreateVolumeFromCopy
tomponline on Github
lxc-bot at linuxcontainers.org
Thu Apr 23 08:36:15 UTC 2020
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 526 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20200423/01cc757e/attachment.bin>
-------------- next part --------------
From ea4958b403149eaae30c59e873ecaa057b1c077c Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at canonical.com>
Date: Thu, 23 Apr 2020 09:34:39 +0100
Subject: [PATCH] lxd/storage/drivers/driver/zfs/volumes: Delete volume on
error in CreateVolumeFromCopy
This was previously relying on the backend_lxd revert logic, but now we need CreateVolumeFromCopy to correctly revert on error so we can call it again if needed.
Signed-off-by: Thomas Parrott <thomas.parrott at canonical.com>
---
lxd/storage/drivers/driver_zfs_volumes.go | 3 +++
1 file changed, 3 insertions(+)
diff --git a/lxd/storage/drivers/driver_zfs_volumes.go b/lxd/storage/drivers/driver_zfs_volumes.go
index d5e48e96b2..b39b957a9b 100644
--- a/lxd/storage/drivers/driver_zfs_volumes.go
+++ b/lxd/storage/drivers/driver_zfs_volumes.go
@@ -514,6 +514,9 @@ func (d *zfs) CreateVolumeFromCopy(vol Volume, srcVol Volume, copySnapshots bool
if err != nil {
return err
}
+
+ // Delete on revert.
+ revert.Add(func() { d.DeleteVolume(vol, op) })
}
// Apply the properties.
More information about the lxc-devel
mailing list