Skip to content

Commit

Permalink
Merge pull request #18412 from kmroz/wip-21659-luminous
Browse files Browse the repository at this point in the history
luminous: mgr: fix crashable DaemonStateIndex::get calls

Reviewed-by: John Spray <john.spray@redhat.com>
  • Loading branch information
John Spray committed Nov 1, 2017
2 parents 4dc0a0e + 8f87fa2 commit 2988a39
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
18 changes: 14 additions & 4 deletions src/mgr/PyModules.cc
Expand Up @@ -119,10 +119,15 @@ PyObject *PyModules::list_servers_python()

PyObject *PyModules::get_metadata_python(
std::string const &handle,
const std::string &svc_name,
const std::string &svc_type,
const std::string &svc_id)
{
auto metadata = daemon_state.get(DaemonKey(svc_name, svc_id));
auto metadata = daemon_state.get(DaemonKey(svc_type, svc_id));
if (metadata == nullptr) {
derr << "Requested missing service " << svc_type << "." << svc_id << dendl;
Py_RETURN_NONE;
}

Mutex::Locker l(metadata->lock);
PyFormatter f;
f.dump_string("hostname", metadata->hostname);
Expand All @@ -135,10 +140,15 @@ PyObject *PyModules::get_metadata_python(

PyObject *PyModules::get_daemon_status_python(
std::string const &handle,
const std::string &svc_name,
const std::string &svc_type,
const std::string &svc_id)
{
auto metadata = daemon_state.get(DaemonKey(svc_name, svc_id));
auto metadata = daemon_state.get(DaemonKey(svc_type, svc_id));
if (metadata == nullptr) {
derr << "Requested missing service " << svc_type << "." << svc_id << dendl;
Py_RETURN_NONE;
}

Mutex::Locker l(metadata->lock);
PyFormatter f;
for (const auto &i : metadata->service_status) {
Expand Down
4 changes: 2 additions & 2 deletions src/mgr/PyModules.h
Expand Up @@ -69,10 +69,10 @@ class PyModules
PyObject *list_servers_python();
PyObject *get_metadata_python(
std::string const &handle,
const std::string &svc_name, const std::string &svc_id);
const std::string &svc_type, const std::string &svc_id);
PyObject *get_daemon_status_python(
std::string const &handle,
const std::string &svc_name, const std::string &svc_id);
const std::string &svc_type, const std::string &svc_id);
PyObject *get_counter_python(
std::string const &handle,
const std::string &svc_name,
Expand Down

0 comments on commit 2988a39

Please sign in to comment.