From: Anoop C S Date: Thu, 11 Jul 2024 07:46:30 +0000 (+0530) Subject: mgr/nfs: Do not ignore clusters from rados pool conf objects X-Git-Tag: v18.2.5~312^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=33cb3ae5f30038039b294d12a26f873d00992d28;p=ceph.git mgr/nfs: Do not ignore clusters from rados pool conf objects Early handling of NoOrchestrator exception via a2192c73e41e 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 --- diff --git a/src/pybind/mgr/nfs/export.py b/src/pybind/mgr/nfs/export.py index 2d07cd6eab6..c6d5afabfef 100644 --- a/src/pybind/mgr/nfs/export.py +++ b/src/pybind/mgr/nfs/export.py @@ -14,10 +14,9 @@ from typing import ( from os.path import normpath import cephfs -from rados import TimedOut, ObjectNotFound, Rados, LIBRADOS_ALL_NSPACES +from rados import TimedOut, ObjectNotFound, Rados from object_format import ErrorResponse -from orchestrator import NoOrchestrator from mgr_module import NFS_POOL_NAME as POOL_NAME, NFS_GANESHA_SUPPORTED_FSALS from .ganesha_conf import ( @@ -29,7 +28,6 @@ from .ganesha_conf import ( format_block) from .exception import NFSException, NFSInvalidOperation, FSNotFound, NFSObjectNotFound from .utils import ( - CONF_PREFIX, EXPORT_PREFIX, NonFatalError, USER_CONF_PREFIX, @@ -49,11 +47,7 @@ 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 + return set(available_clusters(mgr)) def _check_rados_notify(ioctx: Any, obj: str) -> None: @@ -144,21 +138,6 @@ class NFSRados: return False -def nfs_rados_configs(rados: 'Rados', nfs_pool: str = POOL_NAME) -> Set[str]: - """Return a set of all the namespaces in the nfs_pool where nfs - configuration objects are found. The namespaces also correspond - to the cluster ids. - """ - ns: Set[str] = set() - prefixes = (EXPORT_PREFIX, CONF_PREFIX, USER_CONF_PREFIX) - with rados.open_ioctx(nfs_pool) as ioctx: - ioctx.set_namespace(LIBRADOS_ALL_NSPACES) - for obj in ioctx.list_objects(): - if obj.key.startswith(prefixes): - ns.add(obj.nspace) - return ns - - class AppliedExportResults: """Gathers the results of multiple changed exports. Returned by apply_export. diff --git a/src/pybind/mgr/nfs/utils.py b/src/pybind/mgr/nfs/utils.py index 269079c1ccf..ff5324228b5 100644 --- a/src/pybind/mgr/nfs/utils.py +++ b/src/pybind/mgr/nfs/utils.py @@ -8,6 +8,9 @@ import orchestrator from orchestrator import NoOrchestrator import cephfs from mgr_util import CephfsClient, open_filesystem +from mgr_module import NFS_POOL_NAME as POOL_NAME + +from rados import Rados, LIBRADOS_ALL_NSPACES, ObjectNotFound if TYPE_CHECKING: from nfs.module import Module @@ -67,18 +70,36 @@ def available_clusters(mgr: 'Module') -> List[str]: > return value: ['vstart'] ''' - # TODO check cephadm cluster list with rados pool conf objects try: completion = mgr.describe_service(service_type='nfs') except NoOrchestrator: - log.exception("No orchestrator configured") - return [] + log.debug("No orchestrator configured") + return nfs_rados_configs(mgr.rados) orchestrator.raise_if_exception(completion) assert completion.result is not None return [cluster.spec.service_id for cluster in completion.result if cluster.spec.service_id] +def nfs_rados_configs(rados: 'Rados', nfs_pool: str = POOL_NAME) -> List[str]: + """Return a list of all the namespaces in the nfs_pool where nfs + configuration objects are found. The namespaces also correspond + to the cluster ids. + """ + ns: List[str] = [] + prefixes = (EXPORT_PREFIX, CONF_PREFIX, USER_CONF_PREFIX) + try: + with rados.open_ioctx(nfs_pool) as ioctx: + ioctx.set_namespace(LIBRADOS_ALL_NSPACES) + for obj in ioctx.list_objects(): + if obj.key.startswith(prefixes): + ns.append(obj.nspace) + except ObjectNotFound: + log.debug("Failed to open pool %s", nfs_pool) + finally: + return ns + + def restart_nfs_service(mgr: 'Module', cluster_id: str) -> None: ''' This methods restarts the nfs daemons