]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr: excise CephFS client from mgr C++ base
authorPatrick Donnelly <pdonnell@ibm.com>
Thu, 30 Jan 2025 22:08:07 +0000 (17:08 -0500)
committerPatrick Donnelly <pdonnell@ibm.com>
Fri, 28 Feb 2025 00:55:45 +0000 (19:55 -0500)
Linking to the client causes two copies of the Client library to be linked in
the ceph-mgr when modules also dynamically link to libcephfs via the "cephfs"
python library. This creates problems with duplicate boost::locale.

Instead, modules should just use the "cephfs" library to send commands to the
MDS.

Signed-off-by: Patrick Donnelly <pdonnell@ibm.com>
src/mgr/ActivePyModules.cc
src/mgr/ActivePyModules.h
src/mgr/BaseMgrModule.cc
src/mgr/CMakeLists.txt
src/mgr/Mgr.cc
src/mgr/Mgr.h
src/mgr/MgrStandby.cc
src/mgr/MgrStandby.h
src/mgr/PyModuleRegistry.cc
src/mgr/PyModuleRegistry.h

index c7b4db2d29469d2b75f3054f9cbecbb31a7e048f..709fcfae227c751f423a6f1cdebb4ee747eeaad1 100644 (file)
@@ -54,11 +54,11 @@ ActivePyModules::ActivePyModules(
   DaemonStateIndex &ds, ClusterState &cs,
   MonClient &mc, LogChannelRef clog_,
   LogChannelRef audit_clog_, Objecter &objecter_,
-  Client &client_, Finisher &f, DaemonServer &server,
+  Finisher &f, DaemonServer &server,
   PyModuleRegistry &pmr)
 : module_config(module_config_), daemon_state(ds), cluster_state(cs),
   monc(mc), clog(clog_), audit_clog(audit_clog_), objecter(objecter_),
-  client(client_), finisher(f),
+  finisher(f),
   cmd_finisher(g_ceph_context, "cmd_finisher", "cmdfin"),
   server(server), py_module_registry(pmr)
 {
index c48a06ce95e4d36067f84842810c743fc4b8fdcf..a41540503756492de089528130babef11462e25e 100644 (file)
@@ -21,7 +21,6 @@
 #include "PyFormatter.h"
 
 #include "osdc/Objecter.h"
-#include "client/Client.h"
 #include "common/LogClient.h"
 #include "mon/MgrMap.h"
 #include "mon/MonCommand.h"
@@ -58,7 +57,6 @@ class ActivePyModules
   MonClient &monc;
   LogChannelRef clog, audit_clog;
   Objecter &objecter;
-  Client   &client;
   Finisher &finisher;
   TTLCache<std::string, PyObject*> ttl_cache;
 public:
@@ -77,7 +75,7 @@ public:
     std::map<std::string, std::string> store_data,
     bool mon_provides_kv_sub,
     DaemonStateIndex &ds, ClusterState &cs, MonClient &mc,
-    LogChannelRef clog_, LogChannelRef audit_clog_, Objecter &objecter_, Client &client_,
+    LogChannelRef clog_, LogChannelRef audit_clog_, Objecter &objecter_,
     Finisher &f, DaemonServer &server, PyModuleRegistry &pmr);
 
   ~ActivePyModules();
@@ -85,7 +83,6 @@ public:
   // FIXME: wrap for send_command?
   MonClient &get_monc() {return monc;}
   Objecter  &get_objecter() {return objecter;}
-  Client    &get_client() {return client;}
   PyObject *cacheable_get_python(const std::string &what);
   PyObject *get_python(const std::string &what);
   PyObject *get_server_python(const std::string &hostname);
index 67d9986ef8e99335c68ac97d4481cb4ec828c101..bae5d54d74790f124a6cbfa2ef0618c450de2178 100644 (file)
@@ -207,21 +207,11 @@ ceph_send_command(BaseMgrModule *self, PyObject *args, PyObject *kwargs)
          f->queue(command_c);
        });
   } else if (std::string(type) == "mds") {
-    int r = self->py_modules->get_client().mds_command(
-        name,
-        {cmd_json},
-        inbuf,
-        &command_c->outbl,
-        &command_c->outs,
-        new C_OnFinisher(command_c, &self->py_modules->cmd_finisher),
-        one_shot);
-    if (r != 0) {
-      string msg("failed to send command to mds: ");
-      msg.append(cpp_strerror(r));
-      PyEval_RestoreThread(tstate);
-      PyErr_SetString(PyExc_RuntimeError, msg.c_str());
-      return nullptr;
-    }
+    string msg("cannot send command to mds via this interface: ");
+    msg.append(cpp_strerror(-ENOSYS));
+    PyEval_RestoreThread(tstate);
+    PyErr_SetString(PyExc_RuntimeError, msg.c_str());
+    return nullptr;
   } else if (std::string(type) == "pg") {
     pg_t pgid;
     if (!pgid.parse(name)) {
index 1e473355af057f3b671e4f36f44f2228c8d8bf7d..ab1722494f7f786134ba7db324164f4a66f8bfb0 100644 (file)
@@ -44,7 +44,7 @@ if(WITH_MGR)
   target_include_directories(ceph-mgr PRIVATE
     $<TARGET_PROPERTY:RocksDB::RocksDB,INTERFACE_INCLUDE_DIRECTORIES>)
   target_link_libraries(ceph-mgr
-    osdc client heap_profiler
+    osdc heap_profiler
     global-static ceph-common
     Boost::python${MGR_PYTHON_VERSION_MAJOR}${MGR_PYTHON_VERSION_MINOR}
     Python3::Python
index 9acd58248fbfe01ec4b693f6a270daa4ec329899..83c29388f82af2fff6a3c165d37e7c6b44e60767 100644 (file)
@@ -14,7 +14,6 @@
 #include <Python.h>
 
 #include "osdc/Objecter.h"
-#include "client/Client.h"
 #include "common/errno.h"
 #include "mon/MonClient.h"
 #include "include/stringify.h"
@@ -54,10 +53,9 @@ using std::string;
 Mgr::Mgr(MonClient *monc_, const MgrMap& mgrmap,
          PyModuleRegistry *py_module_registry_,
         Messenger *clientm_, Objecter *objecter_,
-        Client* client_, LogChannelRef clog_, LogChannelRef audit_clog_) :
+        LogChannelRef clog_, LogChannelRef audit_clog_) :
   monc(monc_),
   objecter(objecter_),
-  client(client_),
   client_messenger(clientm_),
   finisher(g_ceph_context, "Mgr", "mgr-fin"),
   digest_received(false),
@@ -351,7 +349,7 @@ void Mgr::init()
   py_module_registry->active_start(
     daemon_state, cluster_state,
     pre_init_store, mon_allows_kv_sub,
-    *monc, clog, audit_clog, *objecter, *client,
+    *monc, clog, audit_clog, *objecter,
     finisher, server);
 
   cluster_state.final_init();
index 65931c331f3638d8a5075a7077f3141ab48c4c80..b00590881d476f6104f6ae713527ca8b9e82034b 100644 (file)
@@ -35,13 +35,11 @@ class MMgrDigest;
 class MLog;
 class MServiceMap;
 class Objecter;
-class Client;
 
 class Mgr : public AdminSocketHook {
 protected:
   MonClient *monc;
   Objecter  *objecter;
-  Client    *client;
   Messenger *client_messenger;
 
   mutable ceph::mutex lock = ceph::make_mutex("Mgr::lock");
@@ -74,7 +72,7 @@ public:
   Mgr(MonClient *monc_, const MgrMap& mgrmap,
       PyModuleRegistry *py_module_registry_,
       Messenger *clientm_, Objecter *objecter_,
-      Client *client_, LogChannelRef clog_, LogChannelRef audit_clog_);
+      LogChannelRef clog_, LogChannelRef audit_clog_);
   ~Mgr();
 
   bool is_initialized() const {return initialized;}
index 052e68681772b68da28cae60af24a97838bd1db6..3fc14d9eb29d76fa362fd7b36b6edf18e6acee4c 100644 (file)
@@ -52,7 +52,6 @@ MgrStandby::MgrStandby(int argc, const char **argv) :
                     "mgr",
                     Messenger::get_random_nonce())),
   objecter{g_ceph_context, client_messenger.get(), &monc, poolctx},
-  client{client_messenger.get(), &monc, &objecter},
   mgrc(g_ceph_context, client_messenger.get(), &monc.monmap),
   log_client(g_ceph_context, client_messenger.get(), &monc.monmap, LogClient::NO_FLAGS),
   clog(log_client.create_channel(CLOG_CHANNEL_CLUSTER)),
@@ -131,7 +130,6 @@ int MgrStandby::init()
   // Initialize Messenger
   client_messenger->add_dispatcher_tail(this);
   client_messenger->add_dispatcher_head(&objecter);
-  client_messenger->add_dispatcher_tail(&client);
   client_messenger->start();
 
   poolctx.start(2);
@@ -198,7 +196,6 @@ int MgrStandby::init()
   objecter.set_client_incarnation(0);
   objecter.init();
   objecter.start();
-  client.init();
   timer.init();
 
   py_module_registry.init();
@@ -369,7 +366,7 @@ void MgrStandby::handle_mgr_map(ref_t<MMgrMap> mmap)
       dout(1) << "Activating!" << dendl;
       active_mgr.reset(new Mgr(&monc, map, &py_module_registry,
                                client_messenger.get(), &objecter,
-                              &client, clog, audit_clog));
+                              clog, audit_clog));
       active_mgr->background_init(new LambdaContext(
             [this](int r){
               // Advertise our active-ness ASAP instead of waiting for
index 5d238c8557796c2b43e44568acd530dc688c0096..35ce43c0c808582057906565183882c2dbe1c9e0 100644 (file)
@@ -21,7 +21,6 @@
 #include "common/Timer.h"
 #include "common/LogClient.h"
 
-#include "client/Client.h"
 #include "mon/MonClient.h"
 #include "osdc/Objecter.h"
 #include "PyModuleRegistry.h"
@@ -44,7 +43,6 @@ protected:
   MonClient monc;
   std::unique_ptr<Messenger> client_messenger;
   Objecter objecter;
-  Client client;
 
   MgrClient mgrc;
 
index 08501568a2cd6b80e112aae9b90e01c2890bd950..42555289b4f07fbed14f75a0a34ffd92d1b0b6e8 100644 (file)
@@ -211,7 +211,7 @@ void PyModuleRegistry::active_start(
             const std::map<std::string, std::string> &kv_store,
            bool mon_provides_kv_sub,
             MonClient &mc, LogChannelRef clog_, LogChannelRef audit_clog_,
-            Objecter &objecter_, Client &client_, Finisher &f,
+            Objecter &objecter_, Finisher &f,
             DaemonServer &server)
 {
   std::lock_guard locker(lock);
@@ -234,7 +234,7 @@ void PyModuleRegistry::active_start(
       module_config,
       kv_store, mon_provides_kv_sub,
       ds, cs, mc,
-      clog_, audit_clog_, objecter_, client_, f, server,
+      clog_, audit_clog_, objecter_, f, server,
       *this));
 
   for (const auto &i : modules) {
index 5224ab2040059f78ec36747a0f64821038746788..a89ae6c380fb8cc72beb1e0e23870c7f0f51abdf 100644 (file)
@@ -115,7 +115,7 @@ public:
                 const std::map<std::string, std::string> &kv_store,
                bool mon_provides_kv_sub,
                 MonClient &mc, LogChannelRef clog_, LogChannelRef audit_clog_,
-                Objecter &objecter_, Client &client_, Finisher &f,
+                Objecter &objecter_, Finisher &f,
                 DaemonServer &server);
   void standby_start(MonClient &mc, Finisher &f);