From 21d9f8333b8c76979bbe90d60a8ad6ebb5e36c76 Mon Sep 17 00:00:00 2001 From: Patrick Donnelly Date: Thu, 22 Oct 2020 10:08:26 -0700 Subject: [PATCH] mon/MonMap: fix unconditional failure for init_with_hosts This bug prevents setting mon_host to a DNS name. Fixes: https://tracker.ceph.com/issues/47951 Fixes: 7a1f02acfe6b5d8a760efd16bb594a0656b39eac Signed-off-by: Patrick Donnelly --- src/mon/MonMap.cc | 18 ++++++++---------- src/mon/MonMap.h | 7 +++---- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/mon/MonMap.cc b/src/mon/MonMap.cc index efb426f742c27..5d743de9ad732 100644 --- a/src/mon/MonMap.cc +++ b/src/mon/MonMap.cc @@ -501,10 +501,9 @@ void MonMap::_add_ambiguous_addr(const string& name, } } -int -MonMap::init_with_addrs(const std::vector& addrs, - bool for_mkfs, - std::string_view prefix) +void MonMap::init_with_addrs(const std::vector& addrs, + bool for_mkfs, + std::string_view prefix) { char id = 'a'; for (auto& addr : addrs) { @@ -518,7 +517,6 @@ MonMap::init_with_addrs(const std::vector& addrs, add(name, addr, 0); } } - return 0; } int MonMap::init_with_ips(const std::string& ips, @@ -533,7 +531,8 @@ int MonMap::init_with_ips(const std::string& ips, } if (addrs.empty()) return -ENOENT; - return init_with_addrs(addrs, for_mkfs, prefix); + init_with_addrs(addrs, for_mkfs, prefix); + return 0; } int MonMap::init_with_hosts(const std::string& hostlist, @@ -554,9 +553,7 @@ int MonMap::init_with_hosts(const std::string& hostlist, return -EINVAL; if (addrs.empty()) return -ENOENT; - if (!init_with_addrs(addrs, for_mkfs, prefix)) { - return -EINVAL; - } + init_with_addrs(addrs, for_mkfs, prefix); calc_legacy_ranks(); return 0; } @@ -901,7 +898,8 @@ int MonMap::build_initial(CephContext *cct, bool for_mkfs, ostream& errout) // cct? auto addrs = cct->get_mon_addrs(); if (addrs != nullptr && (addrs->size() > 0)) { - return init_with_addrs(*addrs, for_mkfs, "noname-"); + init_with_addrs(*addrs, for_mkfs, "noname-"); + return 0; } // file? diff --git a/src/mon/MonMap.h b/src/mon/MonMap.h index c409ff9e112b9..02304edfdd265 100644 --- a/src/mon/MonMap.h +++ b/src/mon/MonMap.h @@ -493,11 +493,10 @@ protected: * * @param addrs list of entity_addrvec_t's * @param prefix prefix to prepend to generated mon names - * @return 0 for success, -errno on error */ - int init_with_addrs(const std::vector& addrs, - bool for_mkfs, - std::string_view prefix); + void init_with_addrs(const std::vector& addrs, + bool for_mkfs, + std::string_view prefix); /** * build a monmap from a list of ips * -- 2.39.5