fix #1043: prevent ceph destroypool when in use
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@proxmox.com>
This commit is contained in:
parent
837f149a72
commit
e33712e608
@ -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({
|
||||
|
Loading…
x
Reference in New Issue
Block a user