]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: Abort device health when device not found
authorBenoît Knecht <bknecht@protonmail.ch>
Mon, 6 Dec 2021 08:14:56 +0000 (09:14 +0100)
committerBenoît Knecht <bknecht@protonmail.ch>
Wed, 9 Feb 2022 18:41:02 +0000 (19:41 +0100)
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 <bknecht@protonmail.ch>
(cherry picked from commit c05a3b769dccf5fe839a2150e39d899516469164)

src/mon/Monitor.cc
src/mon/MonitorDBStore.h

index 3f2e2dc036663ac1ca1e81bf0d7a001127c51a42..60eef578c64fd517790672582fe7c15fd33d3432 100644 (file)
@@ -417,6 +417,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<string> devnames;
     get_raw_devices(devname, &devnames);
     json_spirit::mObject json_map;
index 515a047279781743cd638611875c9de5825bd16a..c33d35e486d4424d1bd3f057a1d0d4816aa59255 100644 (file)
@@ -57,6 +57,10 @@ class MonitorDBStore
     return devname;
   }
 
+  std::string get_path() {
+    return path;
+  }
+
   std::shared_ptr<PriorityCache::PriCache> get_priority_cache() const {
     return db->get_priority_cache();
   }