From ae295542e88a88865f90209fb0962f39099bf9a9 Mon Sep 17 00:00:00 2001 From: Jeff Layton Date: Wed, 6 Feb 2019 14:35:32 -0500 Subject: [PATCH] mgr/rook: fix result handling for RookWriteCompletions Add a result property, and ensure that the create_osd codepath returns a string with the result when an exception isn't triggered. Signed-off-by: Jeff Layton --- src/pybind/mgr/rook/module.py | 10 +++++++--- src/pybind/mgr/rook/rook_cluster.py | 5 +++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/pybind/mgr/rook/module.py b/src/pybind/mgr/rook/module.py index 850ccfaf086d..2199b43a819d 100644 --- a/src/pybind/mgr/rook/module.py +++ b/src/pybind/mgr/rook/module.py @@ -78,7 +78,7 @@ class RookWriteCompletion(orchestrator.WriteCompletion): self.executed = False # Result of k8s API call, this is set if executed==True - self.k8s_result = None + self._result = None self.effective = False @@ -92,6 +92,10 @@ class RookWriteCompletion(orchestrator.WriteCompletion): global all_completions all_completions.append(self) + @property + def result(self): + return self._result + @property def is_persistent(self): return (not self.is_errored) and self.executed @@ -106,7 +110,7 @@ class RookWriteCompletion(orchestrator.WriteCompletion): def execute(self): if not self.executed: - self.k8s_result = self.execute_cb() + self._result = self.execute_cb() self.executed = True if not self.effective: @@ -403,7 +407,7 @@ class RookOrchestrator(MgrModule, orchestrator.Orchestrator): "support OSD creation.") def execute(): - self.rook_cluster.add_osds(drive_group, all_hosts) + return self.rook_cluster.add_osds(drive_group, all_hosts) def is_complete(): # Find OSD pods on this host diff --git a/src/pybind/mgr/rook/rook_cluster.py b/src/pybind/mgr/rook/rook_cluster.py index 740151f620f3..5d319b4758c1 100644 --- a/src/pybind/mgr/rook/rook_cluster.py +++ b/src/pybind/mgr/rook/rook_cluster.py @@ -404,8 +404,7 @@ class RookCluster(object): }) if len(patch) == 0: - log.warning("No-op adding stateful service") - return + return "No change" try: self.rook_api_patch( @@ -416,3 +415,5 @@ class RookCluster(object): raise ApplyException( "Failed to create OSD entries in Cluster CRD: {0}".format( e)) + + return "Success" -- 2.47.3