Skip to content

Commit e338e1f

Browse files
authored
Merge pull request ceph#45211 from phlogistonjohn/jjm-nfs-cleanups3
mgr/nfs: Additional fixes for NFS export management without orchestration Reviewed-by: Adam King <[email protected]> Reviewed-by: Michael Fritch <[email protected]>
2 parents 43cc294 + dd5a47f commit e338e1f

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

src/pybind/mgr/nfs/export.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@
2020
from mgr_module import NFS_POOL_NAME as POOL_NAME, NFS_GANESHA_SUPPORTED_FSALS
2121

2222
from .export_utils import GaneshaConfParser, Export, RawBlock, CephFSFSAL, RGWFSAL
23-
from .exception import NFSException, NFSInvalidOperation, FSNotFound, \
24-
ClusterNotFound
23+
from .exception import NFSException, NFSInvalidOperation, FSNotFound
2524
from .utils import (
2625
CONF_PREFIX,
2726
EXPORT_PREFIX,
@@ -40,6 +39,15 @@
4039
log = logging.getLogger(__name__)
4140

4241

42+
def known_cluster_ids(mgr: 'Module') -> Set[str]:
43+
"""Return the set of known cluster IDs."""
44+
try:
45+
clusters = set(available_clusters(mgr))
46+
except NoOrchestrator:
47+
clusters = nfs_rados_configs(mgr.rados)
48+
return clusters
49+
50+
4351
def export_cluster_checker(func: FuncT) -> FuncT:
4452
def cluster_check(
4553
export: 'ExportMgr',
@@ -49,10 +57,7 @@ def cluster_check(
4957
"""
5058
This method checks if cluster exists
5159
"""
52-
try:
53-
clusters = set(available_clusters(export.mgr))
54-
except NoOrchestrator:
55-
clusters = nfs_rados_configs(export.mgr.rados)
60+
clusters = known_cluster_ids(export.mgr)
5661
cluster_id: str = kwargs['cluster_id']
5762
log.debug("checking for %r in known nfs clusters: %r",
5863
cluster_id, clusters)
@@ -187,10 +192,10 @@ def exports(self) -> Dict[str, List[Export]]:
187192
if self._exports is None:
188193
self._exports = {}
189194
log.info("Begin export parsing")
190-
for cluster_id in available_clusters(self.mgr):
195+
for cluster_id in known_cluster_ids(self.mgr):
191196
self.export_conf_objs = [] # type: List[Export]
192197
self._read_raw_config(cluster_id)
193-
self.exports[cluster_id] = self.export_conf_objs
198+
self._exports[cluster_id] = self.export_conf_objs
194199
log.info("Exports parsed successfully %s", self.exports.items())
195200
return self._exports
196201

@@ -710,8 +715,6 @@ def _apply_export(
710715
for k in ['path', 'pseudo']:
711716
if k not in new_export_dict:
712717
raise NFSInvalidOperation(f'Export missing required field {k}')
713-
if cluster_id not in available_clusters(self.mgr):
714-
raise ClusterNotFound()
715718
if cluster_id not in self.exports:
716719
self.exports[cluster_id] = []
717720

0 commit comments

Comments
 (0)