From 448dd523b15776d3cb51ea71131fdb01a39aa4b9 Mon Sep 17 00:00:00 2001 From: John Mulligan Date: Mon, 28 Feb 2022 15:39:24 -0500 Subject: [PATCH] mgr/nfs: add known_cluster_ids to generalize nfs cluster id fetching The changes to the nfs module in 8c711afc are working but when I began writing more test automation I found a few more places in the export-configuration code path relying on the orchestration module only. This change generalizes the logic to source nfs clusters from orchestration when it's enabled but from the .nfs pool when orchestration is disabled. It then uses that call when loading the exports cache on the ExportMgr object. Signed-off-by: John Mulligan (cherry picked from commit 4d09660dea5696e5085a75694968aafe9253f47a) --- src/pybind/mgr/nfs/export.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/pybind/mgr/nfs/export.py b/src/pybind/mgr/nfs/export.py index bd7c6b4ede1bd..3ca4147123e32 100644 --- a/src/pybind/mgr/nfs/export.py +++ b/src/pybind/mgr/nfs/export.py @@ -40,6 +40,15 @@ FuncT = TypeVar('FuncT', bound=Callable) log = logging.getLogger(__name__) +def known_cluster_ids(mgr: 'Module') -> Set[str]: + """Return the set of known cluster IDs.""" + try: + clusters = set(available_clusters(mgr)) + except NoOrchestrator: + clusters = nfs_rados_configs(mgr.rados) + return clusters + + def export_cluster_checker(func: FuncT) -> FuncT: def cluster_check( export: 'ExportMgr', @@ -49,10 +58,7 @@ def export_cluster_checker(func: FuncT) -> FuncT: """ This method checks if cluster exists """ - try: - clusters = set(available_clusters(export.mgr)) - except NoOrchestrator: - clusters = nfs_rados_configs(export.mgr.rados) + clusters = known_cluster_ids(export.mgr) cluster_id: str = kwargs['cluster_id'] log.debug("checking for %r in known nfs clusters: %r", cluster_id, clusters) @@ -187,7 +193,7 @@ class ExportMgr: if self._exports is None: self._exports = {} log.info("Begin export parsing") - for cluster_id in available_clusters(self.mgr): + for cluster_id in known_cluster_ids(self.mgr): self.export_conf_objs = [] # type: List[Export] self._read_raw_config(cluster_id) self.exports[cluster_id] = self.export_conf_objs -- 2.39.5