[pve-devel] [PATCH] rbd: purge snapshots before delete volume

Alexandre Derumier aderumier at odiso.com
Wed Oct 31 11:24:53 CET 2012


we can't delete a rbd volume if snapshots exist

Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
 PVE/Storage/RBDPlugin.pm |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/PVE/Storage/RBDPlugin.pm b/PVE/Storage/RBDPlugin.pm
index 33ae853..cb7a823 100644
--- a/PVE/Storage/RBDPlugin.pm
+++ b/PVE/Storage/RBDPlugin.pm
@@ -214,7 +214,10 @@ sub alloc_image {
 sub free_image {
     my ($class, $storeid, $scfg, $volname) = @_;
 
-    my $cmd = &$rbd_cmd($scfg, $storeid, 'rm', $volname);
+    my $cmd = &$rbd_cmd($scfg, $storeid, 'snap', 'purge',  $volname);
+    run_command($cmd, errmsg => "rbd snap purge $volname' error", outfunc => sub {}, errfunc => sub {});
+
+    $cmd = &$rbd_cmd($scfg, $storeid, 'rm', $volname);
     run_command($cmd, errmsg => "rbd rm $volname' error", outfunc => sub {}, errfunc => sub {});
 
     return undef;
-- 
1.7.10.4




More information about the pve-devel mailing list