From c05a3b769dccf5fe839a2150e39d899516469164 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Beno=C3=AEt=20Knecht?= Date: Mon, 6 Dec 2021 09:14:56 +0100 Subject: [PATCH] mon: Abort device health when device not found MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit If `store->get_devname()` returns an empty device name, it means it couldn't determine the device that backs the monitor DB store directory. This can happen if `ceph-mon` runs with `PrivateDevices=yes` in systemd, or within a container where the host `/dev` isn't exposed. This commit makes sure we abort trying to get the device health at that point, and return an appropriate error. Signed-off-by: Benoît Knecht --- src/mon/Monitor.cc | 5 +++++ src/mon/MonitorDBStore.h | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index e8856a5d120f6..946e44abd236f 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -421,6 +421,11 @@ int Monitor::do_admin_command( cmd_getval(cmdmap, "devid", want_devid); string devname = store->get_devname(); + if (devname.empty()) { + err << "could not determine device name for " << store->get_path(); + r = -ENOENT; + goto abort; + } set devnames; get_raw_devices(devname, &devnames); json_spirit::mObject json_map; diff --git a/src/mon/MonitorDBStore.h b/src/mon/MonitorDBStore.h index 515a047279781..c33d35e486d44 100644 --- a/src/mon/MonitorDBStore.h +++ b/src/mon/MonitorDBStore.h @@ -57,6 +57,10 @@ class MonitorDBStore return devname; } + std::string get_path() { + return path; + } + std::shared_ptr get_priority_cache() const { return db->get_priority_cache(); } -- 2.39.5