]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/MonMap: fix unconditional failure for init_with_hosts 37758/head
authorPatrick Donnelly <pdonnell@redhat.com>
Thu, 22 Oct 2020 17:08:26 +0000 (10:08 -0700)
committerPatrick Donnelly <pdonnell@redhat.com>
Fri, 23 Oct 2020 23:33:44 +0000 (16:33 -0700)
This bug prevents setting mon_host to a DNS name.

Fixes: https://tracker.ceph.com/issues/47951
Fixes: 7a1f02acfe6b5d8a760efd16bb594a0656b39eac
Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
src/mon/MonMap.cc
src/mon/MonMap.h

index efb426f742c276e03bf206fd7af84c733c5fbded..5d743de9ad732755260a0751a22e807e7265882f 100644 (file)
@@ -501,10 +501,9 @@ 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)
+void 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) {
@@ -518,7 +517,6 @@ MonMap::init_with_addrs(const std::vector<entity_addrvec_t>& 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?
index c409ff9e112b9cc3f34ea732ed5ccae4aff7bcf7..02304edfdd265c1b4966da10091ae7a880631302 100644 (file)
@@ -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<entity_addrvec_t>& addrs,
-        bool for_mkfs,
-        std::string_view prefix);
+  void init_with_addrs(const std::vector<entity_addrvec_t>& addrs,
+                       bool for_mkfs,
+                       std::string_view prefix);
   /**
    * build a monmap from a list of ips
    *