]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/config: fix non zero return code when needed during early config 59185/head
authorNitzan Mordechai <nmordech@redhat.com>
Tue, 13 Aug 2024 07:02:20 +0000 (07:02 +0000)
committerNitzan Mordechai <nmordech@redhat.com>
Tue, 13 Aug 2024 10:08:46 +0000 (10:08 +0000)
Fixes: https://tracker.ceph.com/issues/67376
Signed-off-by: Nitzan Mordechai <nmordech@redhat.com>
src/crimson/osd/main_config_bootstrap_helpers.cc

index c4e7fb72e4782ce3bf53b1016880e00c6db3bcc7..3596929527f9332d748a5212dbb7611b388ac7ac 100644 (file)
@@ -35,7 +35,7 @@ namespace crimson::osd {
 
 void usage(const char* prog)
 {
-  std::cout << "usage: " << prog << std::endl;
+  std::cout << "crimson osd usage: " << prog << " -i <ID> [flags...]" << std::endl;
   generic_server_usage();
 }
 
@@ -98,11 +98,6 @@ _get_early_config(int argc, const char *argv[])
     &ret.cluster_name,
     &ret.conf_file_list);
 
-  if (ceph_argparse_need_usage(early_args)) {
-    usage(argv[0]);
-    exit(0);
-  }
-
   seastar::app_template::config app_cfg;
   app_cfg.name = "Crimson-startup";
   app_cfg.auto_handle_sigint_sigterm = false;
@@ -221,6 +216,15 @@ _get_early_config(int argc, const char *argv[])
 tl::expected<early_config_t, int>
 get_early_config(int argc, const char *argv[])
 {
+  auto args = argv_to_vec(argc, argv);
+  if (args.empty()) {
+    std::cerr << argv[0] << ": -h or --help for usage" << std::endl;
+    exit(1);
+  }
+  if (ceph_argparse_need_usage(args)) {
+    usage(argv[0]);
+    exit(0);
+  }
   int pipes[2];
   int r = pipe2(pipes, 0);
   if (r < 0) {
@@ -262,12 +266,20 @@ get_early_config(int argc, const char *argv[])
 
     bufferlist bl;
     early_config_t ret;
-    while ((r = bl.read_fd(pipes[0], 1024)) > 0);
+    bool have_data = false;
+    while ((r = bl.read_fd(pipes[0], 1024)) > 0) {
+      have_data = true;
+    }
     close(pipes[0]);
 
-    // ignore error, we'll propogate error based on read and decode
-    waitpid(worker, nullptr, 0);
+    int status;
+    waitpid(worker, &status, 0);
 
+    // One of the parameters was taged as exit(0) in the child process
+    // so we need to check if we should exit here
+    if (!have_data && WIFEXITED(status) && WEXITSTATUS(status) == 0) {
+      exit(0);
+    }
     if (r < 0) {
       std::cerr << "get_early_config: parent failed to read from pipe: "
                << r << std::endl;