From e6f5e102ba4b59f30551953f0d2266aa81a11c8a Mon Sep 17 00:00:00 2001 From: Radoslaw Zarzynski Date: Fri, 29 May 2020 16:43:46 +0200 Subject: [PATCH] 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 --- src/crimson/osd/main.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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; -- 2.39.5