]> 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 31411/head
authorSage Weil <sage@redhat.com>
Thu, 31 Oct 2019 15:42:53 +0000 (10:42 -0500)
committerSage Weil <sage@redhat.com>
Tue, 5 Nov 2019 13:22:36 +0000 (07:22 -0600)
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>
(cherry picked from commit 67e5139b02518cbc83e5156e2f74a5d22f4d97a4)

qa/workunits/cephtool/test.sh
src/mgr/ActivePyModules.cc

index 55ea6c894e4965b32b31afe7bc532b0a0b62fe03..a4bd3d415a6fc3ec57091bbdaf4fa20b04126b78 100755 (executable)
@@ -2705,6 +2705,13 @@ function test_mgr_tell()
   ceph tell mgr osd status
 }
 
+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
@@ -2807,6 +2814,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 907bb0c81c934e2bbc5d9bd664d72def85b58aad..444de30f3d8e254c324ed6337c14f40b499b353d 100644 (file)
@@ -314,10 +314,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(