]> git.proxmox.com Git - pve-storage.git/commitdiff
rbd: warn if no stats for a pool could be gathered
authorStoiko Ivanov <s.ivanov@proxmox.com>
Tue, 3 May 2022 11:31:40 +0000 (13:31 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 13 May 2022 12:08:13 +0000 (14:08 +0200)
happens in case of a mistyped poolname, and the new message should be
more helpful than:
`Use of uninitialized value $free in addition (+) at \
/usr/share/perl5/PVE/Storage/RBDPlugin.pm line 64`

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
PVE/Storage/RBDPlugin.pm

index 9ee6a3759357bf1eab43deb668a5c69b4f328b5b..fb48c3f3f5b44804a6681a327849efda31dbccfb 100644 (file)
@@ -634,6 +634,11 @@ sub status {
 
     my ($d) = grep { $_->{name} eq $pool } @{$df->{pools}};
 
+    if (!defined($d)) {
+       warn "could not get usage stats for pool '$pool'\n";
+       return;
+    }
+
     # max_avail -> max available space for data w/o replication in the pool
     # bytes_used -> data w/o replication in the pool
     my $free = $d->{stats}->{max_avail};