From 93bc8c53ef51bf4fbaafad0c2d1ad79dbff8eb8b Mon Sep 17 00:00:00 2001 From: Patrick Donnelly Date: Fri, 4 May 2018 10:11:10 -0700 Subject: [PATCH] MDSMonitor: promote standby after fs creation This avoids unnecessary health warnings. However, the original issue in i23885 still exists because the standbys are not available at fs creation time. If you create a new file system after these standbys are available, then you will observe that the promotion works to silence the warnings. Fixes: http://tracker.ceph.com/issues/23885 Signed-off-by: Patrick Donnelly --- src/mds/FSMap.cc | 7 ++++--- src/mds/FSMap.h | 6 +++--- src/mon/FSCommands.cc | 18 ++++++++++++++++-- src/vstart.sh | 1 + 4 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/mds/FSMap.cc b/src/mds/FSMap.cc index f4f539962d043..10ef3fae65f47 100644 --- a/src/mds/FSMap.cc +++ b/src/mds/FSMap.cc @@ -226,9 +226,8 @@ void FSMap::print_summary(Formatter *f, ostream *out) const } -void FSMap::create_filesystem(std::string_view name, - int64_t metadata_pool, int64_t data_pool, - uint64_t features) +std::shared_ptr FSMap::create_filesystem(std::string_view name, + int64_t metadata_pool, int64_t data_pool, uint64_t features) { auto fs = std::make_shared(); fs->mds_map.epoch = epoch; @@ -258,6 +257,8 @@ void FSMap::create_filesystem(std::string_view name, if (filesystems.size() == 1) { legacy_client_fscid = fs->fscid; } + + return fs; } void FSMap::reset_filesystem(fs_cluster_id_t fscid) diff --git a/src/mds/FSMap.h b/src/mds/FSMap.h index bf28546160115..6450edecf1f10 100644 --- a/src/mds/FSMap.h +++ b/src/mds/FSMap.h @@ -306,9 +306,9 @@ public: * Caller must already have validated all arguments vs. the existing * FSMap and OSDMap contents. */ - void create_filesystem(std::string_view name, - int64_t metadata_pool, int64_t data_pool, - uint64_t features); + std::shared_ptr create_filesystem( + std::string_view name, int64_t metadata_pool, + int64_t data_pool, uint64_t features); /** * Remove the filesystem (it must exist). Caller should already diff --git a/src/mon/FSCommands.cc b/src/mon/FSCommands.cc index 609388a309c93..6a8d9ab15954c 100644 --- a/src/mon/FSCommands.cc +++ b/src/mon/FSCommands.cc @@ -202,9 +202,23 @@ class FsNewHandler : public FileSystemCommandHandler mon->osdmon()->propose_pending(); // All checks passed, go ahead and create. - fsmap.create_filesystem(fs_name, metadata, data, - mon->get_quorum_con_features()); + auto fs = fsmap.create_filesystem(fs_name, metadata, data, + mon->get_quorum_con_features()); + ss << "new fs with metadata pool " << metadata << " and data pool " << data; + + // assign a standby to rank 0 to avoid health warnings + std::string _name; + mds_gid_t gid = fsmap.find_replacement_for({fs->fscid, 0}, _name, + g_conf->mon_force_standby_active); + + if (gid != MDS_GID_NONE) { + const auto &info = fsmap.get_info_gid(gid); + mon->clog->info() << info.human_name() << " assigned to filesystem " + << fs_name << " as rank 0"; + fsmap.promote(gid, fs, 0); + } + return 0; } diff --git a/src/vstart.sh b/src/vstart.sh index ab316efeff04f..d06cf708f17b1 100755 --- a/src/vstart.sh +++ b/src/vstart.sh @@ -771,6 +771,7 @@ EOF if [ $new -eq 1 ]; then if [ "$CEPH_NUM_FS" -gt "0" ] ; then + sleep 5 # time for MDS to come up as standby to avoid health warnings on fs creation if [ "$CEPH_NUM_FS" -gt "1" ] ; then ceph_adm fs flag set enable_multiple true --yes-i-really-mean-it fi -- 2.39.5