Skip to content

Commit de4b649

Browse files
committed
osd/config: fix non zero return code when needed during early config
Fixes: https://tracker.ceph.com/issues/67376 Signed-off-by: Nitzan Mordechai <[email protected]>
1 parent 8074a0a commit de4b649

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

src/crimson/osd/main_config_bootstrap_helpers.cc

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ namespace crimson::osd {
3535

3636
void usage(const char* prog)
3737
{
38-
std::cout << "usage: " << prog << std::endl;
38+
std::cout << "crimson osd usage: " << prog << " -i <ID> [flags...]" << std::endl;
3939
generic_server_usage();
4040
}
4141

@@ -98,11 +98,6 @@ _get_early_config(int argc, const char *argv[])
9898
&ret.cluster_name,
9999
&ret.conf_file_list);
100100

101-
if (ceph_argparse_need_usage(early_args)) {
102-
usage(argv[0]);
103-
exit(0);
104-
}
105-
106101
seastar::app_template::config app_cfg;
107102
app_cfg.name = "Crimson-startup";
108103
app_cfg.auto_handle_sigint_sigterm = false;
@@ -221,6 +216,15 @@ _get_early_config(int argc, const char *argv[])
221216
tl::expected<early_config_t, int>
222217
get_early_config(int argc, const char *argv[])
223218
{
219+
auto args = argv_to_vec(argc, argv);
220+
if (args.empty()) {
221+
std::cerr << argv[0] << ": -h or --help for usage" << std::endl;
222+
exit(1);
223+
}
224+
if (ceph_argparse_need_usage(args)) {
225+
usage(argv[0]);
226+
exit(0);
227+
}
224228
int pipes[2];
225229
int r = pipe2(pipes, 0);
226230
if (r < 0) {
@@ -262,12 +266,20 @@ get_early_config(int argc, const char *argv[])
262266

263267
bufferlist bl;
264268
early_config_t ret;
265-
while ((r = bl.read_fd(pipes[0], 1024)) > 0);
269+
bool have_data = false;
270+
while ((r = bl.read_fd(pipes[0], 1024)) > 0) {
271+
have_data = true;
272+
}
266273
close(pipes[0]);
267274

268-
// ignore error, we'll propogate error based on read and decode
269-
waitpid(worker, nullptr, 0);
275+
int status;
276+
waitpid(worker, &status, 0);
270277

278+
// One of the parameters was taged as exit(0) in the child process
279+
// so we need to check if we should exit here
280+
if (!have_data && WIFEXITED(status) && WEXITSTATUS(status) == 0) {
281+
exit(0);
282+
}
271283
if (r < 0) {
272284
std::cerr << "get_early_config: parent failed to read from pipe: "
273285
<< r << std::endl;

0 commit comments

Comments
 (0)