From 8c845bd4ee8e0fddadcb78b2dba457022df39ff2 Mon Sep 17 00:00:00 2001 From: John Mulligan Date: Wed, 21 Aug 2024 17:03:19 -0400 Subject: [PATCH] mgr/smb: simplify orch backend enablement 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 --- src/pybind/mgr/smb/module.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/pybind/mgr/smb/module.py b/src/pybind/mgr/smb/module.py index 91069c07d57..1e71721202e 100644 --- a/src/pybind/mgr/smb/module.py +++ b/src/pybind/mgr/smb/module.py @@ -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( -- 2.39.5