[pve-devel] [PATCH storage] fix #1063: wait for librbd timeout when removing image
Fabian Grünbichler
f.gruenbichler at proxmox.com
Thu Jul 28 15:32:59 CEST 2016
upon a client crash/kill, there is a 30 second timeout until
the associated watcher is removed. until then, removing the
image is not possible.
krbd does not suffer from this, because "rbd map/unmap"
makes the watcher creation and destruction explicit.
---
Note: the pve-access-control patch series for worker stopping
is not strictly required for this to work, but makes the
user experience a lot better.
PVE/Storage/RBDPlugin.pm | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/PVE/Storage/RBDPlugin.pm b/PVE/Storage/RBDPlugin.pm
index 7a08ff5..96b41e5 100644
--- a/PVE/Storage/RBDPlugin.pm
+++ b/PVE/Storage/RBDPlugin.pm
@@ -458,7 +458,18 @@ 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");
+ eval {
+ run_rbd_command($cmd, errmsg => "rbd rm '$volname' error");
+ };
+ my $err = $@;
+
+ if ($err && !$scfg->{krbd} && $err =~ m/image still has watchers$/) {
+ warn "Waiting 30s for rbd client to timeout before removing\n";
+ sleep 30;
+ run_rbd_command($cmd, errmsg => "rbd rm '$volname' error");
+ } else {
+ die $err if $err;
+ }
return undef;
}
--
2.1.4
More information about the pve-devel
mailing list