]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr: fix py calls for dne service perf counters 17867/head
authorJohn Spray <john.spray@redhat.com>
Fri, 8 Sep 2017 15:33:02 +0000 (11:33 -0400)
committerNathan Cutler <ncutler@suse.com>
Thu, 21 Sep 2017 04:10:48 +0000 (06:10 +0200)
Fixes: http://tracker.ceph.com/issues/21253
Signed-off-by: John Spray <john.spray@redhat.com>
(cherry picked from commit f9a4ca07acecd15986cbce61a6e118a6cb05af29)

src/mgr/DaemonState.cc
src/mgr/PyModules.cc

index 93fe130190eb6d72b52eb9d59b7a131f954fbf36..f304b18c6fcb1bf87a7aa9271c95d2d876eef277 100644 (file)
@@ -85,7 +85,12 @@ DaemonStatePtr DaemonStateIndex::get(const DaemonKey &key)
 {
   Mutex::Locker l(lock);
 
-  return all.at(key);
+  auto iter = all.find(key);
+  if (iter != all.end()) {
+    return iter->second;
+  } else {
+    return nullptr;
+  }
 }
 
 void DaemonStateIndex::cull(const std::string& svc_name,
index d8b7b01cc6278dbdcea73f760931d157bf12a6d2..5fa6df9cf7a5f16d7d35f8270a80a67d439f9d47 100644 (file)
@@ -679,9 +679,8 @@ PyObject* PyModules::get_counter_python(
   f.open_array_section(path.c_str());
 
   auto metadata = daemon_state.get(DaemonKey(svc_name, svc_id));
-
-  Mutex::Locker l2(metadata->lock);
   if (metadata) {
+    Mutex::Locker l2(metadata->lock);
     if (metadata->perf_counters.instances.count(path)) {
       auto counter_instance = metadata->perf_counters.instances.at(path);
       const auto &data = counter_instance.get_data();
@@ -726,8 +725,9 @@ PyObject* PyModules::get_perf_schema_python(
   } else {
     auto key = DaemonKey(svc_type, svc_id);
     // so that the below can be a loop in all cases
-    if (daemon_state.exists(key)) {
-      states[key] = daemon_state.get(key);
+    auto got = daemon_state.get(key);
+    if (got != nullptr) {
+      states[key] = got;
     }
   }