]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/ActivePyModules: behave if a module queries a devid that does not exist 31291/head
authorSage Weil <sage@redhat.com>
Thu, 31 Oct 2019 15:42:53 +0000 (10:42 -0500)
committerSage Weil <sage@redhat.com>
Thu, 31 Oct 2019 15:44:16 +0000 (10:44 -0500)
The GIL reacquire was being handled in the lambda, but that was not
getting called if the device didn't exist, leading to a crash.

Add a trivial CLI test.

Fixes: https://tracker.ceph.com/issues/42578
Signed-off-by: Sage Weil <sage@redhat.com>
qa/workunits/cephtool/test.sh
src/mgr/ActivePyModules.cc

index 8cdf1ed5d327bdd89193c3ec5174070b3ebb8699..52601ec4eb951bb71a57a9876df76beb64bd3dd6 100755 (executable)
@@ -2739,6 +2739,13 @@ function test_mgr_tell()
   ceph tell mgr version
 }
 
+function test_mgr_devices()
+{
+  ceph device ls
+  expect_false ceph device info doesnotexist
+  expect_false ceph device get-health-metrics doesnotexist
+}
+
 function test_per_pool_scrub_status()
 {
   ceph osd pool create noscrub_pool 12
@@ -2841,6 +2848,7 @@ MDS_TESTS+=" mon_mds_metadata"
 MDS_TESTS+=" mds_tell_help_command"
 
 MGR_TESTS+=" mgr_tell"
+MGR_TESTS+=" mgr_devices"
 
 TESTS+=$MON_TESTS
 TESTS+=$OSD_TESTS
index 27dbe175ee287ed2c50ca3893ed019bd5be7259c..5a31ad0691d3ecb32c2ce5d2ca0487b0fa30c9b5 100644 (file)
@@ -341,10 +341,15 @@ PyObject *ActivePyModules::get_python(const std::string &what)
   } else if (what.size() > 7 &&
             what.substr(0, 7) == "device ") {
     string devid = what.substr(7);
-    daemon_state.with_device(devid, [&f, &tstate] (const DeviceState& dev) {
-        PyEval_RestoreThread(tstate);
-       f.dump_object("device", dev);
-      });
+    if (!daemon_state.with_device(
+         devid,
+         [&f, &tstate] (const DeviceState& dev) {
+           PyEval_RestoreThread(tstate);
+           f.dump_object("device", dev);
+         })) {
+      // device not found
+      PyEval_RestoreThread(tstate);
+    }
     return f.get();
   } else if (what == "io_rate") {
     cluster_state.with_pgmap(