]> git.proxmox.com Git - pve-manager.git/commitdiff
ceph/destroypool: move image check into worker
authorFabian Grünbichler <f.gruenbichler@proxmox.com>
Tue, 5 Sep 2017 12:59:41 +0000 (14:59 +0200)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Thu, 7 Sep 2017 09:38:20 +0000 (11:38 +0200)
vdisk_list can potentially take very long, and we don't want
the API request to time out.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
PVE/API2/Ceph.pm

index c28c4f7d298e5d54e5da09d2c15f830e8ddcc407..9fef04878f9602bc7db8cee3bb90e23b2e0d4a9a 100644 (file)
@@ -1843,23 +1843,25 @@ __PACKAGE__->register_method ({
            if $param->{remove_storages};
 
        my $pool = $param->{name};
-       my $storages = $get_storages->($pool);
-
-       # 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 %$storages) {
-               my $storage = $storages->{$storageid};
-
-               # check if any vm disks are on the pool
-               my $res = PVE::Storage::vdisk_list($storagecfg, $storageid);
-               die "ceph pool '$pool' still in use by storage '$storageid'\n"
-                   if @{$res->{$storageid}} != 0;
-           }
-       }
 
        my $worker = sub {
+           my $storages = $get_storages->($pool);
+
+           # 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 $storeid (keys %$storages) {
+                   my $storage = $storages->{$storeid};
+
+                   # check if any vm disks are on the pool
+                   print "checking storage '$storeid' for RBD images..\n";
+                   my $res = PVE::Storage::vdisk_list($storagecfg, $storeid);
+                   die "ceph pool '$pool' still in use by storage '$storeid'\n"
+                       if @{$res->{$storeid}} != 0;
+               }
+           }
+
            my $rados = PVE::RADOS->new();
            # fixme: '--yes-i-really-really-mean-it'
            $rados->mon_command({