From 0eaa7710c0a8f514ddf5c8fcabad1c3e0d012fc9 Mon Sep 17 00:00:00 2001 From: Tim Serong Date: Mon, 25 Nov 2019 15:43:25 +1100 Subject: [PATCH] mgr/orchestrator: use finalize to set TrivialReadCompletion result This is needed to correctly set the state of the completion, so that Completion.has_result returns true. Without this, _orchestrator_wait() will spin forever if given a TrivialReadCompletion. Signed-off-by: Tim Serong Signed-off-by: Sebastian Wagner --- src/pybind/mgr/orchestrator.py | 3 ++- src/pybind/mgr/orchestrator_cli/module.py | 8 ++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/pybind/mgr/orchestrator.py b/src/pybind/mgr/orchestrator.py index 8b313922a98..7ddba059ac0 100644 --- a/src/pybind/mgr/orchestrator.py +++ b/src/pybind/mgr/orchestrator.py @@ -637,7 +637,8 @@ class TrivialReadCompletion(Completion): """ def __init__(self, result): super(TrivialReadCompletion, self).__init__() - self._result = result + if result: + self.finalize(result) def _hide_in_features(f): diff --git a/src/pybind/mgr/orchestrator_cli/module.py b/src/pybind/mgr/orchestrator_cli/module.py index ba0eed03e73..fef10673c98 100644 --- a/src/pybind/mgr/orchestrator_cli/module.py +++ b/src/pybind/mgr/orchestrator_cli/module.py @@ -659,8 +659,9 @@ Usage: return HandleCommandResult(-errno.EINVAL, stderr="Module '{0}' not found".format(module_name)) - @_write_cli('orchestrator cancel', - desc='cancels ongoing operations') + @orchestrator._cli_write_command( + 'orchestrator cancel', + desc='cancels ongoing operations') def _cancel(self): """ ProgressReferences might get stuck. Let's unstuck them. @@ -705,3 +706,6 @@ Usage: assert False except orchestrator.OrchestratorError as e: assert e.args == ('hello', 'world') + + c = orchestrator.TrivialReadCompletion(result=True) + assert c.has_result -- 2.39.5