]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
crimson/osd: die when cannot lock pidfile.
authorRadoslaw Zarzynski <rzarzyns@redhat.com>
Fri, 29 May 2020 14:43:46 +0000 (16:43 +0200)
committerRadoslaw Zarzynski <rzarzyns@redhat.com>
Tue, 2 Jun 2020 14:23:47 +0000 (16:23 +0200)
The motivation is to assert-with-human-readable-error on spawning
a crimson-osd with already occupied ID.

Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
src/crimson/osd/main.cc

index d734fad46a9f3450d641aa25759b5b24e3a0f367..743ff43071db5ec97cf8916db0c47a2737888df4 100644 (file)
@@ -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;