From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 0B80077FE9 for ; Mon, 25 Oct 2021 16:02:16 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id E36C92402C for ; Mon, 25 Oct 2021 16:01:45 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id B107C23F00 for ; Mon, 25 Oct 2021 16:01:41 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 55A1345F84 for ; Mon, 25 Oct 2021 16:01:41 +0200 (CEST) From: Dominik Csapak To: pve-devel@lists.proxmox.com Date: Mon, 25 Oct 2021 16:01:32 +0200 Message-Id: <20211025140139.2015470-7-d.csapak@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211025140139.2015470-1-d.csapak@proxmox.com> References: <20211025140139.2015470-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.275 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] [PATCH manager v2 05/11] api: cephfs: add fs_name to 'is mds active' check X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Oct 2021 14:02:16 -0000 so that we check the mds for the correct cephfs we just added Signed-off-by: Dominik Csapak --- 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