]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/nfs: add known_cluster_ids to generalize nfs cluster id fetching
authorJohn Mulligan <jmulligan@redhat.com>
Mon, 28 Feb 2022 20:39:24 +0000 (15:39 -0500)
committerAdam King <adking@redhat.com>
Wed, 6 Apr 2022 20:12:47 +0000 (16:12 -0400)
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 <jmulligan@redhat.com>
(cherry picked from commit 4d09660dea5696e5085a75694968aafe9253f47a)

src/pybind/mgr/nfs/export.py

index bd7c6b4ede1bdd8a7005bc27e75d9f49ea4acc9d..3ca4147123e3297e536447a6c07ec8f1b16fe3a8 100644 (file)
@@ -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