]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common/config: track the path to the conf file we loaded
authorSage Weil <sage@newdream.net>
Fri, 21 May 2021 22:49:33 +0000 (18:49 -0400)
committerSage Weil <sage@newdream.net>
Thu, 3 Jun 2021 12:40:57 +0000 (07:40 -0500)
Signed-off-by: Sage Weil <sage@newdream.net>
(cherry picked from commit 340c799bf924d61b355abb9c5e3e34b66634eb45)

src/common/config.cc
src/common/config.h
src/common/config_proxy.h

index b110e99772715d059b03b8968e231a49246b2f53..4916858676675c3122323e7e3091f034999bcfe9 100644 (file)
@@ -361,7 +361,6 @@ int md_config_t::parse_config_files(ConfigValues& values,
     values.cluster = get_cluster_name(nullptr);
   }
   // open new conf
-  string conffile;
   for (auto& fn : get_conffile_paths(values, conf_files_str, warnings, flags)) {
     bufferlist bl;
     std::string error;
@@ -373,7 +372,7 @@ int md_config_t::parse_config_files(ConfigValues& values,
     int ret = parse_buffer(values, tracker, bl.c_str(), bl.length(), &oss);
     if (ret == 0) {
       parse_error.clear();
-      conffile = fn;
+      conf_path = fn;
       break;
     }
     parse_error = oss.str();
@@ -382,11 +381,11 @@ int md_config_t::parse_config_files(ConfigValues& values,
     }
   }
   // it must have been all ENOENTs, that's the only way we got here
-  if (conffile.empty()) {
+  if (conf_path.empty()) {
     return -ENOENT;
   }
   if (values.cluster.empty()) {
-    values.cluster = get_cluster_name(conffile.c_str());
+    values.cluster = get_cluster_name(conf_path.c_str());
   }
   update_legacy_vals(values);
   return 0;
index bb3410e617d15192ae43e23bffe3d70dd4faee35..ef7d5b34fdc6b3f19dd82c913d766620a6cdc14b 100644 (file)
@@ -319,10 +319,15 @@ public:  // for global_init
                                            const char *conf_files,
                                            std::ostream *warnings,
                                            int flags) const;
+
+  const std::string& get_conf_path() const {
+    return conf_path;
+  }
 private:
   static std::string get_cluster_name(const char* conffile_path);
   // The configuration file we read, or NULL if we haven't read one.
   ConfFile cf;
+  std::string conf_path;
 public:
   std::string parse_error;
 private:
index 0cf53935241ac1f6cfaec0b207ae731e7fda9cf5..cb30a2d7f1fa26ed54486561ac92550e94695327 100644 (file)
@@ -341,6 +341,9 @@ public:
     std::lock_guard l{lock};
     config.get_defaults_bl(values, bl);
   }
+  const std::string& get_conf_path() const {
+    return config.get_conf_path();
+  }
 };
 
 }