mirror of
https://git.proxmox.com/git/pve-manager
synced 2025-08-17 20:07:27 +00:00
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
f9078dd525
commit
76dc2ad016
@ -1321,6 +1321,12 @@ __PACKAGE__->register_method ({
|
|||||||
description => "The name of the pool. It must be unique.",
|
description => "The name of the pool. It must be unique.",
|
||||||
type => 'string',
|
type => 'string',
|
||||||
},
|
},
|
||||||
|
force => {
|
||||||
|
description => "If true, destroys pool even if in use",
|
||||||
|
type => 'boolean',
|
||||||
|
optional => 1,
|
||||||
|
default => 0,
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
returns => { type => 'null' },
|
returns => { type => 'null' },
|
||||||
@ -1329,6 +1335,22 @@ __PACKAGE__->register_method ({
|
|||||||
|
|
||||||
PVE::CephTools::check_ceph_inited();
|
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();
|
my $rados = PVE::RADOS->new();
|
||||||
# fixme: '--yes-i-really-really-mean-it'
|
# fixme: '--yes-i-really-really-mean-it'
|
||||||
$rados->mon_command({
|
$rados->mon_command({
|
||||||
|
Loading…
Reference in New Issue
Block a user