From: John Mulligan Date: Mon, 28 Feb 2022 20:39:24 +0000 (-0500) Subject: mgr/nfs: add known_cluster_ids to generalize nfs cluster id fetching X-Git-Tag: v18.0.0~1280^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=4d09660dea5696e5085a75694968aafe9253f47a;p=ceph.git 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 --- diff --git a/src/pybind/mgr/nfs/export.py b/src/pybind/mgr/nfs/export.py index bd7c6b4ede1b..3ca4147123e3 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