From: Kefu Chai Date: Thu, 7 Sep 2017 05:12:15 +0000 (+0800) Subject: mon,monmap: use new style config opts X-Git-Tag: v13.0.1~976^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F17539%2Fhead;p=ceph.git mon,monmap: use new style config opts Signed-off-by: Kefu Chai --- diff --git a/src/ceph_mon.cc b/src/ceph_mon.cc index 3663bb04e4b..41a6ee0eb10 100644 --- a/src/ceph_mon.cc +++ b/src/ceph_mon.cc @@ -247,7 +247,6 @@ int main(int argc, const char **argv) flags, "mon_data"); ceph_heap_profiler_init(); - uuid_d fsid; std::string val; for (std::vector::iterator i = args.begin(); i != args.end(); ) { if (ceph_argparse_double_dash(args, i)) { @@ -331,10 +330,11 @@ int main(int argc, const char **argv) MonMap monmap; // load or generate monmap - if (g_conf->monmap.length()) { - int err = monmapbl.read_file(g_conf->monmap.c_str(), &error); + const auto monmap_fn = g_conf->get_val("monmap"); + if (monmap_fn.length()) { + int err = monmapbl.read_file(monmap_fn.c_str(), &error); if (err < 0) { - derr << argv[0] << ": error reading " << g_conf->monmap << ": " << error << dendl; + derr << argv[0] << ": error reading " << monmap_fn << ": " << error << dendl; exit(1); } try { @@ -342,9 +342,8 @@ int main(int argc, const char **argv) // always mark seed/mkfs monmap as epoch 0 monmap.set_epoch(0); - } - catch (const buffer::error& e) { - derr << argv[0] << ": error decoding monmap " << g_conf->monmap << ": " << e.what() << dendl; + } catch (const buffer::error& e) { + derr << argv[0] << ": error decoding monmap " << monmap_fn << ": " << e.what() << dendl; exit(1); } } else { @@ -393,9 +392,10 @@ int main(int argc, const char **argv) } } - if (!g_conf->fsid.is_zero()) { - monmap.fsid = g_conf->fsid; - dout(0) << argv[0] << ": set fsid to " << g_conf->fsid << dendl; + const auto fsid = g_conf->get_val("fsid"); + if (!fsid.is_zero()) { + monmap.fsid = fsid; + dout(0) << argv[0] << ": set fsid to " << fsid << dendl; } if (monmap.fsid.is_zero()) { diff --git a/src/common/LogClient.cc b/src/common/LogClient.cc index aeb2f5bfcec..6157194bb8b 100644 --- a/src/common/LogClient.cc +++ b/src/common/LogClient.cc @@ -88,7 +88,7 @@ int parse_log_client_options(CephContext *cct, return r; } - fsid = cct->_conf->fsid; + fsid = cct->_conf->get_val("fsid"); host = cct->_conf->host; return 0; } diff --git a/src/common/ceph_context.cc b/src/common/ceph_context.cc index 109c70d97cc..3a8d992c614 100644 --- a/src/common/ceph_context.cc +++ b/src/common/ceph_context.cc @@ -266,7 +266,7 @@ public: } if (log->graylog() && changed.count("fsid")) { - log->graylog()->set_fsid(conf->fsid); + log->graylog()->set_fsid(conf->get_val("fsid")); } } }; diff --git a/src/common/legacy_config_opts.h b/src/common/legacy_config_opts.h index ff7b7f4b7a7..f7c6983ccbf 100644 --- a/src/common/legacy_config_opts.h +++ b/src/common/legacy_config_opts.h @@ -14,14 +14,11 @@ /* note: no header guard */ OPTION(host, OPT_STR) // "" means that ceph will use short hostname -OPTION(fsid, OPT_UUID) OPTION(public_addr, OPT_ADDR) OPTION(public_bind_addr, OPT_ADDR) OPTION(cluster_addr, OPT_ADDR) OPTION(public_network, OPT_STR) OPTION(cluster_network, OPT_STR) -OPTION(monmap, OPT_STR) -OPTION(mon_host, OPT_STR) OPTION(lockdep, OPT_BOOL) OPTION(lockdep_force_backtrace, OPT_BOOL) // always gather current backtrace at every lock OPTION(run_dir, OPT_STR) // the "/var/run/ceph" dir, created on daemon startup diff --git a/src/mon/LogMonitor.cc b/src/mon/LogMonitor.cc index c7c2b281b48..90524902466 100644 --- a/src/mon/LogMonitor.cc +++ b/src/mon/LogMonitor.cc @@ -811,7 +811,7 @@ ceph::logging::Graylog::Ref LogMonitor::log_channel_info::get_graylog( if (graylogs.count(channel) == 0) { auto graylog(std::make_shared("mon")); - graylog->set_fsid(g_conf->fsid); + graylog->set_fsid(g_conf->get_val("fsid")); graylog->set_hostname(g_conf->host); graylog->set_destination(get_str_map_key(log_to_graylog_host, channel, &CLOG_CONFIG_DEFAULT_KEY), diff --git a/src/mon/MonMap.cc b/src/mon/MonMap.cc index 67381bd430a..7a1b9420e77 100644 --- a/src/mon/MonMap.cc +++ b/src/mon/MonMap.cc @@ -439,31 +439,34 @@ int MonMap::build_initial(CephContext *cct, ostream& errout) { const md_config_t *conf = cct->_conf; // file? - if (!conf->monmap.empty()) { + const auto monmap = conf->get_val("monmap"); + if (!monmap.empty()) { int r; try { - r = read(conf->monmap.c_str()); + r = read(monmap.c_str()); } catch (const buffer::error &e) { r = -EINVAL; } if (r >= 0) return 0; - errout << "unable to read/decode monmap from " << conf->monmap + errout << "unable to read/decode monmap from " << monmap << ": " << cpp_strerror(-r) << std::endl; return r; } // fsid from conf? - if (!cct->_conf->fsid.is_zero()) { - fsid = cct->_conf->fsid; + const auto new_fsid = conf->get_val("fsid"); + if (!new_fsid.is_zero()) { + fsid = new_fsid; } // -m foo? - if (!conf->mon_host.empty()) { - int r = build_from_host_list(conf->mon_host, "noname-"); + const auto mon_host = conf->get_val("mon_host"); + if (!mon_host.empty()) { + int r = build_from_host_list(mon_host, "noname-"); if (r < 0) { - errout << "unable to parse addrs in '" << conf->mon_host << "'" + errout << "unable to parse addrs in '" << mon_host << "'" << std::endl; return r; } diff --git a/src/tools/monmaptool.cc b/src/tools/monmaptool.cc index 1fac4c10e68..0972faf185a 100644 --- a/src/tools/monmaptool.cc +++ b/src/tools/monmaptool.cc @@ -310,7 +310,7 @@ int main(int argc, const char **argv) monmap.created = ceph_clock_now(); monmap.last_changed = monmap.created; srand(getpid() + time(0)); - if (g_conf->fsid.is_zero()) { + if (g_conf->get_val("fsid").is_zero()) { monmap.generate_fsid(); cout << me << ": generated fsid " << monmap.fsid << std::endl; } @@ -338,8 +338,8 @@ int main(int argc, const char **argv) modified = true; } - if (!g_conf->fsid.is_zero()) { - monmap.fsid = g_conf->fsid; + if (!g_conf->get_val("fsid").is_zero()) { + monmap.fsid = g_conf->get_val("fsid"); cout << me << ": set fsid to " << monmap.fsid << std::endl; modified = true; }