summaryrefslogtreecommitdiffstats
path: root/src/mon/MonMap.cc
diff options
context:
space:
mode:
authorGreg Farnum <gfarnum@redhat.com>2020-09-14 04:32:19 +0200
committerGreg Farnum <gfarnum@redhat.com>2020-09-14 04:32:19 +0200
commitd02625331c4e06ca213d9720d98137d83a87cb90 (patch)
tree086924476a2e50f6efb74e911b1aae2ca0643532 /src/mon/MonMap.cc
parentdoc: describe stretch mode for users and developers (diff)
parentMerge pull request #36915 from yuriw/wip-yuriw-46529-master (diff)
downloadceph-d02625331c4e06ca213d9720d98137d83a87cb90.tar.xz
ceph-d02625331c4e06ca213d9720d98137d83a87cb90.zip
Merge remote-tracking branch 'origin/master' into wip-stretch-mode
Diffstat (limited to 'src/mon/MonMap.cc')
-rw-r--r--src/mon/MonMap.cc64
1 files changed, 32 insertions, 32 deletions
diff --git a/src/mon/MonMap.cc b/src/mon/MonMap.cc
index 94434e7302f..a6601e4375c 100644
--- a/src/mon/MonMap.cc
+++ b/src/mon/MonMap.cc
@@ -413,7 +413,6 @@ void MonMap::dump_summary(Formatter *f) const
f->dump_unsigned("num_mons", ranks.size());
}
-
// an ambiguous mon addr may be legacy or may be msgr2--we aren' sure.
// when that happens we need to try them both (unless we can
// reasonably infer from the port number which it is).
@@ -502,9 +501,29 @@ void MonMap::_add_ambiguous_addr(const string& name,
}
}
+int
+MonMap::init_with_addrs(const std::vector<entity_addrvec_t>& addrs,
+ bool for_mkfs,
+ std::string_view prefix)
+{
+ char id = 'a';
+ for (auto& addr : addrs) {
+ string name{prefix};
+ name += id++;
+ if (addr.v.size() == 1) {
+ _add_ambiguous_addr(name, addr.front(), 0, 0, for_mkfs);
+ } else {
+ // they specified an addrvec, so let's assume they also specified
+ // the addr *type* and *port*. (we could possibly improve this?)
+ add(name, addr, 0);
+ }
+ }
+ return 0;
+}
+
int MonMap::init_with_ips(const std::string& ips,
bool for_mkfs,
- const std::string &prefix)
+ std::string_view prefix)
{
vector<entity_addrvec_t> addrs;
if (!parse_ip_port_vec(
@@ -514,27 +533,12 @@ int MonMap::init_with_ips(const std::string& ips,
}
if (addrs.empty())
return -ENOENT;
- for (unsigned i=0; i<addrs.size(); i++) {
- char n[2];
- n[0] = 'a' + i;
- n[1] = 0;
- string name;
- name = prefix;
- name += n;
- if (addrs[i].v.size() == 1) {
- _add_ambiguous_addr(name, addrs[i].front(), 0, 0, for_mkfs);
- } else {
- // they specified an addrvec, so let's assume they also specified
- // the addr *type* and *port*. (we could possibly improve this?)
- add(name, addrs[i], 0);
- }
- }
- return 0;
+ return init_with_addrs(addrs, for_mkfs, prefix);
}
int MonMap::init_with_hosts(const std::string& hostlist,
bool for_mkfs,
- const std::string& prefix)
+ std::string_view prefix)
{
// maybe they passed us a DNS-resolvable name
char *hosts = resolve_addrs(hostlist.c_str());
@@ -550,19 +554,8 @@ int MonMap::init_with_hosts(const std::string& hostlist,
return -EINVAL;
if (addrs.empty())
return -ENOENT;
- for (unsigned i=0; i<addrs.size(); i++) {
- char n[2];
- n[0] = 'a' + i;
- n[1] = 0;
- string name = prefix;
- name += n;
- if (addrs[i].v.size() == 1) {
- _add_ambiguous_addr(name, addrs[i].front(), 0, 0, for_mkfs);
- } else {
- // they specified an addrvec, so let's assume they also specified
- // the addr *type* and *port*. (we could possibly improve this?)
- add(name, addrs[i], 0);
- }
+ if (!init_with_addrs(addrs, for_mkfs, prefix)) {
+ return -EINVAL;
}
calc_legacy_ranks();
return 0;
@@ -889,6 +882,13 @@ int MonMap::init_with_dns_srv(CephContext* cct,
int MonMap::build_initial(CephContext *cct, bool for_mkfs, ostream& errout)
{
const auto& conf = cct->_conf;
+
+ // cct?
+ auto addrs = cct->get_mon_addrs();
+ if (addrs != nullptr && (addrs->size() > 0)) {
+ return init_with_addrs(*addrs, for_mkfs, "noname-");
+ }
+
// file?
if (const auto monmap = conf.get_val<std::string>("monmap");
!monmap.empty()) {