Skip to content

Commit 67dbd06

Browse files
committed
mgr/nfs: Do not ignore clusters from rados pool conf objects
Early handling of NoOrchestrator exception via a2192c7 prevented us from looking for namespaces containing conf objects in .nfs pool. This would mean that we fail to recognize such namespaces as clusters thereby prohibiting the creation of nfs exports. We could instead search for such namespaces while handling the NoOrchestrator exception within available_clusters() before returning the final list of clusters. Fixes: https://tracker.ceph.com/issues/66800 Signed-off-by: Anoop C S <[email protected]>
1 parent 6822f4b commit 67dbd06

File tree

2 files changed

+26
-26
lines changed

2 files changed

+26
-26
lines changed

src/pybind/mgr/nfs/export.py

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,9 @@
1414
from os.path import normpath
1515
import cephfs
1616

17-
from rados import TimedOut, ObjectNotFound, Rados, LIBRADOS_ALL_NSPACES
17+
from rados import TimedOut, ObjectNotFound, Rados
1818

1919
from object_format import ErrorResponse
20-
from orchestrator import NoOrchestrator
2120
from mgr_module import NFS_POOL_NAME as POOL_NAME, NFS_GANESHA_SUPPORTED_FSALS
2221

2322
from .ganesha_conf import (
@@ -29,7 +28,6 @@
2928
format_block)
3029
from .exception import NFSException, NFSInvalidOperation, FSNotFound, NFSObjectNotFound
3130
from .utils import (
32-
CONF_PREFIX,
3331
EXPORT_PREFIX,
3432
NonFatalError,
3533
USER_CONF_PREFIX,
@@ -49,11 +47,7 @@
4947

5048
def known_cluster_ids(mgr: 'Module') -> Set[str]:
5149
"""Return the set of known cluster IDs."""
52-
try:
53-
clusters = set(available_clusters(mgr))
54-
except NoOrchestrator:
55-
clusters = nfs_rados_configs(mgr.rados)
56-
return clusters
50+
return set(available_clusters(mgr))
5751

5852

5953
def _check_rados_notify(ioctx: Any, obj: str) -> None:
@@ -155,21 +149,6 @@ def check_user_config(self) -> bool:
155149
return False
156150

157151

158-
def nfs_rados_configs(rados: 'Rados', nfs_pool: str = POOL_NAME) -> Set[str]:
159-
"""Return a set of all the namespaces in the nfs_pool where nfs
160-
configuration objects are found. The namespaces also correspond
161-
to the cluster ids.
162-
"""
163-
ns: Set[str] = set()
164-
prefixes = (EXPORT_PREFIX, CONF_PREFIX, USER_CONF_PREFIX)
165-
with rados.open_ioctx(nfs_pool) as ioctx:
166-
ioctx.set_namespace(LIBRADOS_ALL_NSPACES)
167-
for obj in ioctx.list_objects():
168-
if obj.key.startswith(prefixes):
169-
ns.add(obj.nspace)
170-
return ns
171-
172-
173152
class AppliedExportResults:
174153
"""Gathers the results of multiple changed exports.
175154
Returned by apply_export.

src/pybind/mgr/nfs/utils.py

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
from orchestrator import NoOrchestrator
99
import cephfs
1010
from mgr_util import CephfsClient, open_filesystem
11+
from mgr_module import NFS_POOL_NAME as POOL_NAME
12+
13+
from rados import Rados, LIBRADOS_ALL_NSPACES, ObjectNotFound
1114

1215
if TYPE_CHECKING:
1316
from nfs.module import Module
@@ -67,18 +70,36 @@ def available_clusters(mgr: 'Module') -> List[str]:
6770
<ServiceDescription of <NFSServiceSpec for service_name=nfs.vstart>>
6871
return value: ['vstart']
6972
'''
70-
# TODO check cephadm cluster list with rados pool conf objects
7173
try:
7274
completion = mgr.describe_service(service_type='nfs')
7375
except NoOrchestrator:
74-
log.exception("No orchestrator configured")
75-
return []
76+
log.debug("No orchestrator configured")
77+
return nfs_rados_configs(mgr.rados)
7678
orchestrator.raise_if_exception(completion)
7779
assert completion.result is not None
7880
return [cluster.spec.service_id for cluster in completion.result
7981
if cluster.spec.service_id]
8082

8183

84+
def nfs_rados_configs(rados: 'Rados', nfs_pool: str = POOL_NAME) -> List[str]:
85+
"""Return a list of all the namespaces in the nfs_pool where nfs
86+
configuration objects are found. The namespaces also correspond
87+
to the cluster ids.
88+
"""
89+
ns: List[str] = []
90+
prefixes = (EXPORT_PREFIX, CONF_PREFIX, USER_CONF_PREFIX)
91+
try:
92+
with rados.open_ioctx(nfs_pool) as ioctx:
93+
ioctx.set_namespace(LIBRADOS_ALL_NSPACES)
94+
for obj in ioctx.list_objects():
95+
if obj.key.startswith(prefixes):
96+
ns.append(obj.nspace)
97+
except ObjectNotFound:
98+
log.debug("Failed to open pool %s", nfs_pool)
99+
finally:
100+
return ns
101+
102+
82103
def restart_nfs_service(mgr: 'Module', cluster_id: str) -> None:
83104
'''
84105
This methods restarts the nfs daemons

0 commit comments

Comments
 (0)