mirror of
https://git.proxmox.com/git/pve-manager
synced 2025-08-05 10:58:09 +00:00
api: cephfs: wait for MDS to become active
A MDS gets only active once a FS is there, and we need an MDS active to be able to add a storage, as the CephFS plugin does an immediate mount check. As an MDS needs some time to get active we had a problematic time window where this mounting could fail. Wait for a MDS to get in active state. Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
34c1236c35
commit
a62d7bd966
@ -185,9 +185,22 @@ __PACKAGE__->register_method ({
|
||||
|
||||
die "$err\n";
|
||||
}
|
||||
print "Successfully create CephFS '$fs_name'\n";
|
||||
|
||||
if ($param->{add_storage}) {
|
||||
my $err;
|
||||
print "Adding '$fs_name' to storage configuration...\n";
|
||||
|
||||
my $waittime = 0;
|
||||
while (!PVE::CephTools::is_any_mds_active()) {
|
||||
if ($waittime >= 10) {
|
||||
die "Need MDS to add storage, but none got active!\n";
|
||||
}
|
||||
|
||||
print "Waiting for an MDS to become active\n";
|
||||
sleep(1);
|
||||
$waittime++;
|
||||
}
|
||||
|
||||
eval {
|
||||
PVE::API2::Storage::Config->create({
|
||||
type => 'cephfs',
|
||||
|
@ -364,6 +364,24 @@ sub get_cluster_mds_state {
|
||||
return $mds_state;
|
||||
}
|
||||
|
||||
sub is_any_mds_active {
|
||||
my ($rados) = @_;
|
||||
|
||||
if (!defined($rados)) {
|
||||
$rados = PVE::RADOS->new();
|
||||
}
|
||||
|
||||
my $mds_dump = $rados->mon_command({ prefix => 'mds stat' });
|
||||
my $fs = $mds_dump->{fsmap}->{filesystems};
|
||||
|
||||
if (!($fs && scalar(@$fs) > 0)) {
|
||||
return undef;
|
||||
}
|
||||
my $active_mds = $fs->[0]->{mdsmap}->{info};
|
||||
|
||||
return scalar(keys %$active_mds) > 0;
|
||||
}
|
||||
|
||||
sub create_mds {
|
||||
my ($id, $rados) = @_;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user