[pve-devel] [PATCH manager] fix #1043: prevent ceph destroypool when in use

Fabian Grünbichler f.gruenbichler at proxmox.com
Thu Jun 30 14:00:39 CEST 2016


tested and applied

> Dominik Csapak <d.csapak at proxmox.com> hat am 30. Juni 2016 um 11:46 geschrieben:
> 
> 
> also introduces a force parameter to this call
> if force is true, the call destroys the ceph pool
> even when it is use
> 
> Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
> ---
>  PVE/API2/Ceph.pm | 22 ++++++++++++++++++++++
>  1 file changed, 22 insertions(+)
> 
> diff --git a/PVE/API2/Ceph.pm b/PVE/API2/Ceph.pm
> index 58e5b35..29b57c7 100644
> --- a/PVE/API2/Ceph.pm
> +++ b/PVE/API2/Ceph.pm
> @@ -1321,6 +1321,12 @@ __PACKAGE__->register_method ({
>  		description => "The name of the pool. It must be unique.",
>  		type => 'string',
>  	    },
> +	    force => {
> +		description => "If true, destroys pool even if in use",
> +		type => 'boolean',
> +		optional => 1,
> +		default => 0,
> +	    }
>  	},
>      },
>      returns => { type => 'null' },
> @@ -1329,6 +1335,22 @@ __PACKAGE__->register_method ({
>  
>  	PVE::CephTools::check_ceph_inited();
>  
> +	# if not forced, destroy ceph pool only when no
> +	# vm disks are on it anymore
> +	if (!$param->{force}) {
> +	    my $storagecfg = PVE::Storage::config();
> +	    foreach my $storageid (keys %{$storagecfg->{ids}}) {
> +		my $storage = $storagecfg->{ids}->{$storageid};
> +		next if $storage->{type} ne 'rbd';
> +		next if $storage->{pool} ne $param->{name};
> +
> +		# check if any vm disks are on the pool
> +		my $res = PVE::Storage::vdisk_list($storagecfg, $storageid);
> +		die "ceph pool '$param->{name}' still in use by storage '$storageid'\n"
> +		    if @{$res->{$storageid}} != 0;
> +	    }
> +	}
> +
>  	my $rados = PVE::RADOS->new();
>  	# fixme: '--yes-i-really-really-mean-it'
>  	$rados->mon_command({ 
> -- 
> 2.1.4
> 
> 
> _______________________________________________
> pve-devel mailing list
> pve-devel at pve.proxmox.com
> http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
>




More information about the pve-devel mailing list