[pve-devel] [PATCH storage] fix #1063: wait for librbd timeout when removing image

Dietmar Maurer dietmar at proxmox.com
Thu Jul 28 17:04:50 CEST 2016



On 07/28/2016 03:32 PM, Fabian Grünbichler wrote:
> 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;
>

such sleep is not reliable, because it can be interrupted by signal.



More information about the pve-devel mailing list