New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mgr: python interface rework + enable modules to run in standby mode #16651
Conversation
jcsp
commented
Jul 28, 2017
•
edited
edited
- Update documentation + release notes for "mgr services" command.
- Add mechanism for python modules to serve in standby mode
fe2ebda
to
dd6a676
Compare
dd6a676
to
c987acb
Compare
3022d7f
to
41fc275
Compare
5644228
to
927920b
Compare
Do we already want to include the "can_run()" method here? Like we discussed on the Ceph day. Meaning that we check if a module is able to run before we attempt it. |
@wido definitely want it, but this PR is already huge so let's do it separately afterwards |
927920b
to
15f4add
Compare
OK - docs built |
@jcsp: Understood! Was scanning through the code and didn't see it. Just wanted to double-check I didn't miss anything. |
6e5dd29
to
86f0766
Compare
make check succeeded |
c8f0882
to
0baa5b6
Compare
src/mgr/PyState.cc
Outdated
|
||
|
||
typedef struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit, no need to typedef a struct in C++.
src/mgr/PyModuleRegistry.cc
Outdated
// Load python code | ||
for (const auto& module_name : mgr_map.modules) { | ||
dout(1) << "Loading python module '" << module_name << "'" << dendl; | ||
auto mod = std::unique_ptr<PyModule>(new PyModule(module_name)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could use make_unique()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/pybind/mgr/dashboard/module.py
Outdated
@@ -184,6 +184,14 @@ def notify(self, notify_type, notify_val): | |||
self.log_buffer.appendleft(notify_val) | |||
elif notify_type == "pg_summary": | |||
self.update_pool_stats() | |||
|
|||
#pg_summary = self.get("pg_summary") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this change is not related to the noop stub of os._exit()
. can we drop it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops! done.
src/mgr/PyModuleRunner.h
Outdated
|
||
PyModuleRunnerThread thread; | ||
|
||
std::string const &get_name() { return module_name; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit, make this method const
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
serve_threads[i.first].reset(thread); | ||
} | ||
int r = modules[module_name]->load(this); | ||
if (r != 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shall we remove the module failed to load from modules
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the moment I suggest we keep them there -- later we might want to add a mechanism for reporting to the MgrMonitor about the list of modules that we tried and failed to load, so they need remembering somewhere.
src/mgr/ActivePyModule.cc
Outdated
@@ -134,7 +134,19 @@ int ActivePyModule::load_commands() | |||
// Don't need a Gil here -- this is called from ActivePyModule::load(), | |||
// which already has one. | |||
PyObject *command_list = PyObject_GetAttrString(pClassInstance, "COMMANDS"); | |||
assert(command_list != nullptr); | |||
if (command_list == nullptr) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. I kind of disagree with the guidelines on this one, I like being explicit that I'm checking a pointer rather than evaluating a class instance for truthiness. I don't remember if the google C++ guide takes a position on this.
src/mgr/PyModuleRegistry.cc
Outdated
Py_INCREF(&BaseMgrModuleType); | ||
PyModule_AddObject(ceph_module, "BaseMgrModule", | ||
(PyObject *)&BaseMgrModuleType); | ||
auto load_class = [ceph_module](std::string name, PyTypeObject *type) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit, could just pass const char*
instead of a std::string
src/mgr/PyModuleRegistry.cc
Outdated
Py_InitModule("ceph_crushmap", CRUSHMapMethods); | ||
*/ | ||
|
||
auto load_class = [ceph_module](std::string name, PyTypeObject *type) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit, pass const char*
instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@jcsp, could we split the mds related changes into separated PR(s)? |
Separate out the *loading* of modules from the *running* of modules. This is a precursor to enabling modules to run in standby mode. Signed-off-by: John Spray <john.spray@redhat.com>
Signed-off-by: John Spray <john.spray@redhat.com>
Modules can implement a second, separate class that has access to very little state about the system and can't implement commands. They have just enough information to redirect or forward incoming requests/traffic to the active instance of the module on the active mgr. This enables module authors to create modules that end users can access via any (running) mgr node at any time, rather than having to first work out which mgr node is active. Signed-off-by: John Spray <john.spray@redhat.com>
...they still don't have access to any config though. Signed-off-by: John Spray <john.spray@redhat.com>
Signed-off-by: John Spray <john.spray@redhat.com>
Signed-off-by: John Spray <john.spray@redhat.com>
Signed-off-by: John Spray <john.spray@redhat.com>
These would throw an exception when passed a status code. Signed-off-by: John Spray <john.spray@redhat.com>
...by using PyModuleRunner class from ActivePyModule too. Signed-off-by: John Spray <john.spray@redhat.com>
Was passing a reference to a local stringstream into Thread::create, not realising that it was taking a char* reference instead of a copy. Result was garbage (or usually, all threads having the name of the last one created) Signed-off-by: John Spray <john.spray@redhat.com>
Was calling way too early, which did a Py_Finalize before the modules had been joined. Signed-off-by: John Spray <john.spray@redhat.com>
Signed-off-by: Sage Weil <sage@redhat.com>
Implement real python classes from the C side, rather than exposing only module methods. Signed-off-by: John Spray <john.spray@redhat.com>
A bunch of the previous commits were done before this class existed, so updating in one go instead of trying to edit history in fine detail. Signed-off-by: John Spray <john.spray@redhat.com>
This was doing a Py_DECREF outside of the Gil. Fixes: http://tracker.ceph.com/issues/21593 Signed-off-by: John Spray <john.spray@redhat.com>
These didn't need to keep the GIL to go and do their pure C++ parts, and by keeping it they could deadlock while trying to take ActiveMgrModules::lock. Signed-off-by: John Spray <john.spray@redhat.com>
Signed-off-by: John Spray <john.spray@redhat.com>
Some extra coverage of the dashboard, including its standby redirect mode and the publishing of URIs. Also invoking the command_spam mode of the selftest module. Signed-off-by: John Spray <john.spray@redhat.com>
This was still using Kraken era settings Signed-off-by: John Spray <john.spray@redhat.com>
Signed-off-by: John Spray <john.spray@redhat.com>
...including the new "mgr services" command. Signed-off-by: John Spray <john.spray@redhat.com>
Otherwise, when someone wants to see what's possible to do with `mgr module enable` they have to trawl through the whole mgr map dump. Signed-off-by: John Spray <john.spray@redhat.com>
aff38be
to
5861c4c
Compare
all commits in this PR are signed |
submodules for project are unmodified |
OK - docs built |
make check succeeded |
1 similar comment
make check succeeded |