From: Radoslaw Zarzynski Date: Fri, 29 May 2020 14:43:46 +0000 (+0200) Subject: crimson/osd: die when cannot lock pidfile. X-Git-Tag: wip-pdonnell-testing-20200918.022351~1092^2~2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=e6f5e102ba4b59f30551953f0d2266aa81a11c8a;p=ceph-ci.git crimson/osd: die when cannot lock pidfile. The motivation is to assert-with-human-readable-error on spawning a crimson-osd with already occupied ID. Signed-off-by: Radoslaw Zarzynski --- diff --git a/src/crimson/osd/main.cc b/src/crimson/osd/main.cc index d734fad46a9..743ff43071d 100644 --- a/src/crimson/osd/main.cc +++ b/src/crimson/osd/main.cc @@ -164,7 +164,14 @@ int main(int argc, char* argv[]) }); local_conf().parse_config_files(conf_file_list).get(); local_conf().parse_argv(ceph_args).get(); - pidfile_write(local_conf()->pid_file); + if (const auto ret = pidfile_write(local_conf()->pid_file); + ret == -EACCES || ret == -EAGAIN) { + ceph_abort_msg( + "likely there is another crimson-osd instance with the same id"); + } else if (ret < 0) { + ceph_abort_msg(fmt::format("pidfile_write failed with {} {}", + ret, cpp_strerror(-ret))); + } const int whoami = std::stoi(local_conf()->name.get_id()); const auto nonce = get_nonce(); crimson::net::MessengerRef cluster_msgr, client_msgr;