]> git.proxmox.com Git - pve-manager.git/commitdiff
api: cephfs: add fs_name to 'is mds active' check
authorDominik Csapak <d.csapak@proxmox.com>
Mon, 25 Oct 2021 14:01:32 +0000 (16:01 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 11 Nov 2021 16:52:08 +0000 (17:52 +0100)
so that we check the mds for the correct cephfs we just added

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
PVE/API2/Ceph/FS.pm
PVE/Ceph/Services.pm

index 845c4fbd6d73df8f4feffcf29ec6f0ac74ed0336..9b2a8d709e3fd4f721999ddf144d391263b1c564 100644 (file)
@@ -187,7 +187,7 @@ __PACKAGE__->register_method ({
                print "Adding '$fs_name' to storage configuration...\n";
 
                my $waittime = 0;
-               while (!PVE::Ceph::Services::is_any_mds_active($rados)) {
+               while (!PVE::Ceph::Services::is_mds_active($rados, $fs_name)) {
                    if ($waittime >= 10) {
                        die "Need MDS to add storage, but none got active!\n";
                    }
index 2a1bbcfc338b7ff603c951974daadf7764d81eed..cda13c6a2fd57149ea0d385e8d3f1b1851c2177d 100644 (file)
@@ -218,23 +218,26 @@ sub get_cluster_mds_state {
     return $mds_state;
 }
 
-sub is_any_mds_active {
-    my ($rados) = @_;
+sub is_mds_active {
+    my ($rados, $fs_name) = @_;
 
     if (!defined($rados)) {
        $rados = PVE::RADOS->new();
     }
 
     my $mds_dump = $rados->mon_command({ prefix => 'mds stat' });
-    my $fs = $mds_dump->{fsmap}->{filesystems};
+    my $fsmap = $mds_dump->{fsmap}->{filesystems};
 
-    if (!($fs && scalar(@$fs) > 0)) {
+    if (!($fsmap && scalar(@$fsmap) > 0)) {
        return undef;
     }
-    my $active_mds = $fs->[0]->{mdsmap}->{info};
+    for my $fs (@$fsmap) {
+       next if defined($fs_name) && $fs->{mdsmap}->{fs_name} ne $fs_name;
 
-    for my $mds (values %$active_mds) {
-       return 1 if $mds->{state} eq 'up:active';
+       my $active_mds = $fs->{mdsmap}->{info};
+       for my $mds (values %$active_mds) {
+           return 1 if $mds->{state} eq 'up:active';
+       }
     }
 
     return 0;