]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr: expose rocksdb version number in the mgr module
authorLaura Flores <lflores@redhat.com>
Wed, 22 Dec 2021 23:09:25 +0000 (23:09 +0000)
committerLaura Flores <lflores@redhat.com>
Tue, 11 Jan 2022 23:03:54 +0000 (23:03 +0000)
It is only necessary here to link the rocksdb include directory
since the mgr simply needs access to the rocksdb version numbers.

Signed-off-by: Laura Flores <lflores@redhat.com>
Co-authored-by: Kefu Chai <tchaikov@gmail.com>
Co-authored-by: Adam Kupczyk <akupczyk@redhat.com>
src/CMakeLists.txt
src/mgr/ActivePyModules.cc
src/mgr/ActivePyModules.h
src/mgr/BaseMgrModule.cc
src/mgr/CMakeLists.txt
src/pybind/mgr/ceph_module.pyi
src/pybind/mgr/mgr_module.py

index 7c1a9fe89f66eb36d3cddbb2c34f7db2fe75eb4a..1157df00a1995d7ffb1fdd31db5696b5890050fd 100644 (file)
@@ -593,6 +593,13 @@ if(WITH_LIBRADOSSTRIPER)
   add_subdirectory(libradosstriper)
 endif()
 
+# make rocksdb statically
+
+if(NOT WITH_SYSTEM_ROCKSDB)
+  include(BuildRocksDB)
+  build_rocksdb()
+endif(NOT WITH_SYSTEM_ROCKSDB)
+
 if(WITH_MGR)
   add_subdirectory(mgr)
 endif()
@@ -630,12 +637,6 @@ target_link_libraries(ceph-mon mon os global-static ceph-common
 install(TARGETS ceph-mon DESTINATION bin)
 
 # OSD/ObjectStore
-# make rocksdb statically
-
-if(NOT WITH_SYSTEM_ROCKSDB)
-  include(BuildRocksDB)
-  build_rocksdb()
-endif(NOT WITH_SYSTEM_ROCKSDB)
 
 include(TestBigEndian)
 test_big_endian(CEPH_BIG_ENDIAN)
index 0c08f3a02b5231b05631c588fe820fe5457482d6..1e9b932daa9cc2d547dc31f94a2581665d30e4b9 100644 (file)
 // Include this first to get python headers earlier
 #include "Gil.h"
 
+#include "ActivePyModules.h"
+
+#include <rocksdb/version.h>
+
 #include "common/errno.h"
 #include "include/stringify.h"
 
-#include "PyFormatter.h"
-
-#include "osd/OSDMap.h"
 #include "mon/MonMap.h"
+#include "osd/OSDMap.h"
 #include "osd/osd_types.h"
 #include "mgr/MgrContext.h"
 #include "mgr/TTLCache.h"
 #include "mgr/mgr_perf_counters.h"
 
+#include "DaemonKey.h"
+#include "DaemonServer.h"
+#include "mgr/MgrContext.h"
+#include "PyFormatter.h"
 // For ::mgr_store_prefix
 #include "PyModule.h"
 #include "PyModuleRegistry.h"
 #include "PyUtil.h"
 
-#include "ActivePyModules.h"
-#include "DaemonKey.h"
-#include "DaemonServer.h"
-
 #define dout_context g_ceph_context
 #define dout_subsys ceph_subsys_mgr
 #undef dout_prefix
@@ -1025,6 +1027,15 @@ PyObject* ActivePyModules::get_perf_schema_python(
   return f.get();
 }
 
+PyObject* ActivePyModules::get_rocksdb_version()
+{
+  std::string version = std::to_string(ROCKSDB_MAJOR) + "." +
+                        std::to_string(ROCKSDB_MINOR) + "." +
+                        std::to_string(ROCKSDB_PATCH);
+
+  return PyUnicode_FromString(version.c_str());
+}
+
 PyObject *ActivePyModules::get_context()
 {
   auto l = without_gil([&] {
index 3054fa3a2772f076b16228145f270077de8510df..2547c2565386c3fa919a684e59c55a86d4052b95 100644 (file)
@@ -101,6 +101,7 @@ public:
   PyObject *get_perf_schema_python(
      const std::string &svc_type,
      const std::string &svc_id);
+  PyObject *get_rocksdb_version();
   PyObject *get_context();
   PyObject *get_osdmap();
   /// @note @c fct is not allowed to acquire locks when holding GIL
index bd6475a2bedb01b60e3181f572ae5e8e4bb2dee7..4c905a6f79ecdde3e654ebb4c3d387967af57290 100644 (file)
@@ -670,6 +670,13 @@ get_perf_schema(BaseMgrModule *self, PyObject *args)
   return self->py_modules->get_perf_schema_python(type_str, svc_id);
 }
 
+static PyObject*
+ceph_get_rocksdb_version(BaseMgrModule *self)
+{
+  return self->py_modules->get_rocksdb_version();
+}
+
+
 static PyObject *
 ceph_get_osdmap(BaseMgrModule *self, PyObject *args)
 {
@@ -1446,6 +1453,9 @@ PyMethodDef BaseMgrModule_methods[] = {
   {"_ceph_get_perf_schema", (PyCFunction)get_perf_schema, METH_VARARGS,
     "Get the performance counter schema"},
 
+  {"_ceph_get_rocksdb_version", (PyCFunction)ceph_get_rocksdb_version, METH_NOARGS,
+    "Get the current RocksDB version number"},
+
   {"_ceph_log", (PyCFunction)ceph_log, METH_VARARGS,
    "Emit a (local) log message"},
 
index d688030343edb306d8cf894f421143e1a83a2665..a53d1d8c2a0a5fd45eac95762dbcfa335679fa14 100644 (file)
@@ -37,6 +37,8 @@ if(WITH_MGR)
   if(WITH_LIBCEPHSQLITE)
     target_link_libraries(ceph-mgr cephsqlite SQLite3::SQLite3)
   endif()
+  target_include_directories(ceph-mgr PRIVATE
+    $<TARGET_PROPERTY:RocksDB::RocksDB,INTERFACE_INCLUDE_DIRECTORIES>)
   target_link_libraries(ceph-mgr
     osdc client heap_profiler
     global-static ceph-common
index 4794d9c36112e2e626cb44f1b53032d7e20c9487..ca323870e58525868a14e25efcc6e064ef079aba 100644 (file)
@@ -71,6 +71,7 @@ class BaseMgrModule(object):
     def _ceph_get_server(self, hostname: Optional[str]) -> Union[ServerInfoT,
                                                                  List[ServerInfoT]]: ...
     def _ceph_get_perf_schema(self, svc_type: str, svc_name: str) -> Dict[str, Any]: ...
+    def _ceph_get_rocksdb_version(self) -> str: ...
     def _ceph_get_counter(self, svc_type: str, svc_name: str, path: str) -> Dict[str, List[Tuple[float, int]]]: ...
     def _ceph_get_latest_counter(self, svc_type, svc_name, path): ...
     def _ceph_get_metadata(self, svc_type, svc_id): ...
index b9c86be7c3e2ee412bfb5054f2334247fcd837b2..30cd1fc5e4b575d6e35d70c17c6d7688a8376a45 100644 (file)
@@ -1452,6 +1452,14 @@ class MgrModule(ceph_module.BaseMgrModule, MgrModuleLoggingMixin):
         """
         return self._ceph_get_perf_schema(svc_type, svc_name)
 
+    def get_rocksdb_version(self) -> str:
+        """
+        Called by the plugin to fetch the latest RocksDB version number.
+
+        :return: str representing the major, minor, and patch RocksDB version numbers
+        """
+        return self._ceph_get_rocksdb_version()
+
     @API.expose
     def get_counter(self,
                     svc_type: str,