From: Dan Mick Date: Tue, 11 Apr 2017 22:31:08 +0000 (-0700) Subject: mgr/MgrPyModule.cc: get Python traceback in all CallMethod spots X-Git-Tag: v12.0.3~290^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=71a985623392e43b8e793d7f2b7d973b6185e491;p=ceph.git mgr/MgrPyModule.cc: get Python traceback in all CallMethod spots Signed-off-by: Dan Mick --- diff --git a/src/mgr/MgrPyModule.cc b/src/mgr/MgrPyModule.cc index 4a8ac7d4172..6337fd9b35d 100644 --- a/src/mgr/MgrPyModule.cc +++ b/src/mgr/MgrPyModule.cc @@ -18,6 +18,8 @@ #include "MgrPyModule.h" +// FIXME: import sanely +extern std::string handle_pyerror(void); #define dout_context g_ceph_context #define dout_subsys ceph_subsys_mgr @@ -86,9 +88,9 @@ int MgrPyModule::serve() if (pValue != NULL) { Py_DECREF(pValue); } else { - derr << "Failed to invoke serve() on " << module_name << dendl; - PyErr_Print(); - r = -EINVAL; + derr << module_name << ".serve:" << dendl; + derr << handle_pyerror() << dendl; + return -EINVAL; } PyGILState_Release(gstate); @@ -111,7 +113,7 @@ void MgrPyModule::shutdown() Py_DECREF(pValue); } else { derr << "Failed to invoke shutdown() on " << module_name << dendl; - PyErr_Print(); + derr << handle_pyerror() << dendl; } PyGILState_Release(gstate); @@ -132,8 +134,8 @@ void MgrPyModule::notify(const std::string ¬ify_type, const std::string ¬i if (pValue != NULL) { Py_DECREF(pValue); } else { - derr << "Failed to invoke notify() on " << module_name << dendl; - PyErr_Print(); + derr << module_name << ".notify:" << dendl; + derr << handle_pyerror() << dendl; // FIXME: callers can't be expected to handle a python module // that has spontaneously broken, but Mgr() should provide // a hook to unload misbehaving modules when they have an @@ -163,7 +165,8 @@ void MgrPyModule::notify_clog(const LogEntry &log_entry) if (pValue != NULL) { Py_DECREF(pValue); } else { - PyErr_Print(); + derr << module_name << ".notify_clog:" << dendl; + derr << handle_pyerror() << dendl; // FIXME: callers can't be expected to handle a python module // that has spontaneously broken, but Mgr() should provide // a hook to unload misbehaving modules when they have an @@ -246,8 +249,8 @@ int MgrPyModule::handle_command( Py_DECREF(pResult); } else { - derr << "Failed to invoke handle_command() on " << module_name << dendl; - PyErr_Print(); + *ds << ""; + *ss << handle_pyerror(); r = -EINVAL; }