reported in drive-mirror,

if we cancel the job and we try to free the rbd volume,
it seem that rbd storage take 2-3 seconds to release the volume
or it's throwing an "image still has watchers".

This patch try to wait 10s with 10retries before dying

Signed-off-by: Alexandre Derumier <[email protected]>
---
 PVE/Storage/RBDPlugin.pm |   15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/PVE/Storage/RBDPlugin.pm b/PVE/Storage/RBDPlugin.pm
index 1026d81..3bfff4c 100644
--- a/PVE/Storage/RBDPlugin.pm
+++ b/PVE/Storage/RBDPlugin.pm
@@ -409,7 +409,20 @@ sub free_image {
     run_rbd_command($cmd, errmsg => "rbd snap purge '$volname' error");
 
     $cmd = &$rbd_cmd($scfg, $storeid, 'rm', $name);
-    run_rbd_command($cmd, errmsg => "rbd rm '$volname' error");
+
+    my $i = 0;
+    while(1){
+       $i++;
+       eval {
+           run_rbd_command($cmd, errmsg => "rbd rm '$volname' error");
+       };
+       my $err = $@;
+
+       sleep 1 if ($err && $err =~ m/image still has watchers/);
+
+       die "image still has watchers" if $i > 10;
+       last if !$err;
+    }
 
     return undef;
 }
-- 
1.7.10.4

_______________________________________________
pve-devel mailing list
[email protected]
http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to