From f67df98d4389d81a721efed9908ffaa340dbec87 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Wed, 10 Oct 2018 16:22:59 +0800 Subject: [PATCH] mgr/restful: do not print warning message at seeing unknown request mgr broadcast "notify()" to call registered plugins upon finishing a send_command() request. and restful plugin prints a warning message if the request is not issued by itself. apparently, there is good chance that the finished request is sent by other mgr plugins, in that case, restful plugin always prints the warning messages like: "2018-10-09 14:52:07.818 7fbc4d8c5700 1 mgr[restful] Unknown request '' this is misleading and annoying. so, in this change * add a prefix of "restful.module" before that tag used for identifying a request. this prefix helps to differentiate the requests sent by restful plugin from other requests. * do not print warning message if none running request matches the given tag * break at seeing the first request matches the given tag, because the tags used by restful plugin are unique. * do not str(self.id) before composing the tag, as it is a `str` already, see CommandsRequest.__init__() * early return to reduce the indent level Fixes: http://tracker.ceph.com/issues/36374 Signed-off-by: Kefu Chai --- src/pybind/mgr/restful/module.py | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/src/pybind/mgr/restful/module.py b/src/pybind/mgr/restful/module.py index a3fcb71c87a96..5b55da92da5be 100644 --- a/src/pybind/mgr/restful/module.py +++ b/src/pybind/mgr/restful/module.py @@ -80,7 +80,7 @@ class CommandsRequest(object): # Gather the results (in parallel) results = [] for index in range(len(commands)): - tag = '%s:%d' % (str(self.id), index) + tag = '%s:%s:%d' % (__name__, self.id, index) # Store the result result = CommandResult(tag) @@ -361,22 +361,20 @@ class Module(MgrModule): def _notify(self, notify_type, tag): - if notify_type == "command": - # we can safely skip all the sequential commands - if tag == 'seq': - return - - request = [x for x in self.requests if x.is_running(tag)] - if len(request) != 1: - self.log.warn("Unknown request '%s'" % str(tag)) - return - - request = request[0] + if notify_type != "command": + self.log.debug("Unhandled notification type '%s'", notify_type) + return + # we can safely skip all the sequential commands + if tag == 'seq': + return + try: + request = next(x for x in self.requests if x.is_running(tag)) request.finish(tag) if request.is_ready(): request.next() - else: - self.log.debug("Unhandled notification type '%s'" % notify_type) + except StopIteration: + # the command was not issued by me + pass def create_self_signed_cert(self): -- 2.39.5