]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr: Use ceph_assert for asserts.
authorAdam C. Emerson <aemerson@redhat.com>
Thu, 23 Aug 2018 15:25:51 +0000 (11:25 -0400)
committerAdam C. Emerson <aemerson@redhat.com>
Mon, 27 Aug 2018 14:27:22 +0000 (10:27 -0400)
Signed-off-by: Adam C. Emerson <aemerson@redhat.com>
21 files changed:
src/mgr/ActivePyModule.cc
src/mgr/ActivePyModules.cc
src/mgr/BaseMgrModule.cc
src/mgr/BaseMgrStandbyModule.cc
src/mgr/ClusterState.h
src/mgr/DaemonServer.cc
src/mgr/DaemonState.cc
src/mgr/Gil.cc
src/mgr/Mgr.cc
src/mgr/MgrClient.cc
src/mgr/MgrStandby.cc
src/mgr/PyFormatter.cc
src/mgr/PyFormatter.h
src/mgr/PyModule.cc
src/mgr/PyModule.h
src/mgr/PyModuleRegistry.cc
src/mgr/PyModuleRegistry.h
src/mgr/PyModuleRunner.cc
src/mgr/PyModuleRunner.h
src/mgr/PyOSDMap.cc
src/mgr/StandbyPyModules.cc

index 425b3f99c7ff6ab15e444a1c53d693750d0e03e7..d8a416bfde578af3267b4ef5e6f3b8c0d251b94e 100644 (file)
@@ -25,7 +25,7 @@
 
 int ActivePyModule::load(ActivePyModules *py_modules)
 {
-  assert(py_modules);
+  ceph_assert(py_modules);
   Gil gil(py_module->pMyThreadState, true);
 
   // We tell the module how we name it, so that it can be consistent
@@ -51,7 +51,7 @@ int ActivePyModule::load(ActivePyModules *py_modules)
 
 void ActivePyModule::notify(const std::string &notify_type, const std::string &notify_id)
 {
-  assert(pClassInstance != nullptr);
+  ceph_assert(pClassInstance != nullptr);
 
   Gil gil(py_module->pMyThreadState, true);
 
@@ -74,7 +74,7 @@ void ActivePyModule::notify(const std::string &notify_type, const std::string &n
 
 void ActivePyModule::notify_clog(const LogEntry &log_entry)
 {
-  assert(pClassInstance != nullptr);
+  ceph_assert(pClassInstance != nullptr);
 
   Gil gil(py_module->pMyThreadState, true);
 
@@ -119,7 +119,7 @@ PyObject *ActivePyModule::dispatch_remote(
     PyObject *kwargs,
     std::string *err)
 {
-  assert(err != nullptr);
+  ceph_assert(err != nullptr);
 
   // Rather than serializing arguments, pass the CPython objects.
   // Works because we happen to know that the subinterpreter
@@ -134,7 +134,7 @@ PyObject *ActivePyModule::dispatch_remote(
   auto boundMethod = PyObject_GetAttrString(pClassInstance, method.c_str());
 
   // Caller should have done method_exists check first!
-  assert(boundMethod != nullptr);
+  ceph_assert(boundMethod != nullptr);
 
   dout(20) << "Calling " << py_module->get_name()
            << "." << method << "..." << dendl;
@@ -163,8 +163,8 @@ int ActivePyModule::handle_command(
   std::stringstream *ds,
   std::stringstream *ss)
 {
-  assert(ss != nullptr);
-  assert(ds != nullptr);
+  ceph_assert(ss != nullptr);
+  ceph_assert(ds != nullptr);
 
   if (pClassInstance == nullptr) {
     // Not the friendliest error string, but we could only
index 1695d4cc10066cec1836350d820ad753841bcb56..6bac2ec6e0318976ef3956a3438caa0874203840 100644 (file)
@@ -373,7 +373,7 @@ int ActivePyModules::start_one(PyModuleRef py_module)
 {
   Mutex::Locker l(lock);
 
-  assert(modules.count(py_module->get_name()) == 0);
+  ceph_assert(modules.count(py_module->get_name()) == 0);
 
   modules[py_module->get_name()].reset(new ActivePyModule(py_module, clog));
   auto active_module = modules.at(py_module->get_name()).get();
@@ -485,7 +485,7 @@ PyObject *ActivePyModules::dispatch_remote(
     std::string *err)
 {
   auto mod_iter = modules.find(other_module);
-  assert(mod_iter != modules.end());
+  ceph_assert(mod_iter != modules.end());
 
   return mod_iter->second->dispatch_remote(method, args, kwargs, err);
 }
@@ -738,7 +738,7 @@ PyObject *construct_with_capsule(
     derr << "Failed to import python module:" << dendl;
     derr << handle_pyerror() << dendl;
   }
-  assert(module);
+  ceph_assert(module);
 
   PyObject *wrapper_type = PyObject_GetAttrString(
       module, (const char*)clsname.c_str());
@@ -746,11 +746,11 @@ PyObject *construct_with_capsule(
     derr << "Failed to get python type:" << dendl;
     derr << handle_pyerror() << dendl;
   }
-  assert(wrapper_type);
+  ceph_assert(wrapper_type);
 
   // Construct a capsule containing an OSDMap.
   auto wrapped_capsule = PyCapsule_New(wrapped, nullptr, nullptr);
-  assert(wrapped_capsule);
+  ceph_assert(wrapped_capsule);
 
   // Construct the python OSDMap
   auto pArgs = PyTuple_Pack(1, wrapped_capsule);
@@ -759,7 +759,7 @@ PyObject *construct_with_capsule(
     derr << "Failed to construct python OSDMap:" << dendl;
     derr << handle_pyerror() << dendl;
   }
-  assert(wrapper_instance != nullptr);
+  ceph_assert(wrapper_instance != nullptr);
   Py_DECREF(pArgs);
   Py_DECREF(wrapped_capsule);
 
index 0556a1c4511d59836bda2bed362ceb4fbc39dc63..c52bf165d867a11bd2d5ab9a46e62c7af8b4cf12 100644 (file)
@@ -58,7 +58,7 @@ public:
     : py_modules(py_modules_), python_completion(ev),
       tag(tag_), pThreadState(ts_)
   {
-    assert(python_completion != nullptr);
+    ceph_assert(python_completion != nullptr);
     Py_INCREF(python_completion);
   }
 
@@ -75,7 +75,7 @@ public:
 
   void finish(int r) override
   {
-    assert(python_completion != nullptr);
+    ceph_assert(python_completion != nullptr);
 
     dout(10) << "MonCommandCompletion::finish()" << dendl;
     {
@@ -85,7 +85,7 @@ public:
       Gil gil(pThreadState, true);
 
       auto set_fn = PyObject_GetAttrString(python_completion, "complete");
-      assert(set_fn != nullptr);
+      ceph_assert(set_fn != nullptr);
 
       auto pyR = PyInt_FromLong(r);
       auto pyOutBl = PyString_FromString(outbl.to_str().c_str());
@@ -131,7 +131,7 @@ ceph_send_command(BaseMgrModule *self, PyObject *args)
   if (set_fn == nullptr) {
     ceph_abort();  // TODO raise python exception instead
   } else {
-    assert(PyCallable_Check(set_fn));
+    ceph_assert(PyCallable_Check(set_fn));
   }
   Py_DECREF(set_fn);
 
@@ -472,7 +472,7 @@ ceph_log(BaseMgrModule *self, PyObject *args)
     return nullptr;
   }
 
-  assert(self->this_module);
+  ceph_assert(self->this_module);
 
   self->this_module->log(level, record);
 
@@ -696,10 +696,10 @@ BaseMgrModule_init(BaseMgrModule *self, PyObject *args, PyObject *kwds)
 
     self->py_modules = static_cast<ActivePyModules*>(PyCapsule_GetPointer(
         py_modules_capsule, nullptr));
-    assert(self->py_modules);
+    ceph_assert(self->py_modules);
     self->this_module = static_cast<ActivePyModule*>(PyCapsule_GetPointer(
         this_module_capsule, nullptr));
-    assert(self->this_module);
+    ceph_assert(self->this_module);
 
     return 0;
 }
index d4ad2b740110717101aad1ff115636ce835a4cb7..db980a2bcc541a2286a3a3d7a4f2db40dc18f87d 100644 (file)
@@ -49,7 +49,7 @@ BaseMgrStandbyModule_init(BaseMgrStandbyModule *self, PyObject *args, PyObject *
 
     self->this_module = static_cast<StandbyPyModule*>(PyCapsule_GetPointer(
         this_module_capsule, nullptr));
-    assert(self->this_module);
+    ceph_assert(self->this_module);
 
     return 0;
 }
@@ -121,7 +121,7 @@ ceph_log(BaseMgrStandbyModule *self, PyObject *args)
     return nullptr;
   }
 
-  assert(self->this_module);
+  ceph_assert(self->this_module);
 
   self->this_module->log(level, record);
 
index a270861e80b48713cc1b8643d1ee53cee529622e..d0ec594cc40fc4a65bf6375b2d6a11e11dc9cee0 100644 (file)
@@ -115,7 +115,7 @@ public:
   void with_monmap(Args &&... args) const
   {
     Mutex::Locker l(lock);
-    assert(monc != nullptr);
+    ceph_assert(monc != nullptr);
     monc->with_monmap(std::forward<Args>(args)...);
   }
 
@@ -123,7 +123,7 @@ public:
   auto with_osdmap(Args &&... args) const ->
     decltype(objecter->with_osdmap(std::forward<Args>(args)...))
   {
-    assert(objecter != nullptr);
+    ceph_assert(objecter != nullptr);
     return objecter->with_osdmap(std::forward<Args>(args)...);
   }
 
index 702bf1629b56a4c7fe72a2f293efb62bcd64c68a..47fde57a65367123fd42e4c563e9d0156baadfe9 100644 (file)
@@ -364,7 +364,7 @@ void DaemonServer::tick()
 // fire after all modules have had a chance to set their health checks.
 void DaemonServer::schedule_tick_locked(double delay_sec)
 {
-  assert(lock.is_locked_by_me());
+  ceph_assert(lock.is_locked_by_me());
 
   if (tick_event) {
     timer.cancel_event(tick_event);
@@ -608,7 +608,7 @@ bool DaemonServer::handle_report(MMgrReport *m)
   }
 
   // Update the DaemonState
-  assert(daemon != nullptr);
+  ceph_assert(daemon != nullptr);
   {
     Mutex::Locker l(daemon->lock);
     auto &daemon_counters = daemon->perf_counters;
@@ -727,7 +727,7 @@ bool DaemonServer::handle_command(MCommand *m)
   std::stringstream ss;
   std::string prefix;
 
-  assert(lock.is_locked_by_me());
+  ceph_assert(lock.is_locked_by_me());
 
   /**
    * The working data for processing an MCommand.  This lives in
@@ -914,7 +914,7 @@ bool DaemonServer::handle_command(MCommand *m)
       for (auto& q : p.second.daemons) {
        f->open_object_section(q.first.c_str());
        DaemonKey key(p.first, q.first);
-       assert(daemon_state.exists(key));
+       ceph_assert(daemon_state.exists(key));
        auto daemon = daemon_state.get(key);
        Mutex::Locker l(daemon->lock);
        f->dump_stream("status_stamp") << daemon->service_status_stamp;
@@ -1215,7 +1215,7 @@ bool DaemonServer::handle_command(MCommand *m)
         if (!pool_name.empty()) {
           poolid = osdmap.lookup_pg_pool_name(pool_name);
           if (poolid < 0) {
-            assert(poolid == -ENOENT);
+            ceph_assert(poolid == -ENOENT);
             ss << "unrecognized pool '" << pool_name << "'";
             return -ENOENT;
           }
@@ -1533,7 +1533,7 @@ bool DaemonServer::handle_command(MCommand *m)
                  }
                  break;
                default:
-                 assert(0 == "actual_op value is not supported");
+                 ceph_assert(0 == "actual_op value is not supported");
              }
 
              parsed_pgs.push_back(std::move(parsed_pg));
@@ -2317,7 +2317,7 @@ void DaemonServer::handle_conf_change(const ConfigProxy& conf,
 
 void DaemonServer::_send_configure(ConnectionRef c)
 {
-  assert(lock.is_locked_by_me());
+  ceph_assert(lock.is_locked_by_me());
 
   auto configure = new MMgrConfigure();
   configure->stats_period = g_conf().get_val<int64_t>("mgr_stats_period");
index d8f36d0be018052f9ce96f015542518e6027e663..1dd314da2d34257b9d5fcde6cb3772f9b5b92c95 100644 (file)
@@ -140,15 +140,15 @@ void DaemonStateIndex::insert(DaemonStatePtr dm)
 
 void DaemonStateIndex::_erase(const DaemonKey& dmk)
 {
-  assert(lock.is_wlocked());
+  ceph_assert(lock.is_wlocked());
 
   const auto to_erase = all.find(dmk);
-  assert(to_erase != all.end());
+  ceph_assert(to_erase != all.end());
   const auto dm = to_erase->second;
 
   for (auto& i : dm->devices) {
     auto d = _get_or_create_device(i.first);
-    assert(d->daemons.count(dmk));
+    ceph_assert(d->daemons.count(dmk));
     d->daemons.erase(dmk);
     d->devnames.erase(make_pair(dm->hostname, i.second));
     if (d->empty()) {
index 9489a31310868771a113bbba030890f7a2ed422b..d476c7177fb15786f049d863366ca9792f486c75 100644 (file)
@@ -27,7 +27,7 @@
 SafeThreadState::SafeThreadState(PyThreadState *ts_)
     : ts(ts_)
 {
-  assert(ts != nullptr);
+  ceph_assert(ts != nullptr);
   thread = pthread_self();
 }
 
@@ -60,7 +60,7 @@ Gil::Gil(SafeThreadState &ts, bool new_thread) : pThreadState(ts)
     PyThreadState_Swap(pNewThreadState);
     dout(20) << "Switched to new thread state " << pNewThreadState << dendl;
   } else {
-    assert(pthread_self() == pThreadState.thread);
+    ceph_assert(pthread_self() == pThreadState.thread);
   }
 }
 
index ca784ebcab79abcdf3c12776fe6542b69bc8010b..eb60ee245384f2d8de272a40443c20b357b927d7 100644 (file)
@@ -141,8 +141,8 @@ void MetadataUpdate::finish(int r)
 void Mgr::background_init(Context *completion)
 {
   Mutex::Locker l(lock);
-  assert(!initializing);
-  assert(!initialized);
+  ceph_assert(!initializing);
+  ceph_assert(!initialized);
   initializing = true;
 
   finisher.start();
@@ -155,7 +155,7 @@ void Mgr::background_init(Context *completion)
 
 std::map<std::string, std::string> Mgr::load_store()
 {
-  assert(lock.is_locked_by_me());
+  ceph_assert(lock.is_locked_by_me());
 
   dout(10) << "listing keys" << dendl;
   JSONCommand cmd;
@@ -163,7 +163,7 @@ std::map<std::string, std::string> Mgr::load_store()
   lock.Unlock();
   cmd.wait();
   lock.Lock();
-  assert(cmd.r == 0);
+  ceph_assert(cmd.r == 0);
 
   std::map<std::string, std::string> loaded;
   
@@ -216,8 +216,8 @@ std::map<std::string, std::string> Mgr::load_store()
 void Mgr::init()
 {
   Mutex::Locker l(lock);
-  assert(initializing);
-  assert(!initialized);
+  ceph_assert(initializing);
+  ceph_assert(!initialized);
 
   // Start communicating with daemons to learn statistics etc
   int r = server.init(monc->get_global_id(), client_messenger->get_myaddrs());
@@ -295,7 +295,7 @@ void Mgr::init()
 
 void Mgr::load_all_metadata()
 {
-  assert(lock.is_locked_by_me());
+  ceph_assert(lock.is_locked_by_me());
 
   JSONCommand mds_cmd;
   mds_cmd.run(monc, "{\"prefix\": \"mds metadata\"}");
@@ -310,9 +310,9 @@ void Mgr::load_all_metadata()
   mon_cmd.wait();
   lock.Lock();
 
-  assert(mds_cmd.r == 0);
-  assert(mon_cmd.r == 0);
-  assert(osd_cmd.r == 0);
+  ceph_assert(mds_cmd.r == 0);
+  ceph_assert(mon_cmd.r == 0);
+  ceph_assert(osd_cmd.r == 0);
 
   for (auto &metadata_val : mds_cmd.json_result.get_array()) {
     json_spirit::mObject daemon_meta = metadata_val.get_obj();
@@ -409,7 +409,7 @@ void Mgr::shutdown()
 
 void Mgr::handle_osd_map()
 {
-  assert(lock.is_locked_by_me());
+  ceph_assert(lock.is_locked_by_me());
 
   std::set<std::string> names_exist;
 
@@ -539,7 +539,7 @@ bool Mgr::ms_dispatch(Message *m)
 
 void Mgr::handle_fs_map(MFSMap* m)
 {
-  assert(lock.is_locked_by_me());
+  ceph_assert(lock.is_locked_by_me());
 
   std::set<std::string> names_exist;
   
index ea6998167b7a906cae57faf3364b88fd7019ea72..0d6acf76bf0b845aec981ab450bf28eba1b574bb 100644 (file)
@@ -34,14 +34,14 @@ MgrClient::MgrClient(CephContext *cct_, Messenger *msgr_)
     : Dispatcher(cct_), cct(cct_), msgr(msgr_),
       timer(cct_, lock)
 {
-  assert(cct != nullptr);
+  ceph_assert(cct != nullptr);
 }
 
 void MgrClient::init()
 {
   Mutex::Locker l(lock);
 
-  assert(msgr != nullptr);
+  ceph_assert(msgr != nullptr);
 
   timer.init();
 }
@@ -107,7 +107,7 @@ bool MgrClient::ms_dispatch(Message *m)
 
 void MgrClient::reconnect()
 {
-  assert(lock.is_locked_by_me());
+  ceph_assert(lock.is_locked_by_me());
 
   if (session) {
     ldout(cct, 4) << "Terminating session with "
@@ -170,8 +170,8 @@ void MgrClient::reconnect()
   // resend any pending commands
   for (const auto &p : command_table.get_commands()) {
     MCommand *m = p.second.get_message({});
-    assert(session);
-    assert(session->con);
+    ceph_assert(session);
+    ceph_assert(session->con);
     session->con->send_message(m);
   }
 }
@@ -198,7 +198,7 @@ void MgrClient::_send_open()
 
 bool MgrClient::handle_mgr_map(MMgrMap *m)
 {
-  assert(lock.is_locked_by_me());
+  ceph_assert(lock.is_locked_by_me());
 
   ldout(cct, 20) << *m << dendl;
 
@@ -249,8 +249,8 @@ void MgrClient::_send_stats()
 
 void MgrClient::_send_report()
 {
-  assert(lock.is_locked_by_me());
-  assert(session);
+  ceph_assert(lock.is_locked_by_me());
+  ceph_assert(session);
   report_callback = nullptr;
 
   auto report = new MMgrReport();
@@ -368,7 +368,7 @@ void MgrClient::_send_pgstats()
 
 bool MgrClient::handle_mgr_configure(MMgrConfigure *m)
 {
-  assert(lock.is_locked_by_me());
+  ceph_assert(lock.is_locked_by_me());
 
   ldout(cct, 20) << *m << dendl;
 
@@ -435,7 +435,7 @@ int MgrClient::start_command(const vector<string>& cmd, const bufferlist& inbl,
 
 bool MgrClient::handle_command_reply(MCommandReply *m)
 {
-  assert(lock.is_locked_by_me());
+  ceph_assert(lock.is_locked_by_me());
 
   ldout(cct, 20) << *m << dendl;
 
index 9a914f773be5d41e3764f9594cd75994397afed2..d90b799f57772346683299a5f58affee13375ab5 100644 (file)
@@ -179,7 +179,7 @@ int MgrStandby::init()
 
 void MgrStandby::send_beacon()
 {
-  assert(lock.is_locked_by_me());
+  ceph_assert(lock.is_locked_by_me());
   dout(4) << state_str() << dendl;
 
   std::list<PyModuleRef> modules = py_module_registry.get_modules();
@@ -253,7 +253,7 @@ void MgrStandby::tick()
 void MgrStandby::handle_signal(int signum)
 {
   Mutex::Locker l(lock);
-  assert(signum == SIGINT || signum == SIGTERM);
+  ceph_assert(signum == SIGINT || signum == SIGTERM);
   derr << "*** Got signal " << sig_str(signum) << " ***" << dendl;
   shutdown();
 }
@@ -261,7 +261,7 @@ void MgrStandby::handle_signal(int signum)
 void MgrStandby::shutdown()
 {
   // Expect already to be locked as we're called from signal handler
-  assert(lock.is_locked_by_me());
+  ceph_assert(lock.is_locked_by_me());
 
   dout(4) << "Shutting down" << dendl;
 
@@ -304,7 +304,7 @@ void MgrStandby::respawn()
     /* Print CWD for the user's interest */
     char buf[PATH_MAX];
     char *cwd = getcwd(buf, sizeof(buf));
-    assert(cwd);
+    ceph_assert(cwd);
     dout(1) << " cwd " << cwd << dendl;
 
     /* Fall back to a best-effort: just running in our CWD */
index f2ef0de0b6f32ef756baead7ed03ea12caefc4af..4c71a2cb1de745fb10997b3bcbba9d3f24f3b355 100644 (file)
@@ -39,14 +39,14 @@ void PyFormatter::open_object_section(const char *name)
 void PyFormatter::dump_unsigned(const char *name, uint64_t u)
 {
   PyObject *p = PyLong_FromLongLong(u);
-  assert(p);
+  ceph_assert(p);
   dump_pyobject(name, p);
 }
 
 void PyFormatter::dump_int(const char *name, int64_t u)
 {
   PyObject *p = PyLong_FromLongLong(u);
-  assert(p);
+  ceph_assert(p);
   dump_pyobject(name, p);
 }
 
index 8b44916a047584daf18ec9bf9e06b7180c114f0a..9c7d54eebbc46470668f56cfe5839c8e34e74df1 100644 (file)
@@ -76,8 +76,8 @@ public:
   void open_object_section(const char *name) override;
   void close_section() override
   {
-    assert(cursor != root);
-    assert(!stack.empty());
+    ceph_assert(cursor != root);
+    ceph_assert(!stack.empty());
     cursor = stack.top();
     stack.pop();
   }
index b298b6949ab024b0a21e36dc4f6d9dae306b305f..a71d6c67db211a054ad1a5fd94d745b2393ca6e3 100644 (file)
@@ -83,8 +83,8 @@ std::string peek_pyerror()
 {
   PyObject *ptype, *pvalue, *ptraceback;
   PyErr_Fetch(&ptype, &pvalue, &ptraceback);
-  assert(ptype);
-  assert(pvalue);
+  ceph_assert(ptype);
+  ceph_assert(pvalue);
   PyObject *pvalue_str = PyObject_Str(pvalue);
   std::string exc_msg = PyString_AsString(pvalue_str);
   Py_DECREF(pvalue_str);
@@ -189,12 +189,12 @@ std::string PyModule::get_site_packages()
   // CPython doesn't auto-add site-packages dirs to sys.path for us,
   // but it does provide a module that we can ask for them.
   auto site_module = PyImport_ImportModule("site");
-  assert(site_module);
+  ceph_assert(site_module);
 
   auto site_packages_fn = PyObject_GetAttrString(site_module, "getsitepackages");
   if (site_packages_fn != nullptr) {
     auto site_packages_list = PyObject_CallObject(site_packages_fn, nullptr);
-    assert(site_packages_list);
+    ceph_assert(site_packages_list);
 
     auto n = PyList_Size(site_packages_list);
     for (Py_ssize_t i = 0; i < n; ++i) {
@@ -212,7 +212,7 @@ std::string PyModule::get_site_packages()
     // run inside virtualenvs :-/
 
     auto site_packages_fn = PyObject_GetAttrString(site_module, "addsitepackages");
-    assert(site_packages_fn);
+    ceph_assert(site_packages_fn);
 
     auto known_paths = PySet_New(nullptr);
     auto pArgs = PyTuple_Pack(1, known_paths);
@@ -222,9 +222,9 @@ std::string PyModule::get_site_packages()
     Py_DECREF(site_packages_fn);
 
     auto sys_module = PyImport_ImportModule("sys");
-    assert(sys_module);
+    ceph_assert(sys_module);
     auto sys_path = PyObject_GetAttrString(sys_module, "path");
-    assert(sys_path);
+    ceph_assert(sys_path);
 
     dout(1) << "sys.path:" << dendl;
     auto n = PyList_Size(sys_path);
@@ -290,7 +290,7 @@ void PyModule::init_ceph_module()
 #else
   PyObject *ceph_module = Py_InitModule("ceph_module", module_methods);
 #endif
-  assert(ceph_module != nullptr);
+  ceph_assert(ceph_module != nullptr);
   std::map<const char*, PyTypeObject*> classes{
     {{"BaseMgrModule", &BaseMgrModuleType},
      {"BaseMgrStandbyModule", &BaseMgrStandbyModuleType},
@@ -301,7 +301,7 @@ void PyModule::init_ceph_module()
   for (auto [name, type] : classes) {
     type->tp_new = PyType_GenericNew;
     if (PyType_Ready(type) < 0) {
-      assert(0);
+      ceph_assert(0);
     }
     Py_INCREF(type);
 
@@ -314,7 +314,7 @@ void PyModule::init_ceph_module()
 
 int PyModule::load(PyThreadState *pMainThreadState)
 {
-  assert(pMainThreadState != nullptr);
+  ceph_assert(pMainThreadState != nullptr);
 
   // Configure sub-interpreter
   {
@@ -454,7 +454,7 @@ int PyModule::walk_dict_list(
   const size_t list_size = PyList_Size(command_list);
   for (size_t i = 0; i < list_size; ++i) {
     PyObject *command = PyList_GetItem(command_list, i);
-    assert(command != nullptr);
+    ceph_assert(command != nullptr);
 
     if (!PyDict_Check(command)) {
       derr << "Module " << get_name() << " has non-dict entry "
@@ -478,17 +478,17 @@ int PyModule::load_commands()
     ModuleCommand command;
 
     PyObject *pCmd = PyDict_GetItemString(pCommand, "cmd");
-    assert(pCmd != nullptr);
+    ceph_assert(pCmd != nullptr);
     command.cmdstring = PyString_AsString(pCmd);
 
     dout(20) << "loaded command " << command.cmdstring << dendl;
 
     PyObject *pDesc = PyDict_GetItemString(pCommand, "desc");
-    assert(pDesc != nullptr);
+    ceph_assert(pDesc != nullptr);
     command.helpstring = PyString_AsString(pDesc);
 
     PyObject *pPerm = PyDict_GetItemString(pCommand, "perm");
-    assert(pPerm != nullptr);
+    ceph_assert(pPerm != nullptr);
     command.perm = PyString_AsString(pPerm);
 
     command.polling = false;
@@ -516,7 +516,7 @@ int PyModule::load_options()
 {
   int r = walk_dict_list("OPTIONS", [this](PyObject *pOption) -> int {
     PyObject *pName = PyDict_GetItemString(pOption, "name");
-    assert(pName != nullptr);
+    ceph_assert(pName != nullptr);
 
     ModuleOption option;
     option.name = PyString_AsString(pName);
index 353e222d8f642dfae0938864a3c6e810f25b02c2..3ffdeb8f13a664f7678d5e84c3aab758133c6647 100644 (file)
@@ -126,7 +126,7 @@ public:
   void get_commands(std::vector<ModuleCommand> *out) const
   {
     Mutex::Locker l(lock);
-    assert(out != nullptr);
+    ceph_assert(out != nullptr);
     out->insert(out->end(), commands.begin(), commands.end());
   }
 
index c09e0eec5188e8c731a6fef2f057be55d00cff69..dbf2e3e8c1d5eb6f2a1142fc1f8cb0cc32ae80bf 100644 (file)
@@ -62,7 +62,7 @@ void PyModuleRegistry::init()
   // Drop the GIL and remember the main thread state (current
   // thread state becomes NULL)
   pMainThreadState = PyEval_SaveThread();
-  assert(pMainThreadState != nullptr);
+  ceph_assert(pMainThreadState != nullptr);
 
   std::list<std::string> failed_modules;
 
@@ -131,12 +131,12 @@ bool PyModuleRegistry::handle_mgr_map(const MgrMap &mgr_map_)
 void PyModuleRegistry::standby_start(MonClient &mc)
 {
   Mutex::Locker l(lock);
-  assert(active_modules == nullptr);
-  assert(standby_modules == nullptr);
+  ceph_assert(active_modules == nullptr);
+  ceph_assert(standby_modules == nullptr);
 
   // Must have seen a MgrMap by this point, in order to know
   // which modules should be enabled
-  assert(mgr_map.epoch > 0);
+  ceph_assert(mgr_map.epoch > 0);
 
   dout(4) << "Starting modules in standby mode" << dendl;
 
@@ -185,11 +185,11 @@ void PyModuleRegistry::active_start(
 
   dout(4) << "Starting modules in active mode" << dendl;
 
-  assert(active_modules == nullptr);
+  ceph_assert(active_modules == nullptr);
 
   // Must have seen a MgrMap by this point, in order to know
   // which modules should be enabled
-  assert(mgr_map.epoch > 0);
+  ceph_assert(mgr_map.epoch > 0);
 
   if (standby_modules != nullptr) {
     standby_modules->shutdown();
index 568e74099607d7ce849d6077fe5260cfffd0370c..089044433edd0a488867036f4ff52e9179d368b2 100644 (file)
@@ -110,7 +110,7 @@ public:
   void with_active_modules(Callback&& cb, Args&&...args) const
   {
     Mutex::Locker l(lock);
-    assert(active_modules != nullptr);
+    ceph_assert(active_modules != nullptr);
 
     std::forward<Callback>(cb)(*active_modules, std::forward<Args>(args)...);
   }
@@ -170,7 +170,7 @@ public:
 
   std::map<std::string, std::string> get_services() const
   {
-    assert(active_modules);
+    ceph_assert(active_modules);
     return active_modules->get_services();
   }
   // <<< (end of ActivePyModules cheeky call-throughs)
index b0324d488d68e792bf5c6461d2f673da2249fc53..403c8a9f183f30c4972e9c4d93d4f44229fb09cc 100644 (file)
@@ -38,7 +38,7 @@ PyModuleRunner::~PyModuleRunner()
 
 int PyModuleRunner::serve()
 {
-  assert(pClassInstance != nullptr);
+  ceph_assert(pClassInstance != nullptr);
 
   // This method is called from a separate OS thread (i.e. a thread not
   // created by Python), so tell Gil to wrap this in a new thread state.
@@ -75,7 +75,7 @@ int PyModuleRunner::serve()
 
 void PyModuleRunner::shutdown()
 {
-  assert(pClassInstance != nullptr);
+  ceph_assert(pClassInstance != nullptr);
 
   Gil gil(py_module->pMyThreadState, true);
 
index c6bf18926fae2171408d14739c03ae26f1936825..fb58bf0c2323f1a0920d8034d80fce261068cb9c 100644 (file)
@@ -70,7 +70,7 @@ public:
     // required to be <16 chars
     thread_name = py_module->get_name().substr(0, 15);
 
-    assert(py_module != nullptr);
+    ceph_assert(py_module != nullptr);
   }
 
   ~PyModuleRunner();
index 3847176f0bd1e13847d35f6f1f74f07b300704a2..3b050d29d4797856789e3014f8489b368236a5f1 100644 (file)
@@ -192,14 +192,14 @@ BasePyOSDMap_init(BasePyOSDMap *self, PyObject *args, PyObject *kwds)
     if (! PyArg_ParseTupleAndKeywords(args, kwds, "O",
                                       const_cast<char**>(kwlist),
                                       &osdmap_capsule)) {
-      assert(0);
+      ceph_assert(0);
         return -1;
     }
-    assert(PyObject_TypeCheck(osdmap_capsule, &PyCapsule_Type));
+    ceph_assert(PyObject_TypeCheck(osdmap_capsule, &PyCapsule_Type));
 
     self->osdmap = (OSDMap*)PyCapsule_GetPointer(
         osdmap_capsule, nullptr);
-    assert(self->osdmap);
+    ceph_assert(self->osdmap);
 
     return 0;
 }
@@ -291,14 +291,14 @@ BasePyOSDMapIncremental_init(BasePyOSDMapIncremental *self,
     if (! PyArg_ParseTupleAndKeywords(args, kwds, "O",
                                       const_cast<char**>(kwlist),
                                       &inc_capsule)) {
-      assert(0);
+      ceph_assert(0);
         return -1;
     }
-    assert(PyObject_TypeCheck(inc_capsule, &PyCapsule_Type));
+    ceph_assert(PyObject_TypeCheck(inc_capsule, &PyCapsule_Type));
 
     self->inc = (OSDMap::Incremental*)PyCapsule_GetPointer(
         inc_capsule, nullptr);
-    assert(self->inc);
+    ceph_assert(self->inc);
 
     return 0;
 }
@@ -376,7 +376,7 @@ static PyObject *osdmap_inc_set_compat_weight_set_weights(
   }
 
   CrushWrapper crush;
-  assert(self->inc->crush.length());  // see new_incremental
+  ceph_assert(self->inc->crush.length());  // see new_incremental
   auto p = self->inc->crush.cbegin();
   decode(crush, p);
   crush.create_choose_args(CrushWrapper::DEFAULT_CHOOSE_ARGS, 1);
@@ -460,10 +460,10 @@ BasePyCRUSH_init(BasePyCRUSH *self,
     if (! PyArg_ParseTupleAndKeywords(args, kwds, "O",
                                       const_cast<char**>(kwlist),
                                       &crush_capsule)) {
-      assert(0);
+      ceph_assert(0);
         return -1;
     }
-    assert(PyObject_TypeCheck(crush_capsule, &PyCapsule_Type));
+    ceph_assert(PyObject_TypeCheck(crush_capsule, &PyCapsule_Type));
 
     auto ptr_ref = (std::shared_ptr<CrushWrapper>*)(
         PyCapsule_GetPointer(crush_capsule, nullptr));
@@ -473,7 +473,7 @@ BasePyCRUSH_init(BasePyCRUSH *self,
     // pointer construction now, and then we throw away that pointer to
     // the shared pointer.
     self->crush = *ptr_ref;
-    assert(self->crush);
+    ceph_assert(self->crush);
 
     return 0;
 }
index 60fe4a01747ecf2eb58b65bb5ee1b27c965b3ab1..0113ae1cf30f666564b09916ae4d96022ba704a9 100644 (file)
@@ -77,7 +77,7 @@ int StandbyPyModules::start_one(PyModuleRef py_module)
   Mutex::Locker l(lock);
   const std::string &module_name = py_module->get_name();
 
-  assert(modules.count(module_name) == 0);
+  ceph_assert(modules.count(module_name) == 0);
 
   modules[module_name].reset(new StandbyPyModule(
       state,
@@ -104,9 +104,9 @@ int StandbyPyModule::load()
   // We tell the module how we name it, so that it can be consistent
   // with us in logging etc.
   auto pThisPtr = PyCapsule_New(this, nullptr, nullptr);
-  assert(pThisPtr != nullptr);
+  ceph_assert(pThisPtr != nullptr);
   auto pModuleName = PyString_FromString(get_name().c_str());
-  assert(pModuleName != nullptr);
+  ceph_assert(pModuleName != nullptr);
   auto pArgs = PyTuple_Pack(2, pModuleName, pThisPtr);
   Py_DECREF(pThisPtr);
   Py_DECREF(pModuleName);