From de0c19893224955552948de7778c4cff5febfaf0 Mon Sep 17 00:00:00 2001 From: Sebastian Wagner Date: Thu, 12 Sep 2019 10:25:21 +0200 Subject: [PATCH] mgr/orchestrator: add cancel Signed-off-by: Sebastian Wagner --- src/pybind/mgr/orchestrator.py | 8 ++++++++ src/pybind/mgr/orchestrator_cli/module.py | 9 +++++++++ src/pybind/mgr/rook/module.py | 5 +++++ 3 files changed, 22 insertions(+) diff --git a/src/pybind/mgr/orchestrator.py b/src/pybind/mgr/orchestrator.py index a88bf7f09fe9d..bd9be59571768 100644 --- a/src/pybind/mgr/orchestrator.py +++ b/src/pybind/mgr/orchestrator.py @@ -679,6 +679,14 @@ class Orchestrator(object): } return features + @_hide_in_features + def cancel_completions(self): + # type: () -> None + """ + Cancels ongoing completions. Unstuck the mgr. + """ + raise NotImplementedError() + def add_host(self, host): # type: (str) -> Completion """ diff --git a/src/pybind/mgr/orchestrator_cli/module.py b/src/pybind/mgr/orchestrator_cli/module.py index 3765b4201f79e..ba0eed03e7366 100644 --- a/src/pybind/mgr/orchestrator_cli/module.py +++ b/src/pybind/mgr/orchestrator_cli/module.py @@ -659,6 +659,15 @@ Usage: return HandleCommandResult(-errno.EINVAL, stderr="Module '{0}' not found".format(module_name)) + @_write_cli('orchestrator cancel', + desc='cancels ongoing operations') + def _cancel(self): + """ + ProgressReferences might get stuck. Let's unstuck them. + """ + self.cancel_completions() + return HandleCommandResult() + @orchestrator._cli_read_command( 'orchestrator status', desc='Report configured backend and its status') diff --git a/src/pybind/mgr/rook/module.py b/src/pybind/mgr/rook/module.py index 473e21fb53475..b2092d167ef40 100644 --- a/src/pybind/mgr/rook/module.py +++ b/src/pybind/mgr/rook/module.py @@ -205,6 +205,11 @@ class RookOrchestrator(MgrModule, orchestrator.Orchestrator): self._shutdown.wait(5) + def cancel_completions(self): + for p in self.all_progress_references: + p.fail() + self.all_progress_references.clear() + @deferred_read def get_inventory(self, node_filter=None, refresh=False): node_list = None -- 2.39.5