]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common: allow running without config 30498/head
authorJoao Eduardo Luis <joao@suse.com>
Thu, 26 Sep 2019 07:54:07 +0000 (07:54 +0000)
committerKefu Chai <kchai@redhat.com>
Mon, 2 Dec 2019 15:28:31 +0000 (23:28 +0800)
If `--no-config-file` is specified, allow the caller to ignore the
requirements to find a config file. This presumes that the caller either
doesn't need to be configured, or that whatever it may need is provided
via the cli.

Signed-off-by: Joao Eduardo Luis <joao@suse.com>
doc/man/8/ceph-mon.rst
src/common/ceph_argparse.cc
src/common/ceph_argparse.h
src/common/common_init.cc
src/common/options.cc
src/global/global_init.cc

index 0c2c57925e55ad2e76dea6278f1cdba98cba453d..aeb6a38fc059852c8dbaed893c69479a4baba298 100644 (file)
@@ -77,6 +77,11 @@ Options
 
    Specify a keyring for use with ``--mkfs``.
 
+.. option:: --no-config-file
+
+    Signal that we don't want to rely on a *ceph.conf*, either user provided
+    or the default, to run the daemon.  This will entail providing all
+    necessary options to the daemon as arguments.
 
 Availability
 ============
index 818f8d0767514cda62744fe1091a43ec33be8b0f..662ed296a1e008aa83aab3dade51654666cc8d94 100644 (file)
@@ -504,6 +504,9 @@ CephInitParameters ceph_argparse_early_args
     else if (ceph_argparse_witharg(args, i, &val, "--conf", "-c", (char*)NULL)) {
       *conf_file_list = val;
     }
+    else if (ceph_argparse_flag(args, i, "--no-config-file", (char*)NULL)) {
+      iparams.no_config_file = true;
+    }
     else if (ceph_argparse_witharg(args, i, &val, "--cluster", (char*)NULL)) {
       *cluster = val;
     }
index 214b3dfb6727f2282b89e0fb5fa8419242874fa8..1c5370a3150460a220f299e3ff3e612c66feb033 100644 (file)
@@ -37,6 +37,7 @@ public:
 
   uint32_t module_type;
   EntityName name;
+  bool no_config_file = false;
 };
 
 /////////////////////// Functions ///////////////////////
index 40b2d31092fbfe0807ebfe5613f41e8ff6a3bbc9..2ad93a958c488a18ba306c312deb524d18c98403 100644 (file)
@@ -64,6 +64,8 @@ CephContext *common_preinit(const CephInitParameters &iparams,
     conf.set_val_default("log_flush_on_exit", "false");
   }
 
+  conf.set_val("no_config_file", iparams.no_config_file ? "true" : "false");
+
   return cct;
 }
 #endif // #ifndef WITH_SEASTAR
index a2958da725aafc85fb1b08b6325572d7dc3d6d75..bc92192b52cfd283f530bbed8cb96056ab5d732f 100644 (file)
@@ -441,6 +441,18 @@ std::vector<Option> get_global_options() {
     .set_flag(Option::FLAG_STARTUP)
     .set_default("ceph/daemon-base:latest-master-devel"),
 
+    Option("no_config_file", Option::TYPE_BOOL, Option::LEVEL_ADVANCED)
+    .set_default(false)
+    .set_flag(Option::FLAG_NO_MON_UPDATE)
+    .set_flag(Option::FLAG_STARTUP)
+    .add_service("common")
+    .add_tag("config")
+    .set_description("signal that we don't require a config file to be present")
+    .set_long_description("When specified, we won't be looking for a "
+                         "configuration file, and will instead expect that "
+                         "whatever options or values are required for us to "
+                         "work will be passed as arguments."),
+
     // lockdep
     Option("lockdep", Option::TYPE_BOOL, Option::LEVEL_DEV)
     .set_description("enable lockdep lock dependency analyzer")
index dff97e5c7ee04c4385d8ab3d1f4c51e8f6534eab..97265040061c0b54309e453ef456184e3a2c5505 100644 (file)
@@ -111,6 +111,10 @@ void global_pre_init(
     }
   }
 
+  if (conf.get_val<bool>("no_config_file")) {
+    flags |= CINIT_FLAG_NO_DEFAULT_CONFIG_FILE;
+  }
+
   int ret = conf.parse_config_files(c_str_or_null(conf_file_list),
                                    &cerr, flags);
   if (ret == -EDOM) {
@@ -126,7 +130,8 @@ void global_pre_init(
             << conf_file_list << std::endl;
         _exit(1);
       } else {
-       cerr << "did not load config file, using default settings." << std::endl;
+       cerr << "did not load config file, using default settings."
+            << std::endl;
       }
     }
   }