]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/smb: simplify orch backend enablement
authorJohn Mulligan <jmulligan@redhat.com>
Wed, 21 Aug 2024 21:03:19 +0000 (17:03 -0400)
committerJohn Mulligan <jmulligan@redhat.com>
Mon, 26 Aug 2024 21:14:05 +0000 (17:14 -0400)
We have a developer/debug module option that allows one to disable
triggering orchestration. When I tried to use it I thought it was
buggy and I had trouble diagnosing it. The mistake was on my side,
but the code change makes it much clearer what is being enabled
so I want to keep it.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
src/pybind/mgr/smb/module.py

index 91069c07d573f18b3e7509007ec8ac3a848fce3e..1e71721202e806434e3ea7f377b02499d677e732 100644 (file)
@@ -56,8 +56,6 @@ class Module(orchestrator.OrchestratorClientMixin, MgrModule):
         authorizer = kwargs.pop('authorizer', None)
         uo = kwargs.pop('update_orchestration', None)
         super().__init__(*args, **kwargs)
-        # the update_orchestration property only works post-init
-        update_orchestration = self.update_orchestration if uo is None else uo
         if internal_store is not None:
             self._internal_store = internal_store
             log.info('Using internal_store passed to class: {internal_store}')
@@ -82,7 +80,7 @@ class Module(orchestrator.OrchestratorClientMixin, MgrModule):
             public_store=self._public_store,
             path_resolver=path_resolver,
             authorizer=authorizer,
-            orch=(self if update_orchestration else None),
+            orch=self._orch_backend(enable_orch=uo),
         )
 
     def _backend_store(self, store_conf: str = '') -> ConfigStore:
@@ -111,6 +109,18 @@ class Module(orchestrator.OrchestratorClientMixin, MgrModule):
             return sqlite_store.mgr_sqlite3_db(self, opts)
         raise ValueError(f'invalid internal store: {name}')
 
+    def _orch_backend(
+        self, enable_orch: Optional[bool] = None
+    ) -> Optional['Module']:
+        if enable_orch is not None:
+            log.info('smb orchestration argument supplied: %r', enable_orch)
+            return self if enable_orch else None
+        if self.update_orchestration:
+            log.warning('smb orchestration enabled by module')
+            return self
+        log.warning('smb orchestration is disabled')
+        return None
+
     @property
     def update_orchestration(self) -> bool:
         return cast(