[pve-devel] [PATCH manager v2 05/11] api: cephfs: add fs_name to 'is mds active' check

Dominik Csapak d.csapak at proxmox.com
Mon Oct 25 16:01:32 CEST 2021


so that we check the mds for the correct cephfs we just added

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 PVE/API2/Ceph/FS.pm  |  2 +-
 PVE/Ceph/Services.pm | 17 ++++++++++-------
 2 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/PVE/API2/Ceph/FS.pm b/PVE/API2/Ceph/FS.pm
index 845c4fbd..9b2a8d70 100644
--- a/PVE/API2/Ceph/FS.pm
+++ b/PVE/API2/Ceph/FS.pm
@@ -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";
 		    }
diff --git a/PVE/Ceph/Services.pm b/PVE/Ceph/Services.pm
index e8cc23dc..abe524e0 100644
--- a/PVE/Ceph/Services.pm
+++ b/PVE/Ceph/Services.pm
@@ -214,23 +214,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;
-- 
2.30.2






More information about the pve-devel mailing list